use std::env; use std::io; use std::path::PathBuf; use lazy_static::lazy_static; use bindgen; lazy_static! { static ref OUT_DIR: PathBuf = { let out_dir = env::var("OUT_DIR").unwrap(); PathBuf::from(out_dir) }; static ref ROOT_DIR: PathBuf = { let root_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); PathBuf::from(root_dir) }; } fn main() -> io::Result<()> { const SECCOMP_HEADER: &str = "/usr/include/seccomp.h"; println!("cargo:rustc-link-lib=dylib=seccomp"); println!("cargo:rerun-if-changed={}", SECCOMP_HEADER); bindgen::builder() .header_contents("seccomp.h", "#include") .generate() .expect("Failed to generate libseccomp bindings") .write_to_file(OUT_DIR.join("libseccomp.rs"))?; Ok(()) }