Skip to content

Commit 0cfbfa9

Browse files
committed
Create a TargetSelection method for recognizing *-windows-gnu targets
1 parent 591ecb8 commit 0cfbfa9

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ fn copy_self_contained_objects(
432432
DependencyType::TargetSelfContained,
433433
);
434434
}
435-
} else if target.ends_with("windows-gnu") {
435+
} else if target.is_windows_gnu() {
436436
for obj in ["crt2.o", "dllcrt2.o"].iter() {
437437
let src = compiler_file(builder, &builder.cc(target), target, CLang::C, obj);
438438
let target = libdir_self_contained.join(obj);
@@ -793,7 +793,7 @@ impl Step for StartupObjects {
793793
fn run(self, builder: &Builder<'_>) -> Vec<(PathBuf, DependencyType)> {
794794
let for_compiler = self.compiler;
795795
let target = self.target;
796-
if !target.ends_with("windows-gnu") {
796+
if !target.is_windows_gnu() {
797797
return vec![];
798798
}
799799

src/bootstrap/src/core/build_steps/dist.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ impl Step for Extended {
15091509
tarballs.push(builder.ensure(Rustc { compiler: builder.compiler(stage, target) }));
15101510
tarballs.push(builder.ensure(Std { compiler, target }).expect("missing std"));
15111511

1512-
if target.ends_with("windows-gnu") {
1512+
if target.is_windows_gnu() {
15131513
tarballs.push(builder.ensure(Mingw { host: target }).expect("missing mingw"));
15141514
}
15151515

@@ -1683,7 +1683,7 @@ impl Step for Extended {
16831683
prepare(tool);
16841684
}
16851685
}
1686-
if target.ends_with("windows-gnu") {
1686+
if target.is_windows_gnu() {
16871687
prepare("rust-mingw");
16881688
}
16891689

@@ -1830,7 +1830,7 @@ impl Step for Extended {
18301830
.arg("-t")
18311831
.arg(etc.join("msi/remove-duplicates.xsl"))
18321832
.run(builder);
1833-
if target.ends_with("windows-gnu") {
1833+
if target.is_windows_gnu() {
18341834
command(&heat)
18351835
.current_dir(&exe)
18361836
.arg("dir")
@@ -1876,7 +1876,7 @@ impl Step for Extended {
18761876
if built_tools.contains("miri") {
18771877
cmd.arg("-dMiriDir=miri");
18781878
}
1879-
if target.ends_with("windows-gnu") {
1879+
if target.is_windows_gnu() {
18801880
cmd.arg("-dGccDir=rust-mingw");
18811881
}
18821882
cmd.run(builder);
@@ -1901,7 +1901,7 @@ impl Step for Extended {
19011901
}
19021902
candle("AnalysisGroup.wxs".as_ref());
19031903

1904-
if target.ends_with("windows-gnu") {
1904+
if target.is_windows_gnu() {
19051905
candle("GccGroup.wxs".as_ref());
19061906
}
19071907

@@ -1941,7 +1941,7 @@ impl Step for Extended {
19411941
cmd.arg("DocsGroup.wixobj");
19421942
}
19431943

1944-
if target.ends_with("windows-gnu") {
1944+
if target.is_windows_gnu() {
19451945
cmd.arg("GccGroup.wixobj");
19461946
}
19471947
// ICE57 wrongly complains about the shortcuts
@@ -1973,7 +1973,7 @@ fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSele
19731973

19741974
if target.contains("windows-gnullvm") {
19751975
cmd.env("CFG_MINGW", "1").env("CFG_ABI", "LLVM");
1976-
} else if target.contains("windows-gnu") {
1976+
} else if target.is_windows_gnu() {
19771977
cmd.env("CFG_MINGW", "1").env("CFG_ABI", "GNU");
19781978
} else {
19791979
cmd.env("CFG_MINGW", "0").env("CFG_ABI", "MSVC");

src/bootstrap/src/core/config/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,10 @@ impl TargetSelection {
514514
self.contains("windows")
515515
}
516516

517+
pub fn is_windows_gnu(&self) -> bool {
518+
self.ends_with("windows-gnu")
519+
}
520+
517521
/// Path to the file defining the custom target, if any.
518522
pub fn filepath(&self) -> Option<&Path> {
519523
self.file.as_ref().map(Path::new)

0 commit comments

Comments
 (0)