mirror of
https://github.com/storytold/k4a-sys-temp.git
synced 2026-10-09 00:09:45 +00:00
30 lines
945 B
Rust
30 lines
945 B
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-search=native=./vendor/lib/linux");
|
|
}
|
|
if cfg!(target_os = "windows") {
|
|
println!("cargo:rustc-link-search=native=./vendor/lib/windows/{}", consts::ARCH);
|
|
}
|
|
println!("cargo:rustc-link-lib=static=k4a");
|
|
|
|
let bindings = bindgen::Builder::default()
|
|
.header("wrapper.h")
|
|
.clang_arg(format!("-I./vendor/include/{}", consts::OS))
|
|
.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!");
|
|
}
|