use std::env;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=ONEcode/ONElib.c");
println!("cargo:rerun-if-changed=ONEcode/ONElib.h");
cc::Build::new()
.file("ONEcode/ONElib.c")
.include("ONEcode")
.flag("-fPIC")
.flag("-fno-strict-aliasing")
.flag("-DNDEBUG")
.flag("-std=c11") .warnings(true)
.extra_warnings(true)
.opt_level(3)
.compile("ONE");
println!("cargo:rustc-link-lib=pthread");
let bindings = bindgen::Builder::default()
.header("ONEcode/ONElib.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.allowlist_type("OneFile")
.allowlist_type("OneSchema")
.allowlist_type("OneProvenance")
.allowlist_type("OneReference")
.allowlist_type("OneCounts")
.allowlist_type("OneStat")
.allowlist_type("OneType")
.allowlist_type("OneField")
.allowlist_type("OneCodec")
.allowlist_type("I8")
.allowlist_type("I16")
.allowlist_type("I32")
.allowlist_type("I64")
.allowlist_type("U8")
.allowlist_function("oneFile.*")
.allowlist_function("oneSchema.*")
.allowlist_function("one.*")
.allowlist_function("_oneList")
.allowlist_function("_oneCompressedList")
.allowlist_var("DNAcodec")
.allowlist_var("oneTypeString")
.rustified_enum("OneType")
.use_core()
.clang_arg("-I./ONEcode")
.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!");
}