Create a TargetSelection method for recognizing *-windows-gnu targets

This commit is contained in:
Jakub Beránek 2024-08-11 21:03:32 +02:00
parent 591ecb88df
commit 0cfbfa9532
3 changed files with 13 additions and 9 deletions

View File

@ -432,7 +432,7 @@ fn copy_self_contained_objects(
DependencyType::TargetSelfContained,
);
}
} else if target.ends_with("windows-gnu") {
} else if target.is_windows_gnu() {
for obj in ["crt2.o", "dllcrt2.o"].iter() {
let src = compiler_file(builder, &builder.cc(target), target, CLang::C, obj);
let target = libdir_self_contained.join(obj);
@ -793,7 +793,7 @@ fn make_run(run: RunConfig<'_>) {
fn run(self, builder: &Builder<'_>) -> Vec<(PathBuf, DependencyType)> {
let for_compiler = self.compiler;
let target = self.target;
if !target.ends_with("windows-gnu") {
if !target.is_windows_gnu() {
return vec![];
}

View File

@ -1509,7 +1509,7 @@ macro_rules! add_component {
tarballs.push(builder.ensure(Rustc { compiler: builder.compiler(stage, target) }));
tarballs.push(builder.ensure(Std { compiler, target }).expect("missing std"));
if target.ends_with("windows-gnu") {
if target.is_windows_gnu() {
tarballs.push(builder.ensure(Mingw { host: target }).expect("missing mingw"));
}
@ -1683,7 +1683,7 @@ fn filter(contents: &str, marker: &str) -> String {
prepare(tool);
}
}
if target.ends_with("windows-gnu") {
if target.is_windows_gnu() {
prepare("rust-mingw");
}
@ -1830,7 +1830,7 @@ fn filter(contents: &str, marker: &str) -> String {
.arg("-t")
.arg(etc.join("msi/remove-duplicates.xsl"))
.run(builder);
if target.ends_with("windows-gnu") {
if target.is_windows_gnu() {
command(&heat)
.current_dir(&exe)
.arg("dir")
@ -1876,7 +1876,7 @@ fn filter(contents: &str, marker: &str) -> String {
if built_tools.contains("miri") {
cmd.arg("-dMiriDir=miri");
}
if target.ends_with("windows-gnu") {
if target.is_windows_gnu() {
cmd.arg("-dGccDir=rust-mingw");
}
cmd.run(builder);
@ -1901,7 +1901,7 @@ fn filter(contents: &str, marker: &str) -> String {
}
candle("AnalysisGroup.wxs".as_ref());
if target.ends_with("windows-gnu") {
if target.is_windows_gnu() {
candle("GccGroup.wxs".as_ref());
}
@ -1941,7 +1941,7 @@ fn filter(contents: &str, marker: &str) -> String {
cmd.arg("DocsGroup.wixobj");
}
if target.ends_with("windows-gnu") {
if target.is_windows_gnu() {
cmd.arg("GccGroup.wixobj");
}
// ICE57 wrongly complains about the shortcuts
@ -1973,7 +1973,7 @@ fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSele
if target.contains("windows-gnullvm") {
cmd.env("CFG_MINGW", "1").env("CFG_ABI", "LLVM");
} else if target.contains("windows-gnu") {
} else if target.is_windows_gnu() {
cmd.env("CFG_MINGW", "1").env("CFG_ABI", "GNU");
} else {
cmd.env("CFG_MINGW", "0").env("CFG_ABI", "MSVC");

View File

@ -514,6 +514,10 @@ pub fn is_windows(&self) -> bool {
self.contains("windows")
}
pub fn is_windows_gnu(&self) -> bool {
self.ends_with("windows-gnu")
}
/// Path to the file defining the custom target, if any.
pub fn filepath(&self) -> Option<&Path> {
self.file.as_ref().map(Path::new)