-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.rs
26 lines (22 loc) · 813 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
use std::env;
use std::fs;
use std::path::Path;
fn supports_scmp_act_kill_process() -> bool {
pkg_config::Config::new()
.atleast_version("2.4.0")
.env_metadata(true)
.probe("libseccomp")
.is_ok()
}
fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("const.rs");
let code = if supports_scmp_act_kill_process() {
"pub const DEFAULT_KILL: Action = Action::KillProcess;"
} else {
"pub const DEFAULT_KILL: Action = Action::KillThread;"
};
let code = format!("/// The default kill action, defaults to KillProcess on supported libseccomp versions and falls back to KillThread otherwise\n{}", code);
fs::write(dest_path, code).unwrap();
println!("cargo:rerun-if-changed=build.rs");
}