Skip to content

Commit

Permalink
Handle multi-valued target_family
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Aug 29, 2024
1 parent 014d836 commit d3af89b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mbedtls-sys/build/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ impl Features {
self.with_feature("c_compiler").unwrap().insert("freestanding");
}
if let Some(components) = self.with_feature("threading") {
if !have_custom_threading && env_have_target_cfg("family", "unix") {
if !have_custom_threading && env_have_target_family("unix") {
components.insert("pthread");
} else {
components.insert("custom");
}
}
if let Some(components) = self.with_feature("std") {
if env_have_target_cfg("family", "unix") || env_have_target_cfg("family", "windows") {
if env_have_target_family("unix") || env_have_target_family("windows") {
components.insert("net");
components.insert("fs");
components.insert("entropy");
}
}
if let Some(components) = self.with_feature("time") {
if !have_custom_gmtime_r && (env_have_target_cfg("family", "unix") || env_have_target_cfg("family", "windows")) {
if !have_custom_gmtime_r && (env_have_target_family("unix") || env_have_target_family("windows")) {
components.insert("libc");
} else {
components.insert("custom");
Expand Down Expand Up @@ -100,6 +100,10 @@ fn env_have_target_cfg(var: &'static str, value: &'static str) -> bool {
env::var_os(env).map_or(false, |s| s == value)
}

fn env_have_target_family(value: &'static str) -> bool {
env::var("CARGO_CFG_TARGET_FAMILY").map_or(false, |var| var.split(",").any(|s| s == value))
}

fn env_have_feature(feature: &'static str) -> bool {
let env = format!("CARGO_FEATURE_{}", feature).to_uppercase().replace("-", "_");
env::var_os(env).is_some()
Expand Down

0 comments on commit d3af89b

Please sign in to comment.