Skip to content

Commit 566b2fd

Browse files
committed
Compare against CARGO_CFG_TARGET_FAMILY in a multi-valued fashion
1 parent ee959d7 commit 566b2fd

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

crates/musl-math-sys/build.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn main() {
4646
let cfg = Config::from_env();
4747

4848
if cfg.target_env == "msvc"
49-
|| cfg.target_family == "wasm"
49+
|| cfg.target_families.iter().any(|f| f == "wasm")
5050
|| cfg.target_features.iter().any(|f| f == "thumb-mode")
5151
{
5252
println!(
@@ -69,7 +69,7 @@ struct Config {
6969
musl_arch: String,
7070
target_arch: String,
7171
target_env: String,
72-
target_family: String,
72+
target_families: Vec<String>,
7373
target_os: String,
7474
target_string: String,
7575
target_vendor: String,
@@ -79,6 +79,9 @@ struct Config {
7979
impl Config {
8080
fn from_env() -> Self {
8181
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
82+
let target_families = env::var("CARGO_CFG_TARGET_FAMILY")
83+
.map(|feats| feats.split(',').map(ToOwned::to_owned).collect())
84+
.unwrap_or_default();
8285
let target_features = env::var("CARGO_CFG_TARGET_FEATURE")
8386
.map(|feats| feats.split(',').map(ToOwned::to_owned).collect())
8487
.unwrap_or_default();
@@ -104,7 +107,7 @@ impl Config {
104107
musl_arch,
105108
target_arch,
106109
target_env: env::var("CARGO_CFG_TARGET_ENV").unwrap(),
107-
target_family: env::var("CARGO_CFG_TARGET_FAMILY").unwrap(),
110+
target_families,
108111
target_os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
109112
target_string: env::var("TARGET").unwrap(),
110113
target_vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(),

libm/configure.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct Config {
1313
pub target_triple: String,
1414
pub target_arch: String,
1515
pub target_env: String,
16-
pub target_family: Option<String>,
16+
pub target_families: Vec<String>,
1717
pub target_os: String,
1818
pub target_string: String,
1919
pub target_vendor: String,
@@ -25,6 +25,9 @@ pub struct Config {
2525
impl Config {
2626
pub fn from_env() -> Self {
2727
let target_triple = env::var("TARGET").unwrap();
28+
let target_families = env::var("CARGO_CFG_TARGET_FAMILY")
29+
.map(|feats| feats.split(',').map(ToOwned::to_owned).collect())
30+
.unwrap_or_default();
2831
let target_features = env::var("CARGO_CFG_TARGET_FEATURE")
2932
.map(|feats| feats.split(',').map(ToOwned::to_owned).collect())
3033
.unwrap_or_default();
@@ -41,7 +44,7 @@ impl Config {
4144
cargo_features,
4245
target_arch: env::var("CARGO_CFG_TARGET_ARCH").unwrap(),
4346
target_env: env::var("CARGO_CFG_TARGET_ENV").unwrap(),
44-
target_family: env::var("CARGO_CFG_TARGET_FAMILY").ok(),
47+
target_families,
4548
target_os: env::var("CARGO_CFG_TARGET_OS").unwrap(),
4649
target_string: env::var("TARGET").unwrap(),
4750
target_vendor: env::var("CARGO_CFG_TARGET_VENDOR").unwrap(),

0 commit comments

Comments
 (0)