Skip to content

Commit 5da749c

Browse files
authored
Handle multi-valued target_family (#362)
1 parent 7116abe commit 5da749c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

mbedtls-sys/build/features.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ impl Features {
3636
self.with_feature("c_compiler").unwrap().insert("freestanding");
3737
}
3838
if let Some(components) = self.with_feature("threading") {
39-
if !have_custom_threading && env_have_target_cfg("family", "unix") {
39+
if !have_custom_threading && env_have_target_family("unix") {
4040
components.insert("pthread");
4141
} else {
4242
components.insert("custom");
4343
}
4444
}
4545
if let Some(components) = self.with_feature("std") {
46-
if env_have_target_cfg("family", "unix") || env_have_target_cfg("family", "windows") {
46+
if env_have_target_family("unix") || env_have_target_family("windows") {
4747
components.insert("net");
4848
components.insert("fs");
4949
components.insert("entropy");
5050
}
5151
}
5252
if let Some(components) = self.with_feature("time") {
53-
if !have_custom_gmtime_r && (env_have_target_cfg("family", "unix") || env_have_target_cfg("family", "windows")) {
53+
if !have_custom_gmtime_r && (env_have_target_family("unix") || env_have_target_family("windows")) {
5454
components.insert("libc");
5555
} else {
5656
components.insert("custom");
@@ -100,6 +100,10 @@ fn env_have_target_cfg(var: &'static str, value: &'static str) -> bool {
100100
env::var_os(env).map_or(false, |s| s == value)
101101
}
102102

103+
fn env_have_target_family(value: &'static str) -> bool {
104+
env::var("CARGO_CFG_TARGET_FAMILY").map_or(false, |var| var.split(",").any(|s| s == value))
105+
}
106+
103107
fn env_have_feature(feature: &'static str) -> bool {
104108
let env = format!("CARGO_FEATURE_{}", feature).to_uppercase().replace("-", "_");
105109
env::var_os(env).is_some()

0 commit comments

Comments
 (0)