#[cfg(not(feature = "bindgen"))] fn main() {} #[cfg(feature = "bindgen")] fn main() { use std::env; use std::path::PathBuf; const INCLUDE: &str = r#" #include #include "#; #[cfg(not(feature = "overwrite"))] let outdir = PathBuf::from(env::var("OUT_DIR").unwrap()); #[cfg(feature = "overwrite")] let outdir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("src/netdev/sys"); bindgen::Builder::default() .header_contents("include-file.h", INCLUDE) .allowlist_type("ifreq") .allowlist_var("SIOCGIFINDEX") .generate() .unwrap() .write_to_file(outdir.join("sys.rs")) .unwrap(); }