Skip to content

Commit 9a2d1b8

Browse files
committed
restore check for both target os and env
This is better than the old impl of target.ends_with("windows-gnu"), because it also catches things like windows-gnullvm
1 parent 5b0a0d8 commit 9a2d1b8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/tools/compiletest/src/common.rs

+10
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ pub struct TargetCfgs {
409409
pub all_targets: HashSet<String>,
410410
pub all_archs: HashSet<String>,
411411
pub all_oses: HashSet<String>,
412+
pub all_oses_and_envs: HashSet<String>,
412413
pub all_envs: HashSet<String>,
413414
pub all_abis: HashSet<String>,
414415
pub all_families: HashSet<String>,
@@ -433,6 +434,7 @@ impl TargetCfgs {
433434
let mut all_targets = HashSet::new();
434435
let mut all_archs = HashSet::new();
435436
let mut all_oses = HashSet::new();
437+
let mut all_oses_and_envs = HashSet::new();
436438
let mut all_envs = HashSet::new();
437439
let mut all_abis = HashSet::new();
438440
let mut all_families = HashSet::new();
@@ -441,6 +443,7 @@ impl TargetCfgs {
441443
for (target, cfg) in targets.into_iter() {
442444
all_archs.insert(cfg.arch.clone());
443445
all_oses.insert(cfg.os.clone());
446+
all_oses_and_envs.insert(cfg.os_and_env());
444447
all_envs.insert(cfg.env.clone());
445448
all_abis.insert(cfg.abi.clone());
446449
for family in &cfg.families {
@@ -459,6 +462,7 @@ impl TargetCfgs {
459462
all_targets,
460463
all_archs,
461464
all_oses,
465+
all_oses_and_envs,
462466
all_envs,
463467
all_abis,
464468
all_families,
@@ -506,6 +510,12 @@ pub struct TargetCfg {
506510
panic: PanicStrategy,
507511
}
508512

513+
impl TargetCfg {
514+
pub(crate) fn os_and_env(&self) -> String {
515+
format!("{}-{}", self.os, self.env)
516+
}
517+
}
518+
509519
fn default_os() -> String {
510520
"none".into()
511521
}

src/tools/compiletest/src/header/cfg.rs

+5
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ pub(super) fn parse_cfg_name_directive<'a>(
8484
allowed_names: &target_cfgs.all_envs,
8585
message: "when the target environment is {name}"
8686
}
87+
condition! {
88+
name: &target_cfg.os_and_env(),
89+
allowed_names: &target_cfgs.all_oses_and_envs,
90+
message: "when the operative system and target environment are {name}"
91+
}
8792
condition! {
8893
name: &target_cfg.abi,
8994
allowed_names: &target_cfgs.all_abis,

0 commit comments

Comments
 (0)