blob: 7b5130d88234ba987217052fca01f9ae229aa73d [file] [log] [blame]
Matthias Andreas Benkard08586462020-06-28 22:42:43 +02001use std::env;
2use std::path::PathBuf;
3
4fn main() {
5 // Generate C header bindings.
Matthias Andreas Benkardbf331462020-06-28 22:46:43 +02006 println!("cargo:rerun-if-changed=bindings.h");
Matthias Andreas Benkard08586462020-06-28 22:42:43 +02007
8 let bindings = bindgen::Builder::default()
9 .header("bindings.h")
10 .parse_callbacks(Box::new(bindgen::CargoCallbacks))
11 .generate()
12 .expect("Unable to generate C bindings");
13
14 let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
15 bindings
16 .write_to_file(out_path.join("bindings.rs"))
17 .expect("Unable to write bindings.rs");
18
19 // Compile C code.
20 cc::Build::new()
21 .file("c/swap.c")
22 .flag("-std=c17")
23 .compile("swap");
24}