use cmake::Config;
use bindgen::builder;
#[cfg(target_os = "macos")]
fn link_cpp() {
println!("cargo:rustc-link-lib=c++");
}
#[cfg(not(target_os = "macos"))]
fn link_cpp() {
println!("cargo:rustc-link-lib=stdc++");
}
fn main() {
let dst = Config::new("c-wrapper")
.build_target("linkrs")
.build();
let builddir = dst.join("build");
println!("cargo:rustc-link-search=native={}", builddir.display());
println!("cargo:rustc-link-lib=static=linkrs");
link_cpp();
let bindings = builder()
.header("c-wrapper/link_rs.h")
.whitelist_function("Link_.*")
.whitelist_function("SessionState_.*")
.whitelist_function("Clock_.*")
.generate()
.expect("generate bindings");
let outfile = dst.join("link_rs.rs");
bindings.write_to_file(outfile).expect("write bindings to file");
}