use bindgen::builder;
use std::{env, path::PathBuf, process::Command};
fn main() {
Command::new("cmake")
.current_dir("./c")
.args(["-S.", "-Bbuild"])
.output()
.expect("failed to execute process");
Command::new("cmake")
.current_dir("./c")
.args(["--build", "build"])
.output()
.expect("failed to execute process");
println!("cargo:rustc-link-lib=static=apsi");
println!("cargo:rustc-link-search=native=./c/build");
let bindings = bindgen::Builder::default()
.header("./c/fourq/FourQ.h")
.header("./c/fourq/FourQ_api.h")
.header("./c/fourq/FourQ_define.h")
.header("./c/fourq/FourQ_internal.h")
.clang_arg("-I./c")
.derive_default(true)
.generate()
.expect("failed to generate");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings");
}