Skip to content

Commit

Permalink
Auto merge of #109880 - ehuss:fix-macos-installer-rust-docs, r=Mark-S…
Browse files Browse the repository at this point in the history
…imulacrum

Fix macOS and Windows installers when rust-docs is not available.

This fixes the macOS `.pkg` and Windows `.msi` installers to work when rust-docs is not available. If the rust-docs component is not built, then the installer would fail. This adds the rust-docs component to the filtering mechanism so that the rust-docs line of the distribution definition aren't included.

I tested installing and uninstalling both with and without the rust-docs component available.

This happens on the aarch64-apple-darwin distribution provided by rust-lang since we currently disable the rust-docs component due to long build times. An alternate solution would be to just enable the rust-docs component on aarch64-apple-darwin since there are faster build systems.

Fixes #109877
  • Loading branch information
bors committed Apr 10, 2023
2 parents 3c2e2dd + 6b57a34 commit 749b487
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 23 deletions.
53 changes: 30 additions & 23 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ impl Step for Extended {

let xform = |p: &Path| {
let mut contents = t!(fs::read_to_string(p));
for tool in &["rust-demangler", "miri"] {
for tool in &["rust-demangler", "miri", "rust-docs"] {
if !built_tools.contains(tool) {
contents = filter(&contents, tool);
}
Expand Down Expand Up @@ -1585,11 +1585,10 @@ impl Step for Extended {
prepare("rustc");
prepare("cargo");
prepare("rust-analysis");
prepare("rust-docs");
prepare("rust-std");
prepare("clippy");
prepare("rust-analyzer");
for tool in &["rust-demangler", "miri"] {
for tool in &["rust-docs", "rust-demangler", "miri"] {
if built_tools.contains(tool) {
prepare(tool);
}
Expand Down Expand Up @@ -1624,23 +1623,25 @@ impl Step for Extended {
.arg("-out")
.arg(exe.join("RustcGroup.wxs")),
);
builder.run(
Command::new(&heat)
.current_dir(&exe)
.arg("dir")
.arg("rust-docs")
.args(&heat_flags)
.arg("-cg")
.arg("DocsGroup")
.arg("-dr")
.arg("Docs")
.arg("-var")
.arg("var.DocsDir")
.arg("-out")
.arg(exe.join("DocsGroup.wxs"))
.arg("-t")
.arg(etc.join("msi/squash-components.xsl")),
);
if built_tools.contains("rust-docs") {
builder.run(
Command::new(&heat)
.current_dir(&exe)
.arg("dir")
.arg("rust-docs")
.args(&heat_flags)
.arg("-cg")
.arg("DocsGroup")
.arg("-dr")
.arg("Docs")
.arg("-var")
.arg("var.DocsDir")
.arg("-out")
.arg(exe.join("DocsGroup.wxs"))
.arg("-t")
.arg(etc.join("msi/squash-components.xsl")),
);
}
builder.run(
Command::new(&heat)
.current_dir(&exe)
Expand Down Expand Up @@ -1787,7 +1788,6 @@ impl Step for Extended {
cmd.current_dir(&exe)
.arg("-nologo")
.arg("-dRustcDir=rustc")
.arg("-dDocsDir=rust-docs")
.arg("-dCargoDir=cargo")
.arg("-dStdDir=rust-std")
.arg("-dAnalysisDir=rust-analysis")
Expand All @@ -1799,6 +1799,9 @@ impl Step for Extended {
.arg(&input);
add_env(builder, &mut cmd, target);

if built_tools.contains("rust-docs") {
cmd.arg("-dDocsDir=rust-docs");
}
if built_tools.contains("rust-demangler") {
cmd.arg("-dRustDemanglerDir=rust-demangler");
}
Expand All @@ -1817,7 +1820,9 @@ impl Step for Extended {
candle(&etc.join("msi/ui.wxs"));
candle(&etc.join("msi/rustwelcomedlg.wxs"));
candle("RustcGroup.wxs".as_ref());
candle("DocsGroup.wxs".as_ref());
if built_tools.contains("rust-docs") {
candle("DocsGroup.wxs".as_ref());
}
candle("CargoGroup.wxs".as_ref());
candle("StdGroup.wxs".as_ref());
candle("ClippyGroup.wxs".as_ref());
Expand Down Expand Up @@ -1854,7 +1859,6 @@ impl Step for Extended {
.arg("ui.wixobj")
.arg("rustwelcomedlg.wixobj")
.arg("RustcGroup.wixobj")
.arg("DocsGroup.wixobj")
.arg("CargoGroup.wixobj")
.arg("StdGroup.wixobj")
.arg("AnalysisGroup.wixobj")
Expand All @@ -1870,6 +1874,9 @@ impl Step for Extended {
if built_tools.contains("rust-demangler") {
cmd.arg("RustDemanglerGroup.wixobj");
}
if built_tools.contains("rust-docs") {
cmd.arg("DocsGroup.wixobj");
}

if target.ends_with("windows-gnu") {
cmd.arg("GccGroup.wixobj");
Expand Down
6 changes: 6 additions & 0 deletions src/etc/installer/msi/rust.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@
<?if $(env.CFG_MINGW)="1" ?>
<Directory Id="Gcc" Name="." />
<?endif?>
<!-- tool-rust-docs-start -->
<Directory Id="Docs" Name="." />
<!-- tool-rust-docs-end -->
<Directory Id="Cargo" Name="." />
<Directory Id="Std" Name="." />
</Directory>
Expand Down Expand Up @@ -209,6 +211,7 @@
<RegistryValue Root="HKMU" Key="$(var.BaseRegKey)" Name="RustShell" Type="integer" Value="1" KeyPath="yes" />
<RemoveFolder Id="ApplicationProgramsFolder1" On="uninstall" />
</Component>
<!-- tool-rust-docs-start -->
<Component Id="DocIndexShortcut" Guid="*">
<Shortcut Id="RustDocs"
Name="$(var.ProductName) Documentation"
Expand All @@ -217,6 +220,7 @@
<RegistryValue Root="HKMU" Key="$(var.BaseRegKey)" Name="RustDocs" Type="integer" Value="1" KeyPath="yes" />
<RemoveFolder Id="ApplicationProgramsFolder2" On="uninstall" />
</Component>
<!-- tool-rust-docs-end -->
</Directory>
</Directory>

Expand Down Expand Up @@ -256,6 +260,7 @@
<ComponentGroupRef Id="GccGroup" />
</Feature>
<?endif?>
<!-- tool-rust-docs-start -->
<Feature Id="Docs"
Title="HTML documentation"
Display="5"
Expand All @@ -264,6 +269,7 @@
<ComponentGroupRef Id="DocsGroup" />
<ComponentRef Id="DocIndexShortcut" />
</Feature>
<!-- tool-rust-docs-end -->
<Feature Id="Path"
Title="Add to PATH"
Description="Add Rust to PATH environment variable"
Expand Down
6 changes: 6 additions & 0 deletions src/etc/installer/pkg/Distribution.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
<line choice="rustc"/>
<line choice="rust-std"/>
<line choice="cargo"/>
<!-- tool-rust-docs-start -->
<line choice="rust-docs"/>
<!-- tool-rust-docs-end -->
</line>
<line choice="uninstall" />
</choices-outline>
Expand Down Expand Up @@ -55,15 +57,19 @@
>
<pkg-ref id="org.rust-lang.rust-std"/>
</choice>
<!-- tool-rust-docs-start -->
<choice id="rust-docs" visible="true"
title="Documentation" description="HTML documentation."
selected="(!choices.uninstall.selected &amp;&amp; choices['rust-docs'].selected) || (choices.uninstall.selected &amp;&amp; choices.install.selected)"
>
<pkg-ref id="org.rust-lang.rust-docs"/>
</choice>
<!-- tool-rust-docs-end -->
<pkg-ref id="org.rust-lang.rustc" version="0" onConclusion="none">rustc.pkg</pkg-ref>
<pkg-ref id="org.rust-lang.cargo" version="0" onConclusion="none">cargo.pkg</pkg-ref>
<!-- tool-rust-docs-start -->
<pkg-ref id="org.rust-lang.rust-docs" version="0" onConclusion="none">rust-docs.pkg</pkg-ref>
<!-- tool-rust-docs-end -->
<pkg-ref id="org.rust-lang.rust-std" version="0" onConclusion="none">rust-std.pkg</pkg-ref>
<pkg-ref id="org.rust-lang.uninstall" version="0" onConclusion="none">uninstall.pkg</pkg-ref>
<background file="rust-logo.png" mime-type="image/png"
Expand Down

0 comments on commit 749b487

Please sign in to comment.