Skip to content

Commit 4e9527c

Browse files
committed
Auto merge of #45243 - alexcrichton:tool-rls-rustfmt, r=Mark-Simulacrum
rustbuild: Allow setting rls/rustfmt to "broken" This commit enables configuring the RLS/rustfmt tools to the "broken" state and actually get it past CI. The main changes here were to update all dist-related code to handle the situation where the RLS isn't available. This in turn involved a homegrown preprocessor-like-function to edit the configuration files we pass to the various combined installer tools.
2 parents ba4e8d7 + 5050dad commit 4e9527c

File tree

6 files changed

+129
-89
lines changed

6 files changed

+129
-89
lines changed

src/bootstrap/dist.rs

+108-88
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,7 @@ pub struct Rls {
10351035
}
10361036

10371037
impl Step for Rls {
1038-
type Output = PathBuf;
1038+
type Output = Option<PathBuf>;
10391039
const ONLY_BUILD_TARGETS: bool = true;
10401040
const ONLY_HOSTS: bool = true;
10411041

@@ -1050,12 +1050,17 @@ impl Step for Rls {
10501050
});
10511051
}
10521052

1053-
fn run(self, builder: &Builder) -> PathBuf {
1053+
fn run(self, builder: &Builder) -> Option<PathBuf> {
10541054
let build = builder.build;
10551055
let stage = self.stage;
10561056
let target = self.target;
10571057
assert!(build.config.extended);
10581058

1059+
if !builder.config.toolstate.rls.testing() {
1060+
println!("skipping Dist RLS stage{} ({})", stage, target);
1061+
return None
1062+
}
1063+
10591064
println!("Dist RLS stage{} ({})", stage, target);
10601065
let src = build.src.join("src/tools/rls");
10611066
let release_num = build.release_num("rls");
@@ -1102,7 +1107,7 @@ impl Step for Rls {
11021107
.arg("--component-name=rls-preview");
11031108

11041109
build.run(&mut cmd);
1105-
distdir(build).join(format!("{}-{}.tar.gz", name, target))
1110+
Some(distdir(build).join(format!("{}-{}.tar.gz", name, target)))
11061111
}
11071112
}
11081113

@@ -1202,8 +1207,12 @@ impl Step for Extended {
12021207
// upgrades rustc was upgraded before rust-std. To avoid rustc clobbering
12031208
// the std files during uninstall. To do this ensure that rustc comes
12041209
// before rust-std in the list below.
1205-
let mut tarballs = vec![rustc_installer, cargo_installer, rls_installer,
1206-
analysis_installer, std_installer];
1210+
let mut tarballs = Vec::new();
1211+
tarballs.push(rustc_installer);
1212+
tarballs.push(cargo_installer);
1213+
tarballs.extend(rls_installer.clone());
1214+
tarballs.push(analysis_installer);
1215+
tarballs.push(std_installer);
12071216
if build.config.docs {
12081217
tarballs.push(docs_installer);
12091218
}
@@ -1245,35 +1254,38 @@ impl Step for Extended {
12451254
}
12461255
rtf.push_str("}");
12471256

1257+
fn filter(contents: &str, marker: &str) -> String {
1258+
let start = format!("tool-{}-start", marker);
1259+
let end = format!("tool-{}-end", marker);
1260+
let mut lines = Vec::new();
1261+
let mut omitted = false;
1262+
for line in contents.lines() {
1263+
if line.contains(&start) {
1264+
omitted = true;
1265+
} else if line.contains(&end) {
1266+
omitted = false;
1267+
} else if !omitted {
1268+
lines.push(line);
1269+
}
1270+
}
1271+
1272+
lines.join("\n")
1273+
}
1274+
1275+
let xform = |p: &Path| {
1276+
let mut contents = String::new();
1277+
t!(t!(File::open(p)).read_to_string(&mut contents));
1278+
if rls_installer.is_none() {
1279+
contents = filter(&contents, "rls");
1280+
}
1281+
let ret = tmp.join(p.file_name().unwrap());
1282+
t!(t!(File::create(&ret)).write_all(contents.as_bytes()));
1283+
return ret
1284+
};
1285+
12481286
if target.contains("apple-darwin") {
12491287
let pkg = tmp.join("pkg");
12501288
let _ = fs::remove_dir_all(&pkg);
1251-
t!(fs::create_dir_all(pkg.join("rustc")));
1252-
t!(fs::create_dir_all(pkg.join("cargo")));
1253-
t!(fs::create_dir_all(pkg.join("rust-docs")));
1254-
t!(fs::create_dir_all(pkg.join("rust-std")));
1255-
t!(fs::create_dir_all(pkg.join("rls")));
1256-
t!(fs::create_dir_all(pkg.join("rust-analysis")));
1257-
1258-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rustc"), target)),
1259-
&pkg.join("rustc"));
1260-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "cargo"), target)),
1261-
&pkg.join("cargo"));
1262-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-docs"), target)),
1263-
&pkg.join("rust-docs"));
1264-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-std"), target)),
1265-
&pkg.join("rust-std"));
1266-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rls"), target)),
1267-
&pkg.join("rls"));
1268-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-analysis"), target)),
1269-
&pkg.join("rust-analysis"));
1270-
1271-
install(&etc.join("pkg/postinstall"), &pkg.join("rustc"), 0o755);
1272-
install(&etc.join("pkg/postinstall"), &pkg.join("cargo"), 0o755);
1273-
install(&etc.join("pkg/postinstall"), &pkg.join("rust-docs"), 0o755);
1274-
install(&etc.join("pkg/postinstall"), &pkg.join("rust-std"), 0o755);
1275-
install(&etc.join("pkg/postinstall"), &pkg.join("rls"), 0o755);
1276-
install(&etc.join("pkg/postinstall"), &pkg.join("rust-analysis"), 0o755);
12771289

