Skip to content

Commit 2f8256c

Browse files
committed
Apply build script suggestions from #58 (comment)
1 parent dcadf23 commit 2f8256c

File tree

1 file changed

+8
-29
lines changed

1 file changed

+8
-29
lines changed

libmimalloc-sys/build.rs

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,27 @@ fn main() {
44
let mut build = cc::Build::new();
55

66
build.include("c_src/mimalloc/include");
7-
build.files(
8-
[
9-
"alloc-aligned",
10-
"alloc-posix",
11-
"alloc",
12-
"arena",
13-
"bitmap",
14-
"heap",
15-
"init",
16-
"options",
17-
"os",
18-
"page",
19-
"random",
20-
"region",
21-
"segment",
22-
"stats",
23-
]
24-
.iter()
25-
.map(|fname| format!("c_src/mimalloc/src/{}.c", fname)),
26-
);
27-
28-
build.define("MI_STATIC_LIB", None);
7+
build.include("c_src/mimalloc/src");
8+
build.file("c_src/mimalloc/src/static.c");
299

3010
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("target_os not defined!");
11+
let target_family = env::var("CARGO_CFG_TARGET_FAMILY").expect("target_family not defined!");
3112

32-
if cfg!(feature = "override") {
13+
if env::var_os("CARGO_FEATURE_OVERRIDE").is_some() {
3314
// Overriding malloc is only available on windows in shared mode, but we
3415
// only ever build a static lib.
35-
if target_os != "windows" {
16+
if target_family != "windows" {
3617
build.define("MI_MALLOC_OVERRIDE", None);
3718
}
3819
}
3920

40-
if cfg!(feature = "secure") {
21+
if env::var_os("CARGO_FEATURE_SECURE").is_some() {
4122
build.define("MI_SECURE", "4");
4223
}
4324

44-
let dynamic_tls = cfg!(feature = "local_dynamic_tls");
25+
let dynamic_tls = env::var("CARGO_FEATURE_LOCAL_DYNAMIC_TLS").is_ok();
4526

46-
if env::var("CARGO_CFG_TARGET_FAMILY").expect("target family not set") == "unix"
47-
&& target_os != "haiku"
48-
{
27+
if target_family == "unix" && target_os != "haiku" {
4928
if dynamic_tls {
5029
build.flag_if_supported("-ftls-model=local-dynamic");
5130
} else {

0 commit comments

Comments
 (0)