Files
k4a-sys-temp/build.rs
T
Amédée d'Aboville 347a89b1d3 Remove vendor/lib/linux contents because they are dynamic libraries and not static libraries.
This means they won't be linked against and the user still needs to have libk4a installed on their computer.
I'm not sure about the windows side yet, if it's an import library or a static library so I will check that later.
2020-02-20 15:16:08 -05:00

33 lines
1.0 KiB
Rust

extern crate bindgen;
use std::env;
use std::env::consts;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=wrapper.h");
if cfg!(target_os = "linux") {
println!("cargo:rustc-link-lib=cdylib=k4a");
}
if cfg!(target_os = "windows") {
println!("cargo:rustc-link-search=native=./vendor/lib/windows/{}", consts::ARCH);
println!("cargo:rustc-link-lib=native=k4a");
}
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.clang_arg(format!("-I./vendor/include/{}", consts::OS))
.whitelist_function("k4a.*")
.whitelist_type("_?[kK]4[aA].*")
.whitelist_var("[kK]4[aA].*")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");
// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}