-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
36 lines (33 loc) · 1.2 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
use std::env;
use std::fs::File;
use std::io::Read;
use std::process::Command;
extern crate cc;
fn main() {
println!("cargo:rerun-if-changed=src/vtitun.c");
// build with cc
cc::Build::new()
.file("src/vtitun.c")
.compile("libvtitun.a");
// static link the musl target
if env::var("TARGET").unwrap() == "x86_64-unknown-linux-musl" {
let mut cmd = Command::new("./build_seccomp.sh");
let output = cmd.output().expect("cmd failed to start");
if !output.status.success() {
println!(
"failed to build libseccomp:\n{}\n{}",
&std::str::from_utf8(&output.stdout).unwrap(),
&std::str::from_utf8(&output.stderr).unwrap()
);
let mut f = File::open("libseccomp/config.log").unwrap();
let mut result = String::new();
f.read_to_string(&mut result).unwrap();
println!{"{}", &result};
std::process::exit(1);
}
let pwd = std::env::var("PWD").unwrap();
let dir = format!("{}/libseccomp/src/.libs", pwd);
println!("cargo:rustc-link-search=native={}", dir);
println!("cargo:rustc-link-lib=static=seccomp");
}
}