12781290
let pkgbuild = |component: &str| {
12791291
let mut cmd = Command::new("pkgbuild");
@@ -1283,12 +1295,23 @@ impl Step for Extended {
12831295
.arg(pkg.join(component).with_extension("pkg"));
12841296
build.run(&mut cmd);
12851297
};
1286-
pkgbuild("rustc");
1287-
pkgbuild("cargo");
1288-
pkgbuild("rust-docs");
1289-
pkgbuild("rust-std");
1290-
pkgbuild("rls");
1291-
pkgbuild("rust-analysis");
1298+
1299+
let prepare = |name: &str| {
1300+
t!(fs::create_dir_all(pkg.join(name)));
1301+
cp_r(&work.join(&format!("{}-{}", pkgname(build, name), target)),
1302+
&pkg.join(name));
1303+
install(&etc.join("pkg/postinstall"), &pkg.join(name), 0o755);
1304+
pkgbuild(name);
1305+
};
1306+
prepare("rustc");
1307+
prepare("cargo");
1308+
prepare("rust-docs");
1309+
prepare("rust-std");
1310+
prepare("rust-analysis");
1311+
1312+
if rls_installer.is_some() {
1313+
prepare("rls");
1314+
}
12921315

12931316
// create an 'uninstall' package
12941317
install(&etc.join("pkg/postinstall"), &pkg.join("uninstall"), 0o755);
@@ -1298,7 +1321,7 @@ impl Step for Extended {
12981321
t!(t!(File::create(pkg.join("res/LICENSE.txt"))).write_all(license.as_bytes()));
12991322
install(&etc.join("gfx/rust-logo.png"), &pkg.join("res"), 0o644);
13001323
let mut cmd = Command::new("productbuild");
1301-
cmd.arg("--distribution").arg(etc.join("pkg/Distribution.xml"))
1324+
cmd.arg("--distribution").arg(xform(&etc.join("pkg/Distribution.xml")))
13021325
.arg("--resources").arg(pkg.join("res"))
13031326
.arg(distdir(build).join(format!("{}-{}.pkg",
13041327
pkgname(build, "rust"),
@@ -1310,46 +1333,34 @@ impl Step for Extended {
13101333
if target.contains("windows") {
13111334
let exe = tmp.join("exe");
13121335
let _ = fs::remove_dir_all(&exe);
1313-
t!(fs::create_dir_all(exe.join("rustc")));
1314-
t!(fs::create_dir_all(exe.join("cargo")));
1315-
t!(fs::create_dir_all(exe.join("rls")));
1316-
t!(fs::create_dir_all(exe.join("rust-analysis")));
1317-
t!(fs::create_dir_all(exe.join("rust-docs")));
1318-
t!(fs::create_dir_all(exe.join("rust-std")));
1319-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rustc"), target))
1320-
.join("rustc"),
1321-
&exe.join("rustc"));
1322-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "cargo"), target))
1323-
.join("cargo"),
1324-
&exe.join("cargo"));
1325-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-docs"), target))
1326-
.join("rust-docs"),
1327-
&exe.join("rust-docs"));
1328-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-std"), target))
1329-
.join(format!("rust-std-{}", target)),
1330-
&exe.join("rust-std"));
1331-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rls"), target)).join("rls-preview"),
1332-
&exe.join("rls"));
1333-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-analysis"), target))
1334-
.join(format!("rust-analysis-{}", target)),
1335-
&exe.join("rust-analysis"));
1336-
1337-
t!(fs::remove_file(exe.join("rustc/manifest.in")));
1338-
t!(fs::remove_file(exe.join("cargo/manifest.in")));
1339-
t!(fs::remove_file(exe.join("rust-docs/manifest.in")));
1340-
t!(fs::remove_file(exe.join("rust-std/manifest.in")));
1341-
t!(fs::remove_file(exe.join("rls/manifest.in")));
1342-
t!(fs::remove_file(exe.join("rust-analysis/manifest.in")));
13431336

