| use std::env; |
| use std::path::PathBuf; |
| |
| fn main() { |
| // Generate C header bindings. |
| println!("cargo:rerun-if-changed=wrapper.h"); |
| |
| let bindings = bindgen::Builder::default() |
| .header("bindings.h") |
| .parse_callbacks(Box::new(bindgen::CargoCallbacks)) |
| .generate() |
| .expect("Unable to generate C bindings"); |
| |
| let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); |
| bindings |
| .write_to_file(out_path.join("bindings.rs")) |
| .expect("Unable to write bindings.rs"); |
| |
| // Compile C code. |
| cc::Build::new() |
| .file("c/swap.c") |
| .flag("-std=c17") |
| .compile("swap"); |
| } |