-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.rs
48 lines (40 loc) · 1.35 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
37
38
39
40
41
42
43
44
45
46
47
48
use cxx_build::bridges;
use glob::glob;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=src/lib.rs");
let cpp_files = glob("RocketSim/libsrc/bullet3-3.24/**/*.cpp")
.unwrap()
.chain(glob("RocketSim/src/**/*.cpp").unwrap())
.flatten()
.chain([PathBuf::from("arenar/arenar.cpp")])
.collect::<Vec<_>>();
for file in &cpp_files {
println!("cargo:rerun-if-changed={}", file.display());
}
let rust_files: Vec<PathBuf> = glob("src/sim/*.rs")
.unwrap()
.chain(glob("RocketSim/src/**/*.rs").unwrap())
.flatten()
.filter(|path| !path.ends_with("mod.rs"))
.chain([PathBuf::from("src/math.rs"), PathBuf::from("src/lib.rs")])
.collect::<Vec<_>>();
let mut builder = bridges(rust_files);
if !cfg!(debug_assertions) || !cfg!(feature = "debug_logging") {
builder.define("RS_DONT_LOG", "1");
}
if !cfg!(debug_assertions) {
builder.define("RS_MAX_SPEED", "1");
builder.flag_if_supported("-flto=thin");
builder.opt_level_str("3");
}
builder
.includes(["RocketSim/src/", "arenar/"])
.std("c++20")
.use_plt(false)
.flag_if_supported("-march=native")
.flag_if_supported("-w")
.files(cpp_files)
.warnings(false)
.compile("rocketsim");
}