rkvm/input/build.rs

34 lines
898 B
Rust
Raw Normal View History

2020-09-16 18:04:18 +02:00
use bindgen::{Builder, CargoCallbacks};
2021-01-11 21:47:14 +01:00
use pkg_config::Config;
2020-09-16 18:04:18 +02:00
use std::env;
use std::path::PathBuf;
fn main() {
match env::var("CARGO_CFG_TARGET_OS").unwrap().as_str() {
"windows" => return,
"linux" => {}
_ => panic!("Unsupported target OS"),
}
2020-10-25 18:35:50 +01:00
println!("cargo:rerun-if-changed=glue/glue.h");
2020-09-16 18:04:18 +02:00
2021-01-11 21:47:14 +01:00
let library = Config::new()
.atleast_version("1.9.1")
.probe("libevdev")
.unwrap();
let args = library
.include_paths
.iter()
.map(|path| format!("-I{}", path.as_os_str().to_str().unwrap()));
2020-09-16 18:04:18 +02:00
let bindings = Builder::default()
2020-10-25 18:35:50 +01:00
.header("glue/glue.h")
2021-01-11 21:47:14 +01:00
.clang_args(args)
2020-09-16 18:04:18 +02:00
.parse_callbacks(Box::new(CargoCallbacks))
.generate()
.unwrap();
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
2020-10-25 18:35:50 +01:00
bindings.write_to_file(out_path.join("glue.rs")).unwrap();
2020-09-16 18:04:18 +02:00
}