-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
29 lines (23 loc) · 870 Bytes
/
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
extern crate bindgen;
use std::env;
use std::path::PathBuf;
fn main() {
let mut bindings = bindgen::Builder::default()
.header("wrapper.h")
.rust_target(bindgen::RustTarget::Stable_1_25)
.constified_enum_module("*")
.derive_debug(true)
.derive_default(true)
.derive_partialeq(true)
.rustfmt_bindings(true);
if std::env::var("TARGET").unwrap().find("linux").is_none() {
bindings = bindings.clang_arg("-Ilinux-headers");
}
let generated = bindings.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());
generated
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
println!("cargo:rerun-if-changed=wrapper.h");
}