-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
25 lines (22 loc) · 846 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
use std::path::PathBuf;
fn main() {
if cfg!(feature = "test") {
let src_dir = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap());
let test_dir = &format!("{}/tests/testdata", src_dir.to_str().unwrap());
println!("cargo:rerun-if-changed={}", format!("{}/test.c", test_dir));
cc::Build::new()
.compiler("/usr/bin/clang-10")
.no_default_flags(true)
.warnings(false)
.cargo_metadata(false)
.file(format!("{}/test.c", test_dir))
.include(test_dir)
.include("/usr/include/x86_64-linux-gnu")
.flag("-g")
.flag("-O2")
.flag("--target=bpf")
.out_dir(test_dir)
.compile("test");
std::fs::remove_file(format!("{}/libtest.a", test_dir)).unwrap();
}
}