-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
45 lines (33 loc) · 1021 Bytes
/
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
35
36
37
38
39
40
41
42
43
44
45
use std::env;
use std::path::PathBuf;
use coin_build_tools::coinbuilder;
const HEADER: &str = "Cbc_C_Interface.h";
fn main() {
bindgen_lib();
}
fn bindgen_lib() {
let (include, _) = coinbuilder::get_metadata_from("Cbc");
let mut header_path = String::new();
for i in &include {
let path = PathBuf::from(i).join(HEADER);
if path.exists() {
header_path = path.display().to_string();
break;
}
}
println!("{:?}", include);
let clang_args = include
.iter()
.map(|dir| format!("-I{}", dir))
.collect::<Vec<String>>();
let bindings = bindgen::Builder::default()
.header(header_path)
.clang_args(clang_args.iter())
.trust_clang_mangling(false)
.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!");
}