-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
42 lines (36 loc) · 1.18 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
34
35
36
37
38
39
40
41
42
extern crate bindgen;
use std::env;
use std::path::PathBuf;
macro_rules! add_header {
($builder:ident, $header:literal) => {
$builder = $builder.header($header);
}
}
fn main() {
println!("cargo:rustc-link-lib=tss2-rc");
println!("cargo:rustc-link-lib=tss2-mu");
#[cfg(feature = "sys")]
println!("cargo:rustc-link-lib=tss2-sys");
#[cfg(feature = "esys")]
println!("cargo:rustc-link-lib=tss2-esys");
#[cfg(feature = "fapi")]
println!("cargo:rustc-link-lib=tss2-fapi");
println!("cargo:rerun-if-changed=wrapper.h");
let mut builder = bindgen::Builder::default()
.size_t_is_usize(false)
.header("wrapper.h");
#[cfg(feature = "sys")]
add_header!(builder, "sys.h");
#[cfg(feature = "esys")]
add_header!(builder, "esys.h");
#[cfg(feature = "fapi")]
add_header!(builder, "fapi.h");
let bindings = builder
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("tss2.rs"))
.expect("Couldn't write bindings!");
}