-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.rs
65 lines (54 loc) · 1.78 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use std::env;
fn main() {
let mut build = cc::Build::new();
build
.include("./mimalloc/include")
.include("./mimalloc/src")
.file("./mimalloc/src/static.c")
.define("MI_BUILD_SHARED", "0")
.cpp(false)
.warnings(false)
.flag_if_supported("-w");
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("target_os not defined!");
let target_family = env::var("CARGO_CFG_TARGET_FAMILY").expect("target_family not defined!");
if env::var_os("CARGO_FEATURE_OVERRIDE").is_some() {
// Overriding malloc is only available on windows in shared mode, but we
// only ever build a static lib.
if target_family != "windows" {
build.define("MI_MALLOC_OVERRIDE", "0");
}
}
#[cfg(feature = "secure")]
{
build.define("MI_SECURE", "4");
}
#[cfg(feature = "asm")]
{
build.flag_if_supported("-save-temps");
}
#[cfg(feature = "skip-collect-on-exit")]
{
build.define("MI_SKIP_COLLECT_ON_EXIT", "1");
}
if target_family == "unix" && target_os != "haiku" {
#[cfg(feature = "local-dynamic-tls")]
{
build.flag_if_supported("-ftls-model=local-dynamic");
}
#[cfg(not(feature = "local-dynamic-tls"))]
{
build.flag_if_supported("-ftls-model=initial-exec");
}
}
// Remove heavy debug assertions etc
let profile = std::env::var("PROFILE").unwrap();
match profile.as_str() {
"debug" => build.define("MI_DEBUG_FUL", "3"),
"release" => build.define("MI_DEBUG_FUL", "0").define("MI_DEBUG", "0"),
_ => build.define("MI_DEBUG_FUL", "3"),
};
if build.get_compiler().is_like_msvc() {
build.cpp(true);
}
build.compile("mimalloc");
}