1337+
let prepare = |name: &str| {
1338+
t!(fs::create_dir_all(exe.join(name)));
1339+
let dir = if name == "rust-std" || name == "rust-analysis" {
1340+
format!("{}-{}", name, target)
1341+
} else if name == "rls" {
1342+
"rls-preview".to_string()
1343+
} else {
1344+
name.to_string()
1345+
};
1346+
cp_r(&work.join(&format!("{}-{}", pkgname(build, name), target))
1347+
.join(dir),
1348+
&exe.join(name));
1349+
t!(fs::remove_file(exe.join(name).join("manifest.in")));
1350+
};
1351+
prepare("rustc");
1352+
prepare("cargo");
1353+
prepare("rust-analysis");
1354+
prepare("rust-docs");
1355+
prepare("rust-std");
1356+
if rls_installer.is_some() {
1357+
prepare("rls");
1358+
}
13441359
if target.contains("windows-gnu") {
1345-
t!(fs::create_dir_all(exe.join("rust-mingw")));
1346-
cp_r(&work.join(&format!("{}-{}", pkgname(build, "rust-mingw"), target))
1347-
.join("rust-mingw"),
1348-
&exe.join("rust-mingw"));
1349-
t!(fs::remove_file(exe.join("rust-mingw/manifest.in")));
1360+
prepare("rust-mingw");
13501361
}
13511362

