-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
49 lines (44 loc) · 1.95 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use std::env;
use std::error::Error;
use std::path::PathBuf;
fn main() -> Result<(), Box<dyn Error>> {
let make = cmake::Config::new("./igraph-0.9.9")
.env("IGRAPH_STATIC", "1")
.build();
println!("cargo:rustc-link-search=native={}", make.display());
println!("cargo:rustc-link-search=native={}/lib64", make.display());
println!("cargo:rustc-link-lib=igraph");
// Tell cargo to invalidate the built crate whenever the wrapper changes
println!("cargo:rerun-if-changed=igraph-sys.h");
let bindings = bindgen::Builder::default()
// The input header we would like to generate
// bindings for.
.header("igraph-sys.h")
// Tell cargo to invalidate the built crate whenever any of the
// included header files changed.
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.allowlist_type("igraph_t")
.allowlist_type("igraph_vector_t")
.allowlist_type("igraph_real_t")
.allowlist_type("igraph_i_directed_t")
.allowlist_function("igraph_vector_view")
.allowlist_function("igraph_create")
.allowlist_function("igraph_destroy")
.allowlist_function("igraph_vector_init")
.allowlist_function("igraph_vector_max")
.allowlist_function("igraph_vector_which_max")
.allowlist_function("igraph_degree")
.allowlist_function("igraph_closeness")
.allowlist_function("igraph_vector_destroy")
.allowlist_function("igraph_graph_destroy")
.allowlist_function("igraph_vss_all")
.rustified_enum("igraph_neimode_t")
.rustified_enum("igraph_i_directed_t")
.clang_arg(format!("-I{}/include/igraph", make.display()))
// Finish the builder and generate the bindings.
.generate()?;
// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings.write_to_file(out_path.join("igraph.rs"))?;
Ok(())
}