forked from libpnet/rust-dpdk
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.rs
27 lines (25 loc) · 865 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
extern crate bindgen;
use std::path::PathBuf;
use std::process::Command;
fn main() {
println!("cargo:rustc-link-lib=dpdk");
let bindings = bindgen::Builder::default()
.header("rte.h")
.generate_inline_functions(true)
.clang_arg("-I/usr/local/include/dpdk")
.clang_arg("-Wno-error=implicit-function-declaration")
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from("src");
bindings
.write_to_file(out_path.join("ffi.rs"))
.expect("Cooudn't write bindings");
let mut child = Command::new("perl")
.arg("-pi")
.arg("-e")
.arg("s/(pub static mut per_lcore__lcore_id)/ #[thread_local] $1/")
.arg(out_path.join("ffi.rs").as_os_str())
.spawn()
.expect("failed to execute perl");
let _ = child.wait();
}