-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
33 lines (29 loc) · 1.06 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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=dylib=k4a");
}
if cfg!(target_os = "windows") {
println!("cargo:rustc-link-search=dylib=./vendor/lib/windows/{}", consts::ARCH);
println!("cargo:rustc-link-lib=dylib=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].*")
//.rustified_enum("[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!");
}