-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
34 lines (29 loc) · 1.02 KB
/
build.rs
File metadata and controls
34 lines (29 loc) · 1.02 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
31
32
33
34
use std::{env, path::PathBuf};
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
fn main() -> Result<()> {
println!("cargo:rerun-if-changed=wrapper.h");
let src = ["wrapper.cpp", "vendor/proj/proj.cpp"];
cc::Build::new()
.cpp(true)
.files(src.iter())
.flag("-std=c++11")
.warnings(false)
.compile("proj");
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.clang_arg("-Ivendor/proj")
.allowlist_function("newConfig")
.allowlist_function("delConfig")
.allowlist_function("setInherited")
.allowlist_function("printInherited")
.allowlist_function("setComposed")
.allowlist_function("printComposed")
.opaque_type("std::.*")
.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!");
Ok(())
}