Skip to content

Commit 1462f3d

Browse files
committed
Add {{target}} substitution to compiletest
1 parent 06194ca commit 1462f3d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/tools/compiletest/src/header.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,7 @@ fn expand_variables(mut value: String, config: &Config) -> String {
12811281
const BUILD_BASE: &str = "{{build-base}}";
12821282
const SYSROOT_BASE: &str = "{{sysroot-base}}";
12831283
const TARGET_LINKER: &str = "{{target-linker}}";
1284+
const TARGET: &str = "{{target}}";
12841285

12851286
if value.contains(CWD) {
12861287
let cwd = env::current_dir().unwrap();
@@ -1303,6 +1304,10 @@ fn expand_variables(mut value: String, config: &Config) -> String {
13031304
value = value.replace(TARGET_LINKER, config.target_linker.as_deref().unwrap_or(""));
13041305
}
13051306

1307+
if value.contains(TARGET) {
1308+
value = value.replace(TARGET, &config.target);
1309+
}
1310+
13061311
value
13071312
}
13081313

src/tools/tidy/src/target_specific_tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ pub fn check(path: &Path, bad: &mut bool) {
5353
} else if directive.starts_with(COMPILE_FLAGS_HEADER) {
5454
let compile_flags = &directive[COMPILE_FLAGS_HEADER.len()..];
5555
if let Some((_, v)) = compile_flags.split_once("--target") {
56-
if let Some((arch, _)) =
57-
v.trim_start_matches(|c| c == ' ' || c == '=').split_once("-")
58-
{
56+
let v = v.trim_start_matches(|c| c == ' ' || c == '=');
57+
let v = if v == "{{target}}" { Some((v, v)) } else { v.split_once("-") };
58+
if let Some((arch, _)) = v {
5959
let info = header_map.entry(revision).or_insert(RevisionInfo::default());
6060
info.target_arch.replace(arch);
6161
} else {

0 commit comments

Comments
 (0)