Skip to content

Commit 11e002a

Browse files
committed
Make stage2 rustdoc and proc-macro-srv disableable in x.py install
1 parent b8f9cb3 commit 11e002a

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

config.toml.example

+18-5
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,24 @@ changelog-seen = 2
285285
# be built if `extended = true`.
286286
#extended = false
287287

288-
# Installs chosen set of extended tools if `extended = true`. By default builds
289-
# all extended tools except `rust-demangler`, unless the target is also being
290-
# built with `profiler = true`. If chosen tool failed to build the installation
291-
# fails. If `extended = false`, this option is ignored.
292-
#tools = ["cargo", "rls", "clippy", "rustfmt", "analysis", "src"] # + "rust-demangler" if `profiler`
288+
# Set of tools to be included in the installation.
289+
#
290+
# If `extended = false`, the only one of these built by default is rustdoc.
291+
#
292+
# If `extended = true`, they're all included, with the exception of
293+
# rust-demangler which additionally requires `profiler = true` to be set.
294+
#
295+
# If any enabled tool fails to build, the installation fails.
296+
#tools = [
297+
# "cargo",
298+
# "clippy",
299+
# "rustdoc",
300+
# "rustfmt",
301+
# "rust-analyzer",
302+
# "analysis",
303+
# "src",
304+
# "rust-demangler", # if profiler = true
305+
#]
293306

294307
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
295308
#verbose = 0

src/bootstrap/dist.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -392,19 +392,29 @@ impl Step for Rustc {
392392
t!(fs::create_dir_all(image.join("bin")));
393393
builder.cp_r(&src.join("bin"), &image.join("bin"));
394394

395-
builder.install(&builder.rustdoc(compiler), &image.join("bin"), 0o755);
395+
if builder
396+
.config
397+
.tools
398+
.as_ref()
399+
.map_or(true, |tools| tools.iter().any(|tool| tool == "rustdoc"))
400+
{
401+
let rustdoc = builder.rustdoc(compiler);
402+
builder.install(&rustdoc, &image.join("bin"), 0o755);
403+
}
396404

397-
let ra_proc_macro_srv = builder
398-
.ensure(tool::RustAnalyzerProcMacroSrv {
405+
if let Some(ra_proc_macro_srv) = builder.ensure_if_default(
406+
tool::RustAnalyzerProcMacroSrv {
399407
compiler: builder.compiler_for(
400408
compiler.stage,
401409
builder.config.build,
402410
compiler.host,
403411
),
404412
target: compiler.host,
405-
})
406-
.expect("rust-analyzer-proc-macro-server always builds");
407-
builder.install(&ra_proc_macro_srv, &image.join("libexec"), 0o755);
413+
},
414+
builder.kind,
415+
) {
416+
builder.install(&ra_proc_macro_srv, &image.join("libexec"), 0o755);
417+
}
408418

409419
let libdir_relative = builder.libdir_relative(compiler);
410420

src/bootstrap/tool.rs

+6
Original file line numberDiff line numberDiff line change
@@ -765,9 +765,15 @@ impl Step for RustAnalyzerProcMacroSrv {
765765
const ONLY_HOSTS: bool = true;
766766

767767
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
768+
let builder = run.builder;
768769
// Allow building `rust-analyzer-proc-macro-srv` both as part of the `rust-analyzer` and as a stand-alone tool.
769770
run.path("src/tools/rust-analyzer")
770771
.path("src/tools/rust-analyzer/crates/proc-macro-srv-cli")
772+
.default_condition(builder.config.tools.as_ref().map_or(true, |tools| {
773+
tools
774+
.iter()
775+
.any(|tool| tool == "rust-analyzer" || tool == "rust-analyzer-proc-macro-srv")
776+
}))
771777
}
772778

773779
fn make_run(run: RunConfig<'_>) {

0 commit comments

Comments
 (0)