This repository was archived by the owner on Jan 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
62 lines (51 loc) · 1.38 KB
/
build.rs
File metadata and controls
62 lines (51 loc) · 1.38 KB
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
61
62
extern crate bindgen;
extern crate cc;
extern crate glob;
use glob::glob;
use std::env;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=src/cpp");
let bindings = bindgen::Builder::default()
.header("src/cpp/exports.hpp")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("cpp_exports.rs"))
.expect("Couldn't write bindings!");
build_cpp_child_process();
build_libcgroups();
build_libnetns();
}
fn build_cpp_child_process() {
let files = glob("src/cpp/child_process/**/*.cpp")
.unwrap()
.map(|r| r.unwrap());
cc::Build::new()
.cpp(true)
.flag("-std=c++17")
.files(files)
.compile("child_process.a");
}
fn build_libcgroups() {
let files = glob("src/cpp/libcgroups/**/*.cpp")
.unwrap()
.map(|r| r.unwrap());
cc::Build::new()
.cpp(true)
.flag("-std=c++17")
.files(files)
.compile("libcgroups.a");
}
fn build_libnetns() {
let files = glob("src/cpp/libnetns/**/*.cpp")
.unwrap()
.map(|r| r.unwrap());
cc::Build::new()
.cpp(true)
.flag("-std=c++17")
.files(files)
.compile("libnetns.a");
}