-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
23 lines (18 loc) · 714 Bytes
/
build.rs
File metadata and controls
23 lines (18 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::env;
use std::error::Error;
use std::path::PathBuf;
fn main() -> Result<(), Box<dyn Error>> {
cc::Build::new().file("some-c/gcd.c").compile("gcd");
// Force parsing for x86_64-linux since the C header is platform-agnostic
// but clang may fail to parse when targeting wasm without proper sysroot
let bindings = bindgen::builder()
.header("some-c/gcd.h")
.use_core()
.clang_arg("--target=x86_64-unknown-linux-gnu")
.generate()?;
let out_path = PathBuf::from(env::var("OUT_DIR")?);
bindings.write_to_file(out_path.join("bindings.rs"))?;
println!("cargo:rerun-if-changed=some-c");
println!("cargo:rerun-if-changed=build.rs");
Ok(())
}