Skip to content

Commit b4ca670

Browse files
authored
Unrolled build for rust-lang#138606
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 7290b04 + 55239b5 commit b4ca670

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
@@ -1585,9 +1585,15 @@ impl Step for Extended {
15851585
prepare("cargo");
15861586
prepare("rust-std");
15871587
prepare("rust-analysis");
1588-
prepare("clippy");
1589-
prepare("rust-analyzer");
1590-
for tool in &["rust-docs", "miri", "rustc-codegen-cranelift"] {
1588+
1589+
for tool in &[
1590+
"clippy",
1591+
"rustfmt",
1592+
"rust-analyzer",
1593+
"rust-docs",
1594+
"miri",
1595+
"rustc-codegen-cranelift",
1596+
] {
15911597
if built_tools.contains(tool) {
15921598
prepare(tool);
15931599
}
@@ -1627,6 +1633,8 @@ impl Step for Extended {
16271633
"rust-analyzer-preview".to_string()
16281634
} else if name == "clippy" {
16291635
"clippy-preview".to_string()
1636+
} else if name == "rustfmt" {
1637+
"rustfmt-preview".to_string()
16301638
} else if name == "miri" {
16311639
"miri-preview".to_string()
16321640
} else if name == "rustc-codegen-cranelift" {
@@ -1646,7 +1654,7 @@ impl Step for Extended {
16461654
prepare("cargo");
16471655
prepare("rust-analysis");
16481656
prepare("rust-std");
1649-
for tool in &["clippy", "rust-analyzer", "rust-docs", "miri"] {
1657+
for tool in &["clippy", "rustfmt", "rust-analyzer", "rust-docs", "miri"] {
16501658
if built_tools.contains(tool) {
16511659
prepare(tool);
16521660
}
@@ -1764,6 +1772,24 @@ impl Step for Extended {
17641772
.arg(etc.join("msi/remove-duplicates.xsl"))
17651773
.run(builder);
17661774
}
1775+
if built_tools.contains("rustfmt") {
1776+
command(&heat)
1777+
.current_dir(&exe)
1778+
.arg("dir")
1779+
.arg("rustfmt")
1780+
.args(heat_flags)
1781+
.arg("-cg")
1782+
.arg("RustFmtGroup")
1783+
.arg("-dr")
1784+
.arg("RustFmt")
1785+
.arg("-var")
1786+
.arg("var.RustFmtDir")
1787+
.arg("-out")
1788+
.arg(exe.join("RustFmtGroup.wxs"))
1789+
.arg("-t")
1790+
.arg(etc.join("msi/remove-duplicates.xsl"))
1791+
.run(builder);
1792+
}
17671793
if built_tools.contains("miri") {
17681794
command(&heat)
17691795
.current_dir(&exe)
@@ -1830,11 +1856,14 @@ impl Step for Extended {
18301856
.arg("-out")
18311857
.arg(&output)
18321858
.arg(input);
1833-
add_env(builder, &mut cmd, target);
1859+
add_env(builder, &mut cmd, target, &built_tools);
18341860

18351861
if built_tools.contains("clippy") {
18361862
cmd.arg("-dClippyDir=clippy");
18371863
}
1864+
if built_tools.contains("rustfmt") {
1865+
cmd.arg("-dRustFmtDir=rustfmt");
1866+
}
18381867
if built_tools.contains("rust-docs") {
18391868
cmd.arg("-dDocsDir=rust-docs");
18401869
}
@@ -1861,6 +1890,9 @@ impl Step for Extended {
18611890
if built_tools.contains("clippy") {
18621891
candle("ClippyGroup.wxs".as_ref());
18631892
}
1893+
if built_tools.contains("rustfmt") {
1894+
candle("RustFmtGroup.wxs".as_ref());
1895+
}
18641896
if built_tools.contains("miri") {
18651897
candle("MiriGroup.wxs".as_ref());
18661898
}
@@ -1899,6 +1931,9 @@ impl Step for Extended {
18991931
if built_tools.contains("clippy") {
19001932
cmd.arg("ClippyGroup.wixobj");
19011933
}
1934+
if built_tools.contains("rustfmt") {
1935+
cmd.arg("RustFmtGroup.wixobj");
1936+
}
19021937
if built_tools.contains("miri") {
19031938
cmd.arg("MiriGroup.wixobj");
19041939
}
@@ -1925,7 +1960,12 @@ impl Step for Extended {
19251960
}
19261961
}
19271962

1928-
fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSelection) {
1963+
fn add_env(
1964+
builder: &Builder<'_>,
1965+
cmd: &mut BootstrapCommand,
1966+
target: TargetSelection,
1967+
built_tools: &HashSet<&'static str>,
1968+
) {
19291969
let mut parts = builder.version.split('.');
19301970
cmd.env("CFG_RELEASE_INFO", builder.rust_version())
19311971
.env("CFG_RELEASE_NUM", &builder.version)
@@ -1946,6 +1986,15 @@ fn add_env(builder: &Builder<'_>, cmd: &mut BootstrapCommand, target: TargetSele
19461986
} else {
19471987
cmd.env("CFG_MINGW", "0").env("CFG_ABI", "MSVC");
19481988
}
1989+
1990+
// ensure these variables are defined
1991+
let mut define_optional_tool = |tool_name: &str, env_name: &str| {
1992+
cmd.env(env_name, if built_tools.contains(tool_name) { "1" } else { "0" });
1993+
};
1994+
define_optional_tool("rustfmt", "CFG_RUSTFMT");
1995+
define_optional_tool("clippy", "CFG_CLIPPY");
1996+
define_optional_tool("miri", "CFG_MIRI");
1997+
define_optional_tool("rust-analyzer", "CFG_RA");
19491998
}
19501999

19512000
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)