-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
52 lines (45 loc) · 1.75 KB
/
build.rs
File metadata and controls
52 lines (45 loc) · 1.75 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
// build.rs
//
// Compiles the small C++ shim (`src/mcpnet.cpp`) that wraps the header-only
// mcpnet kernel templates, and wires it up to the Rust side through `cxx`.
use std::path::PathBuf;
fn main() {
let crate_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let mcpnet_root = crate_dir.join("src").join("mcpnet");
let mcpnet_include = mcpnet_root.join("include");
let splash_include = mcpnet_root.join("ext").join("splash").join("include");
let fmt_include = mcpnet_root
.join("ext")
.join("splash")
.join("ext")
.join("fmt")
.join("include");
for path in [&mcpnet_include, &splash_include, &fmt_include] {
assert!(
path.exists(),
"missing include directory: {} (did you run `git submodule update --init --recursive`?)",
path.display()
);
}
let mut build = cxx_build::bridge("src/lib.rs");
build
.file("src/mcpnet.cpp")
.include(crate_dir.join("include"))
.include(&mcpnet_include)
.include(&splash_include)
.include(&fmt_include)
.std("c++14")
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-Wno-unused-variable")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-sign-compare")
.flag_if_supported("-Wno-deprecated-declarations")
.flag_if_supported("-Wimplicit-fallthrough=0")
.flag_if_supported("-ffast-math")
.flag_if_supported("-funroll-loops");
build.compile("mcpnet_rs");
println!("cargo:rerun-if-changed=src/lib.rs");
println!("cargo:rerun-if-changed=src/mcpnet.cpp");
println!("cargo:rerun-if-changed=include/mcpnet.h");
println!("cargo:rerun-if-changed=build.rs");
}