Simplify bootstrap check-cfg arguments

This commit is contained in:
Urgau
2023-12-30 15:13:04 +01:00
parent d59f06fc64
commit df375765b9
+15 -10
View File
@@ -1468,17 +1468,22 @@ pub fn cargo(
for (restricted_mode, name, values) in EXTRA_CHECK_CFGS {
if *restricted_mode == None || *restricted_mode == Some(mode) {
// Creating a string of the values by concatenating each value:
// ',"tvos","watchos"' or '' (nothing) when there are no values
let values = match values {
Some(values) => values
.iter()
.map(|val| [",", "\"", val, "\""])
.flatten()
.collect::<String>(),
None => String::new(),
// ',values("tvos","watchos")' or '' (nothing) when there are no values.
let next = match values {
Some(values) => {
let mut tmp = values
.iter()
.map(|val| [",", "\"", val, "\""])
.flatten()
.collect::<String>();
tmp.insert_str(1, "values(");
tmp.push_str(")");
tmp
}
None => "".to_string(),
};
let values = values.strip_prefix(",").unwrap_or(&values); // remove the first `,`
rustflags.arg(&format!("--check-cfg=cfg({name},values({values}))"));
rustflags.arg(&format!("--check-cfg=cfg({name}{next})"));
}
}