refactor: split cargo workspace
This commit is contained in:
parent
5db14936e7
commit
1c21bd1259
695 changed files with 32023 additions and 44964 deletions
175
crates/libinput/build.rs
Normal file
175
crates/libinput/build.rs
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
use {
|
||||
repc::layout::{Type, TypeVariant},
|
||||
std::{
|
||||
env,
|
||||
fs::{File, OpenOptions},
|
||||
io::{self, BufWriter, Write},
|
||||
path::PathBuf,
|
||||
},
|
||||
};
|
||||
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! cenum {
|
||||
($name:ident, $uc:ident; $($name2:ident = $val:expr,)*) => {
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub struct $name(pub i32);
|
||||
|
||||
impl $name {
|
||||
pub fn raw(self) -> i32 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
$(
|
||||
pub const $name2: $name = $name($val);
|
||||
)*
|
||||
|
||||
pub const $uc: &[i32] = &[$($val,)*];
|
||||
};
|
||||
}
|
||||
|
||||
#[path = "src/consts.rs"]
|
||||
mod consts;
|
||||
|
||||
fn open(s: &str) -> io::Result<BufWriter<File>> {
|
||||
let mut path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
path.push(s);
|
||||
Ok(BufWriter::new(
|
||||
OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.truncate(true)
|
||||
.open(path)?,
|
||||
))
|
||||
}
|
||||
|
||||
fn get_target() -> repc::Target {
|
||||
let rustc_target = env::var("TARGET").unwrap();
|
||||
repc::TARGET_MAP
|
||||
.iter()
|
||||
.cloned()
|
||||
.find(|t| t.0 == rustc_target)
|
||||
.unwrap()
|
||||
.1
|
||||
}
|
||||
|
||||
fn get_enum_ty(variants: Vec<i128>) -> anyhow::Result<u64> {
|
||||
let target = get_target();
|
||||
let ty = Type {
|
||||
layout: (),
|
||||
annotations: vec![],
|
||||
variant: TypeVariant::Enum(variants),
|
||||
};
|
||||
let ty = repc::compute_layout(target, &ty)?;
|
||||
assert!(ty.layout.pointer_alignment_bits <= ty.layout.size_bits);
|
||||
Ok(ty.layout.size_bits)
|
||||
}
|
||||
|
||||
fn write_ty<W: Write>(f: &mut W, vals: &[i32], ty: &str) -> anyhow::Result<()> {
|
||||
let variants: Vec<_> = vals.iter().cloned().map(|v| v as i128).collect();
|
||||
let size = get_enum_ty(variants)?;
|
||||
writeln!(f, "#[allow(clippy::allow_attributes, dead_code)]")?;
|
||||
writeln!(f, "pub type {} = i{};", ty, size)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let mut f = open("libinput_tys.rs")?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_LOG_PRIORITY,
|
||||
"libinput_log_priority",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_DEVICE_CAPABILITY,
|
||||
"libinput_device_capability",
|
||||
)?;
|
||||
write_ty(&mut f, consts::LIBINPUT_KEY_STATE, "libinput_key_state")?;
|
||||
write_ty(&mut f, consts::LIBINPUT_LED, "libinput_led")?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_BUTTON_STATE,
|
||||
"libinput_button_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_POINTER_AXIS,
|
||||
"libinput_pointer_axis",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_POINTER_AXIS_SOURCE,
|
||||
"libinput_pointer_axis_source",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_TABLET_PAD_RING_AXIS_SOURCE,
|
||||
"libinput_tablet_pad_ring_axis_source",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_TABLET_PAD_STRIP_AXIS_SOURCE,
|
||||
"libinput_tablet_pad_strip_axis_source",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_TABLET_TOOL_TYPE,
|
||||
"libinput_tablet_tool_type",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_TABLET_TOOL_PROXIMITY_STATE,
|
||||
"libinput_tablet_tool_proximity_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_TABLET_TOOL_TIP_STATE,
|
||||
"libinput_tablet_tool_tip_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_SWITCH_STATE,
|
||||
"libinput_switch_state",
|
||||
)?;
|
||||
write_ty(&mut f, consts::LIBINPUT_SWITCH, "libinput_switch")?;
|
||||
write_ty(&mut f, consts::LIBINPUT_EVENT_TYPE, "libinput_event_type")?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_STATUS,
|
||||
"libinput_config_status",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_ACCEL_PROFILE,
|
||||
"libinput_config_accel_profile",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_TAP_STATE,
|
||||
"libinput_config_tap_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_DRAG_STATE,
|
||||
"libinput_config_drag_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_DRAG_LOCK_STATE,
|
||||
"libinput_config_drag_lock_state",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_CLICK_METHOD,
|
||||
"libinput_config_click_method",
|
||||
)?;
|
||||
write_ty(
|
||||
&mut f,
|
||||
consts::LIBINPUT_CONFIG_MIDDLE_EMULATION_STATE,
|
||||
"libinput_config_middle_emulation_state",
|
||||
)?;
|
||||
|
||||
println!("cargo:rerun-if-changed=src/consts.rs");
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue