diff --git a/.gitignore b/.gitignore index 4726f05..ea8c4bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ /target -bindings.rs diff --git a/build.rs b/build.rs index b20c1c3..a628de2 100644 --- a/build.rs +++ b/build.rs @@ -1,17 +1,6 @@ -use std::fs::OpenOptions; -use std::io::Write; use std::path::PathBuf; fn main() { - let out_path = PathBuf::from("src/native/linux/bindings.rs"); - - let mut bindings_file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .open(out_path) - .unwrap(); - if cfg!(target_os = "linux") { const HEADER_FILE: &str = "src/native/linux/bluetooth_linux.h"; println!("cargo:rerun-if-changed={HEADER_FILE}"); @@ -22,10 +11,9 @@ fn main() { .generate() .expect("Failed to generate bindings for libbluetooth"); - bindings_file.write_all(b"#![allow(warnings)]\n\n").unwrap(); - + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); bindings - .write(Box::new(bindings_file)) + .write_to_file(out_dir.join("bindings.rs")) .expect("Failed to write bindings for libbluetooth"); println!("cargo:rustc-link-lib=bluetooth"); diff --git a/src/native/linux/bindings.rs b/src/native/linux/bindings.rs new file mode 100644 index 0000000..792f9ab --- /dev/null +++ b/src/native/linux/bindings.rs @@ -0,0 +1,3 @@ +#![allow(warnings)] + +include!(concat!(env!("OUT_DIR"), "/bindings.rs"));