Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slightly refactor TargetSelection in bootstrap #128983

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Create a TargetSelection method for recognizing *-windows-gnu tar…
…gets
Kobzol committed Aug 13, 2024
commit 0cfbfa9532275a9b26ab21e706cbdc71f74c3450
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
@@ -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 @@ impl Step for StartupObjects {
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![];
}

14 changes: 7 additions & 7 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
@@ -1509,7 +1509,7 @@ impl Step for Extended {
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 @@ impl Step for Extended {
prepare(tool);
}
}
if target.ends_with("windows-gnu") {
if target.is_windows_gnu() {
prepare("rust-mingw");
}

@@ -1830,7 +1830,7 @@ impl Step for Extended {
.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 @@ impl Step for Extended {
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 @@ impl Step for Extended {
}
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 @@ impl Step for Extended {
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");
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
@@ -514,6 +514,10 @@ impl TargetSelection {
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)