-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
34 lines (31 loc) · 1.24 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
// vim: tw=80
#[cfg(target_os = "freebsd")]
fn main() {
use std::{env, path::PathBuf};
println!("cargo::rustc-check-cfg=cfg(crossdocs)");
println!("cargo:rerun-if-env-changed=LLVM_CONFIG_PATH");
println!("cargo:rustc-link-lib=geom");
let bindings = bindgen::Builder::default()
.header("/usr/include/libgeom.h")
.header("/usr/include/sys/devicestat.h")
.allowlist_function("geom_.*")
.allowlist_function("gctl_.*")
.allowlist_function("g_.*")
.allowlist_type("devstat_trans_flags")
.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("bindings.rs"))
.expect("Couldn't write bindings!");
}
#[cfg(not(target_os = "freebsd"))]
fn main() {
println!("cargo::rustc-check-cfg=cfg(crossdocs)");
// If we're building not on FreeBSD, there's no way the build can succeed.
// This probably means we're building docs on docs.rs, so set this config
// variable. We'll use it to stub out the crate well enough that
// freebsd-libgeom's docs can build.
println!("cargo:rustc-cfg=crossdocs");
}