use std::{env, path::PathBuf}; const BLURAY_HEADER: &str = "#include \n #include \n #include \n #include \n #include \n #include \n #include \n"; const AACS_HEADER: &str = "#include \n"; const BDPLUS_HEADER: &str = "#include \n"; fn main() { let mut header = String::new(); header.push_str(BLURAY_HEADER); println!("cargo:rustc-link-lib=bluray"); #[cfg(feature = "aacs")] { header.push_str(AACS_HEADER); println!("cargo:rustc-link-lib=aacs"); } #[cfg(feature = "bdplus")] { header.push_str(BDPLUS_HEADER); println!("cargo:rustc-link-lib=bdplus"); } let bindings = bindgen::Builder::default() .header_contents("wrapper.h", header.as_str()) // Fix error E0133 (see https://github.com/rust-lang/rust/issues/46043) .derive_debug(false) .generate() .expect("Unable to generate bindings"); let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); }