Rollup merge of #138606 - heiseish:131365-extended, r=Mark-Simulacrum

Fix missing rustfmt in msi installer - cont

## Context
- This PR extended and fixed https://github.com/rust-lang/rust/pull/131365, which was reverted in https://github.com/rust-lang/rust/pull/135253
- Initial effort from `@klensy` in https://github.com/rust-lang/rust/pull/135255 (at any points if you feel like picking this up again, let me know I'll close my PR! Just trying to push this through since it's my mistake in the original commits)
- Tested with both `beta` and `nightly` `rust.channel`

r? `@Mark-Simulacrum`
This commit is contained in:
Jacob Pratt
2025-03-23 20:44:11 -04:00
committed by GitHub
2 changed files with 111 additions and 7 deletions
+55 -6
View File
@@ -1632,9 +1632,15 @@ fn filter(contents: &str, marker: &str) -> String {
prepare("cargo");
prepare("rust-std");
prepare("rust-analysis");
prepare("clippy");
prepare("rust-analyzer");
for tool in &["rust-docs", "miri", "rustc-codegen-cranelift"] {
for tool in &[
"clippy",
"rustfmt",
"rust-analyzer",
"rust-docs",
"miri",
"rustc-codegen-cranelift",
] {
if built_tools.contains(tool) {
prepare(tool);
}
@@ -1674,6 +1680,8 @@ fn filter(contents: &str, marker: &str) -> String {
"rust-analyzer-preview".to_string()
} else if name == "clippy" {
"clippy-preview".to_string()
} else if name == "rustfmt" {
"rustfmt-preview".to_string()
} else if name == "miri" {
"miri-preview".to_string()
} else if name == "rustc-codegen-cranelift" {
@@ -1693,7 +1701,7 @@ fn filter(contents: &str, marker: &str) -> String {
prepare("cargo");
prepare("rust-analysis");
prepare("rust-std");
for tool in &["clippy", "rust-analyzer", "rust-docs", "miri"] {
for tool in &["clippy", "rustfmt", "rust-analyzer", "rust-docs", "miri"] {
if built_tools.contains(tool) {
prepare(tool);
}
@@ -1811,6 +1819,24 @@ fn filter(contents: &str, marker: &str) -> String {
.arg(etc.join("msi/remove-duplicates.xsl"))
.run(builder);
}
if built_tools.contains("rustfmt") {
command(&heat)
.current_dir(&exe)
.arg("dir")
.arg("rustfmt")
.args(heat_flags)
.arg("-cg")
.arg("RustFmtGroup")
.arg("-dr")
.arg("RustFmt")
.arg("-var")
.arg("var.RustFmtDir")
.arg("-out")
.arg(exe.join("RustFmtGroup.wxs"))
.arg("-t")
.arg(etc.join("msi/remove-duplicates.xsl"))
.run(builder);
}
if built_tools.contains("miri") {
command(&heat)
.current_dir(&exe)
@@ -1877,11 +1903,14 @@ fn filter(contents: &str, marker: &str) -> String {
.arg("-out")
.arg(&output)
.arg(input);
add_env(builder, &mut cmd, target);
add_env(builder, &mut cmd, target, &built_tools);
if built_tools.contains("clippy") {
cmd.arg("-dClippyDir=clippy");
}
if built_tools.contains("rustfmt") {
cmd.arg("-dRustFmtDir=rustfmt");
}
if built_tools.contains("rust-docs") {
cmd.arg("-dDocsDir=rust-docs");
}
@@ -1908,6 +1937,9 @@ fn filter(contents: &str, marker: &str) -> String {
if built_tools.contains("clippy") {
candle("ClippyGroup.wxs".as_ref());
}
if built_tools.contains("rustfmt") {
candle("RustFmtGroup.wxs".as_ref());
}
if built_tools.contains("miri") {
candle("MiriGroup.wxs".as_ref());
}
@@ -1946,6 +1978,9 @@ fn filter(contents: &str, marker: &str) -> String {
if built_tools.contains("clippy") {
cmd.arg("ClippyGroup.wixobj");
}
if built_tools.contains("rustfmt") {
cmd.arg("RustFmtGroup.wixobj");
}
if built_tools.contains("miri") {
cmd.arg("MiriGroup.wixobj");
}
@@ -1972,7 +2007,12 @@ fn filter(contents: &str, marker: &str) -> String {
}
}
fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSelection) {
fn add_env(
builder: &Builder<'_>,
cmd: &mut BootstrapCommand,
target: TargetSelection,
built_tools: &HashSet<&'static str>,
) {
let mut parts = builder.version.split('.');
cmd.env("CFG_RELEASE_INFO", builder.rust_version())
.env("CFG_RELEASE_NUM", &builder.version)
@@ -1993,6 +2033,15 @@ fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSele
} else {
cmd.env("CFG_MINGW", "0").env("CFG_ABI", "MSVC");
}
// ensure these variables are defined
let mut define_optional_tool = |tool_name: &str, env_name: &str| {
cmd.env(env_name, if built_tools.contains(tool_name) { "1" } else { "0" });
};
define_optional_tool("rustfmt", "CFG_RUSTFMT");
define_optional_tool("clippy", "CFG_CLIPPY");
define_optional_tool("miri", "CFG_MIRI");
define_optional_tool("rust-analyzer", "CFG_RA");
}
fn install_llvm_file(
+56 -1
View File
@@ -172,6 +172,19 @@
<!-- tool-rust-docs-end -->
<Directory Id="Cargo" Name="." />
<Directory Id="Std" Name="." />
<?if $(env.CFG_RUSTFMT)="1" ?>
<Directory Id="RustFmt" Name="." />
<?endif?>
<?if $(env.CFG_RA)="1" ?>
<Directory Id="RustAnalyzer" Name="." />
<?endif?>
<?if $(env.CFG_MIRI)="1" ?>
<Directory Id="Miri" Name="." />
<?endif?>
<Directory Id="Analysis" Name="." />
<?if $(env.CFG_CLIPPY)="1" ?>
<Directory Id="Clippy" Name="." />
<?endif?>
</Directory>
</Directory>
@@ -279,7 +292,49 @@
<ComponentRef Id="PathEnvPerMachine" />
<ComponentRef Id="PathEnvPerUser" />
</Feature>
<?if $(env.CFG_RUSTFMT)="1" ?>
<Feature Id="RustFmt"
Title="Formatter for rust"
Display="7"
Level="1"
AllowAdvertise="no">
<ComponentGroupRef Id="RustFmtGroup" />
</Feature>
<?endif?>
<?if $(env.CFG_CLIPPY)="1" ?>
<Feature Id="Clippy"
Title="Formatter and checker for rust"
Display="8"
Level="1"
AllowAdvertise="no">
<ComponentGroupRef Id="ClippyGroup" />
</Feature>
<?endif?>
<?if $(env.CFG_MIRI)="1" ?>
<Feature Id="Miri"
Title="Soundness checker for rust"
Display="9"
Level="1"
AllowAdvertise="no">
<ComponentGroupRef Id="MiriGroup" />
</Feature>
<?endif?>
<?if $(env.CFG_RA)="1" ?>
<Feature Id="RustAnalyzer"
Title="Analyzer for rust"
Display="10"
Level="1"
AllowAdvertise="no">
<ComponentGroupRef Id="RustAnalyzerGroup" />
</Feature>
<?endif?>
<Feature Id="Analysis"
Title="Analysis for rust"
Display="11"
Level="1"
AllowAdvertise="no">
<ComponentGroupRef Id="AnalysisGroup" />
</Feature>
<UIRef Id="RustUI" />
</Product>
</Wix>