forked from jonhoo/rust-ibverbs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
60 lines (54 loc) · 2.11 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
50
51
52
53
54
55
56
57
58
59
60
extern crate bindgen;
use std::env;
use std::path::PathBuf;
use std::process::Command;
fn main() {
println!("cargo:include=vendor/rdma-core/build/include");
println!("cargo:rustc-link-search=native=vendor/rdma-core/build/lib");
println!("cargo:rustc-link-lib=ibverbs");
// initialize and update submodules
Command::new("git")
.args(&["submodule", "update", "--init"])
.status()
.expect("Failed to update submodules.");
// build vendor/rdma-core
Command::new("bash")
.current_dir("vendor/rdma-core/")
.args(&["build.sh"])
.status()
.expect("Failed to build vendor/rdma-core using build.sh");
// generate the bindings
let bindings = bindgen::Builder::default()
.header("vendor/rdma-core/libibverbs/verbs.h")
.clang_arg("-Ivendor/rdma-core/build/include/")
// https://github.com/servo/rust-bindgen/issues/550
.blacklist_type("max_align_t")
.whitelist_function("ibv_.*")
.whitelist_type("ibv_.*")
.bitfield_enum("ibv_access_flags")
.bitfield_enum("ibv_qp_attr_mask")
.bitfield_enum("ibv_wc_flags")
.bitfield_enum("ibv_send_flags")
.bitfield_enum("ibv_port_cap_flags")
.constified_enum_module("ibv_qp_type")
.constified_enum_module("ibv_qp_state")
.constified_enum_module("ibv_port_state")
.constified_enum_module("ibv_wc_opcode")
.constified_enum_module("ibv_wr_opcode")
.constified_enum_module("ibv_wc_status")
//.constified_enum_module("IBV_WC_.*")
//.constified_enum_module("IBV_WR_.*")
//.constified_enum_module("IBV_QPS_.*")
//.constified_enum_module("IBV_PORT_.*")
.derive_default(true)
.derive_debug(true)
.prepend_enum_name(false)
.blacklist_type("ibv_wc")
.generate()
.expect("Unable to generate bindings");
// 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("bindings.rs"))
.expect("Could not write bindings");
}