1352-
install(&etc.join("exe/rust.iss"), &exe, 0o644);
1363+
install(&xform(&etc.join("exe/rust.iss")), &exe, 0o644);
13531364
install(&etc.join("exe/modpath.iss"), &exe, 0o644);
13541365
install(&etc.join("exe/upgrade.iss"), &exe, 0o644);
13551366
install(&etc.join("gfx/rust-logo.ico"), &exe, 0o644);
@@ -1413,16 +1424,18 @@ impl Step for Extended {
14131424
.arg("-dr").arg("Std")
14141425
.arg("-var").arg("var.StdDir")
14151426
.arg("-out").arg(exe.join("StdGroup.wxs")));
1416-
build.run(Command::new(&heat)
1417-
.current_dir(&exe)
1418-
.arg("dir")
1419-
.arg("rls")
1420-
.args(&heat_flags)
1421-
.arg("-cg").arg("RlsGroup")
1422-
.arg("-dr").arg("Rls")
1423-
.arg("-var").arg("var.RlsDir")
1424-
.arg("-out").arg(exe.join("RlsGroup.wxs"))
1425-
.arg("-t").arg(etc.join("msi/remove-duplicates.xsl")));
1427+
if rls_installer.is_some() {
1428+
build.run(Command::new(&heat)
1429+
.current_dir(&exe)
1430+
.arg("dir")
1431+
.arg("rls")
1432+
.args(&heat_flags)
1433+
.arg("-cg").arg("RlsGroup")
1434+
.arg("-dr").arg("Rls")
1435+
.arg("-var").arg("var.RlsDir")
1436+
.arg("-out").arg(exe.join("RlsGroup.wxs"))
1437+
.arg("-t").arg(etc.join("msi/remove-duplicates.xsl")));
1438+
}
14261439
build.run(Command::new(&heat)
14271440
.current_dir(&exe)
14281441
.arg("dir")
@@ -1456,26 +1469,30 @@ impl Step for Extended {
14561469
.arg("-dDocsDir=rust-docs")
14571470
.arg("-dCargoDir=cargo")
14581471
.arg("-dStdDir=rust-std")
1459-
.arg("-dRlsDir=rls")
14601472
.arg("-dAnalysisDir=rust-analysis")
14611473
.arg("-arch").arg(&arch)
14621474
.arg("-out").arg(&output)
14631475
.arg(&input);
14641476
add_env(build, &mut cmd, target);
14651477

1478+
if rls_installer.is_some() {
1479+
cmd.arg("-dRlsDir=rls");
1480+
}
14661481
if target.contains("windows-gnu") {
14671482
cmd.arg("-dGccDir=rust-mingw");
14681483
}
14691484
build.run(&mut cmd);
14701485
};
1471-
candle(&etc.join("msi/rust.wxs"));
1486+
candle(&xform(&etc.join("msi/rust.wxs")));
14721487
candle(&etc.join("msi/ui.wxs"));
14731488
candle(&etc.join("msi/rustwelcomedlg.wxs"));
14741489
candle("RustcGroup.wxs".as_ref());
14751490
candle("DocsGroup.wxs".as_ref());
14761491
candle("CargoGroup.wxs".as_ref());
14771492
candle("StdGroup.wxs".as_ref());
1478-
candle("RlsGroup.wxs".as_ref());
1493+
if rls_installer.is_some() {
1494+
candle("RlsGroup.wxs".as_ref());
1495+
}
14791496
candle("AnalysisGroup.wxs".as_ref());
14801497

14811498
if target.contains("windows-gnu") {
@@ -1499,10 +1516,13 @@ impl Step for Extended {
14991516
.arg("DocsGroup.wixobj")
15001517
.arg("CargoGroup.wixobj")
15011518
.arg("StdGroup.wixobj")
1502-
.arg("RlsGroup.wixobj")
15031519
.arg("AnalysisGroup.wixobj")
15041520
.current_dir(&exe);
15051521

1522+
if rls_installer.is_some() {
1523+
cmd.arg("RlsGroup.wixobj");
1524+
}
1525+
15061526
if target.contains("windows-gnu") {
15071527
cmd.arg("GccGroup.wixobj");
15081528
}

src/bootstrap/toolstate.rs

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ impl ToolState {
3131
BuildExpectation::Failing
3232
}
3333
}
34+
35+
pub fn testing(&self) -> bool {
36+
match *self {
37+
ToolState::Testing => true,
38+
_ => false,
39+
}
40+
}
3441
}
3542

3643
impl Default for ToolState {

src/etc/installer/exe/rust.iss

+4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ Name: gcc; Description: "Linker and platform libraries"; Types: full
4646
Name: docs; Description: "HTML documentation"; Types: full
4747
Name: cargo; Description: "Cargo, the Rust package manager"; Types: full
4848
Name: std; Description: "The Rust Standard Library"; Types: full
49+
// tool-rls-start
4950
Name: rls; Description: "RLS, the Rust Language Server"
51+
// tool-rls-end
5052

5153
[Files]
5254
Source: "rustc/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: rust
@@ -56,8 +58,10 @@ Source: "rust-mingw/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs;
5658
Source: "rust-docs/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: docs
5759
Source: "cargo/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: cargo
5860
Source: "rust-std/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: std
61+
// tool-rls-start
5962
Source: "rls/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: rls
6063
Source: "rust-analysis/*.*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs; Components: rls
64+
// tool-rls-end
6165

6266
[Code]
6367
const

src/etc/installer/msi/rust.wxs

+4
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,10 @@
170170
<Directory Id="Docs" Name="." />
171171
<Directory Id="Cargo" Name="." />
172172
<Directory Id="Std" Name="." />
173+
<!-- tool-rls-start -->
173174
<Directory Id="Rls" Name="." />
174175
<Directory Id="Analysis" Name="." />
176+
<!-- tool-rls-end -->
175177
</Directory>
176178
</Directory>
177179

@@ -275,6 +277,7 @@
275277
<ComponentRef Id="PathEnvPerMachine" />
276278
<ComponentRef Id="PathEnvPerUser" />
277279
</Feature>
280+
<!-- tool-rls-start -->
278281
<Feature Id="RLS"
279282
Title="RLS, the Rust Language Server"
280283
Display="7"
@@ -283,6 +286,7 @@
283286
<ComponentGroupRef Id="RlsGroup" />
284287
<ComponentGroupRef Id="AnalysisGroup" />
285288
</Feature>
289+
<!-- tool-rls-end -->
286290

287291
<UIRef Id="RustUI" />
288292
</Product>

src/etc/installer/pkg/Distribution.xml

+6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
<line choice="rust-std"/>
1717
<line choice="cargo"/>
1818
<line choice="rust-docs"/>
19+
<!-- tool-rls-start -->
1920
<line choice="rls"/>
21+
<!-- tool-rls-end -->
2022
</line>
2123
<line choice="uninstall" />
2224
</choices-outline>
@@ -62,6 +64,7 @@
6264
>
6365
<pkg-ref id="org.rust-lang.rust-docs"/>
6466
</choice>
67+
<!-- tool-rls-start -->
6568
<choice id="rls" visible="true"
6669
title="RLS" description="RLS, the Rust Language Server"
6770
selected="(!choices.uninstall.selected &amp;&amp; choices['rls'].selected) || (choices.uninstall.selected &amp;&amp; choices.install.selected)"
@@ -70,11 +73,14 @@
7073
<pkg-ref id="org.rust-lang.rls"/>
7174
<pkg-ref id="org.rust-lang.rust-analysis"/>
7275
</choice>
76+
<!-- tool-rls-end -->
7377
<pkg-ref id="org.rust-lang.rustc" version="0" onConclusion="none">rustc.pkg</pkg-ref>
7478
<pkg-ref id="org.rust-lang.cargo" version="0" onConclusion="none">cargo.pkg</pkg-ref>
7579
<pkg-ref id="org.rust-lang.rust-docs" version="0" onConclusion="none">rust-docs.pkg</pkg-ref>
7680
<pkg-ref id="org.rust-lang.rust-std" version="0" onConclusion="none">rust-std.pkg</pkg-ref>
81+
<!-- tool-rls-start -->
7782
<pkg-ref id="org.rust-lang.rls" version="0" onConclusion="none">rls.pkg</pkg-ref>
83+
<!-- tool-rls-end -->
7884
<pkg-ref id="org.rust-lang.rust-analysis" version="0" onConclusion="none">rust-analysis.pkg</pkg-ref>
7985
<pkg-ref id="org.rust-lang.uninstall" version="0" onConclusion="none">uninstall.pkg</pkg-ref>
8086
<background file="rust-logo.png" mime-type="image/png"

0 commit comments

Comments
 (0)