-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
30 lines (24 loc) · 1.04 KB
/
build.rs
File metadata and controls
30 lines (24 loc) · 1.04 KB
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
use std::{env, path::PathBuf};
fn main() {
// these headers cause problems with circular includes, so we don't generate bindings for them
let disallowed_headers = vec!["rastarole.h".into()];
println!("cargo:rerun-if-changed=rasta-sys");
let mut dst = cmake::build("librasta");
dst.push("lib");
println!("cargo:rustc-link-search=native={}", dst.display());
println!("cargo:rustc-link-lib=dylib=rasta");
let mut bindings = bindgen::Builder::default().clang_arg("-Ilibrasta/src/include/");
for header in std::fs::read_dir("librasta/src/include/rasta").expect("Failed to read directory")
{
let header = header.unwrap();
if !disallowed_headers.contains(&header.file_name().to_string_lossy().into_owned()) {
bindings = bindings.header(header.path().to_string_lossy());
}
}
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.generate()
.unwrap()
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}