-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
30 lines (24 loc) · 1.09 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
fn main() {
println!("cargo:rerun-if-changed=src/customlabels.c");
println!("cargo:rerun-if-changed=src/customlabels.h");
println!("cargo:rerun-if-changed=./dlist");
cc::Build::new()
.file("src/customlabels.c")
.compile("customlabels");
println!("cargo:rustc-link-lib=static=customlabels");
println!("cargo:rustc-link-arg=-Wl,--dynamic-list=./dlist");
// let dlist_path = format!("{}/dlist", std::env::var("OUT_DIR").unwrap());
// std::fs::copy("./dlist", &dlist_path).unwrap();
// println!("cargo::metadata=dlist-path={}", dlist_path);
// Generate bindings using bindgen
let bindings = bindgen::Builder::default()
.header("src/customlabels.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate()
.expect("Unable to generate bindings");
// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}