gecko-dev/third_party/rust/authenticator/build.rs

55 строки
2.1 KiB
Rust

#[cfg(all(target_os = "linux", feature = "binding-recompile"))]
extern crate bindgen;
#[cfg(all(target_os = "linux", feature = "binding-recompile"))]
use std::path::PathBuf;
#[cfg(any(not(target_os = "linux"), not(feature = "binding-recompile")))]
fn main() {}
#[cfg(all(target_os = "linux", feature = "binding-recompile"))]
fn main() {
let bindings = bindgen::Builder::default()
.header("src/linux/hidwrapper.h")
.whitelist_var("_HIDIOCGRDESCSIZE")
.whitelist_var("_HIDIOCGRDESC")
.generate()
.expect("Unable to get hidraw bindings");
let out_path = PathBuf::new();
let name = if cfg!(target_arch = "x86") {
"ioctl_x86.rs"
} else if cfg!(target_arch = "x86_64") {
"ioctl_x86_64.rs"
} else if cfg!(all(target_arch = "mips", target_endian = "big")) {
"ioctl_mipsbe.rs"
} else if cfg!(all(target_arch = "mips", target_endian = "little")) {
"ioctl_mipsle.rs"
} else if cfg!(all(target_arch = "mips64", target_endian = "little")) {
"ioctl_mips64le.rs"
} else if cfg!(all(target_arch = "powerpc", target_endian = "little")) {
"ioctl_powerpcle.rs"
} else if cfg!(all(target_arch = "powerpc", target_endian = "big")) {
"ioctl_powerpcbe.rs"
} else if cfg!(all(target_arch = "powerpc64", target_endian = "little")) {
"ioctl_powerpc64le.rs"
} else if cfg!(all(target_arch = "powerpc64", target_endian = "big")) {
"ioctl_powerpc64be.rs"
} else if cfg!(all(target_arch = "arm", target_endian = "little")) {
"ioctl_armle.rs"
} else if cfg!(all(target_arch = "arm", target_endian = "big")) {
"ioctl_armbe.rs"
} else if cfg!(all(target_arch = "aarch64", target_endian = "little")) {
"ioctl_aarch64le.rs"
} else if cfg!(all(target_arch = "aarch64", target_endian = "big")) {
"ioctl_aarch64be.rs"
} else if cfg!(all(target_arch = "s390x", target_endian = "big")) {
"ioctl_s390xbe.rs"
} else {
panic!("architecture not supported");
};
bindings
.write_to_file(out_path.join("src").join("linux").join(name))
.expect("Couldn't write hidraw bindings");
}