Skip to content
/ rust Public
forked from rust-lang/rust

Commit 0fc6279

Browse files
authored
Rollup merge of rust-lang#138606 - heiseish:131365-extended, r=Mark-Simulacrum
Fix missing rustfmt in msi installer - cont ## Context - This PR extended and fixed rust-lang#131365, which was reverted in rust-lang#135253 - Initial effort from `@klensy` in rust-lang#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`
2 parents abc6784 + 55239b5 commit 0fc6279

File tree

2 files changed

+111
-7
lines changed

2 files changed

+111
-7
lines changed

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

+55-6
Original file line numberDiff line numberDiff line change
@@ -1632,9 +1632,15 @@ impl Step for Extended {
16321632
prepare("cargo");
16331633
prepare("rust-std");
16341634
prepare("rust-analysis");
1635-
prepare("clippy");
1636-
prepare("rust-analyzer");
1637-
for tool in &["rust-docs", "miri", "rustc-codegen-cranelift"] {
1635+
1636+
for tool in &[
1637+
"clippy",
1638+
"rustfmt",
1639+
"rust-analyzer",
1640+
"rust-docs",
1641+
"miri",
1642+
"rustc-codegen-cranelift",
1643+
] {
16381644
if built_tools.contains(tool) {
16391645
prepare(tool);
16401646
}
@@ -1674,6 +1680,8 @@ impl Step for Extended {
16741680
"rust-analyzer-preview".to_string()
16751681
} else if name == "clippy" {
16761682
"clippy-preview".to_string()
1683+
} else if name == "rustfmt" {
1684+
"rustfmt-preview".to_string()
16771685
} else if name == "miri" {
16781686
"miri-preview".to_string()
16791687
} else if name == "rustc-codegen-cranelift" {
@@ -1693,7 +1701,7 @@ impl Step for Extended {
16931701
prepare("cargo");
16941702
prepare("rust-analysis");
16951703
prepare("rust-std");
1696-
for tool in &["clippy", "rust-analyzer", "rust-docs", "miri"] {
1704+
for tool in &["clippy", "rustfmt", "rust-analyzer", "rust-docs", "miri"] {
16971705
if built_tools.contains(tool) {
16981706
prepare(tool);
16991707
}
@@ -1811,6 +1819,24 @@ impl Step for Extended {
18111819
.arg(etc.join("msi/remove-duplicates.xsl"))
18121820
.run(builder);
18131821
}
1822+
if built_tools.contains("rustfmt") {
1823+
command(&heat)
1824+
.current_dir(&exe)
1825+
.arg("dir")
1826+
.arg("rustfmt")
1827+
.args(heat_flags)
1828+
.arg("-cg")
1829+
.arg("RustFmtGroup")
1830+
.arg("-dr")
1831+
.arg("RustFmt")
1832+
.arg("-var")
1833+
.arg("var.RustFmtDir")
1834+
.arg("-out")
1835+
.arg(exe.join("RustFmtGroup.wxs"))
1836+
.arg("-t")
1837+
.arg(etc.join("msi/remove-duplicates.xsl"))
1838+
.run(builder);
1839+
}
18141840
if built_tools.contains("miri") {
18151841
command(&heat)
18161842
.current_dir(&exe)
@@ -1877,11 +1903,14 @@ impl Step for Extended {
18771903
.arg("-out")
18781904
.arg(&output)
18791905
.arg(input);
1880-
add_env(builder, &mut cmd, target);
1906+
add_env(builder, &mut cmd, target, &built_tools);
18811907

18821908
if built_tools.contains("clippy") {
18831909
cmd.arg("-dClippyDir=clippy");
18841910
}
1911+
if built_tools.contains("rustfmt") {
1912+
cmd.arg("-dRustFmtDir=rustfmt");
1913+
}
18851914
if built_tools.contains("rust-docs") {
18861915
cmd.arg("-dDocsDir=rust-docs");
18871916
}
@@ -1908,6 +1937,9 @@ impl Step for Extended {
19081937
if built_tools.contains("clippy") {
19091938
candle("ClippyGroup.wxs".as_ref());
19101939
}
1940+
if built_tools.contains("rustfmt") {
1941+
candle("RustFmtGroup.wxs".as_ref());
1942+
}
19111943
if built_tools.contains("miri") {
19121944
candle("MiriGroup.wxs".as_ref());
19131945
}
@@ -1946,6 +1978,9 @@ impl Step for Extended {
19461978
if built_tools.contains("clippy") {
19471979
cmd.arg("ClippyGroup.wixobj");
19481980
}
1981+
if built_tools.contains("rustfmt") {
1982+
cmd.arg("RustFmtGroup.wixobj");
1983+
}
19491984
if built_tools.contains("miri") {
19501985
cmd.arg("MiriGroup.wixobj");
19511986
}
@@ -1972,7 +2007,12 @@ impl Step for Extended {
19722007
}
19732008
}
19742009

1975-
fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSelection) {
2010+
fn add_env(
2011+
builder: &Builder<'_>,
2012+
cmd: &mut BootstrapCommand,
2013+
target: TargetSelection,
2014+
built_tools: &HashSet<&'static str>,
2015+
) {
19762016
let mut parts = builder.version.split('.');
19772017
cmd.env("CFG_RELEASE_INFO", builder.rust_version())
19782018
.env("CFG_RELEASE_NUM", &builder.version)
@@ -1993,6 +2033,15 @@ fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSele
19932033
} else {
19942034
cmd.env("CFG_MINGW", "0").env("CFG_ABI", "MSVC");
19952035
}
2036+
2037+
// ensure these variables are defined
2038+
let mut define_optional_tool = |tool_name: &str, env_name: &str| {
2039+
cmd.env(env_name, if built_tools.contains(tool_name) { "1" } else { "0" });
2040+
};
2041+
define_optional_tool("rustfmt", "CFG_RUSTFMT");
2042+
define_optional_tool("clippy", "CFG_CLIPPY");
2043+
define_optional_tool("miri", "CFG_MIRI");
2044+
define_optional_tool("rust-analyzer", "CFG_RA");
19962045
}
19972046

19982047
fn install_llvm_file(

src/etc/installer/msi/rust.wxs

+56-1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@
172172
<!-- tool-rust-docs-end -->
173173
<Directory Id="Cargo" Name="." />
174174
<Directory Id="Std" Name="." />
175+
<?if $(env.CFG_RUSTFMT)="1" ?>
176+
<Directory Id="RustFmt" Name="." />
177+
<?endif?>
178+
<?if $(env.CFG_RA)="1" ?>
179+
<Directory Id="RustAnalyzer" Name="." />
180+
<?endif?>
181+
<?if $(env.CFG_MIRI)="1" ?>
182+
<Directory Id="Miri" Name="." />
183+
<?endif?>
184+
<Directory Id="Analysis" Name="." />
185+
<?if $(env.CFG_CLIPPY)="1" ?>
186+
<Directory Id="Clippy" Name="." />
187+
<?endif?>
175188
</Directory>
176189
</Directory>
177190

@@ -279,7 +292,49 @@
279292
<ComponentRef Id="PathEnvPerMachine" />
280293
<ComponentRef Id="PathEnvPerUser" />
281294
</Feature>
282-
295+
<?if $(env.CFG_RUSTFMT)="1" ?>
296+
<Feature Id="RustFmt"
297+
Title="Formatter for rust"
298+
Display="7"
299+
Level="1"
300+
AllowAdvertise="no">
301+
<ComponentGroupRef Id="RustFmtGroup" />
302+
</Feature>
303+
<?endif?>
304+
<?if $(env.CFG_CLIPPY)="1" ?>
305+
<Feature Id="Clippy"
306+
Title="Formatter and checker for rust"
307+
Display="8"
308+
Level="1"
309+
AllowAdvertise="no">
310+
<ComponentGroupRef Id="ClippyGroup" />
311+
</Feature>
312+
<?endif?>
313+
<?if $(env.CFG_MIRI)="1" ?>
314+
<Feature Id="Miri"
315+
Title="Soundness checker for rust"
316+
Display="9"
317+
Level="1"
318+
AllowAdvertise="no">
319+
<ComponentGroupRef Id="MiriGroup" />
320+
</Feature>
321+
<?endif?>
322+
<?if $(env.CFG_RA)="1" ?>
323+
<Feature Id="RustAnalyzer"
324+
Title="Analyzer for rust"
325+
Display="10"
326+
Level="1"
327+
AllowAdvertise="no">
328+
<ComponentGroupRef Id="RustAnalyzerGroup" />
329+
</Feature>
330+
<?endif?>
331+
<Feature Id="Analysis"
332+
Title="Analysis for rust"
333+
Display="11"
334+
Level="1"
335+
AllowAdvertise="no">
336+
<ComponentGroupRef Id="AnalysisGroup" />
337+
</Feature>
283338
<UIRef Id="RustUI" />
284339
</Product>
285340
</Wix>

0 commit comments

Comments
 (0)