Skip to content

Commit c4b51c4

Browse files
committed
rustbuild: add configuration option to build all tools
This does not change what we install (as opposed to extended). This only causes all the tools to be built as part of './x.py build'. This is useful to check that all the tools compile fine, and will avoid some compilation during './x.py install' if it is enabled. Signed-off-by: Marc-Antoine Perennou <[email protected]>
1 parent a4c68c6 commit c4b51c4

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

src/bootstrap/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub struct Config {
4949
pub target_config: HashMap<String, Target>,
5050
pub full_bootstrap: bool,
5151
pub extended: bool,
52+
pub build_all_tools: bool,
5253
pub sanitizers: bool,
5354
pub profiler: bool,
5455

@@ -162,6 +163,7 @@ struct Build {
162163
python: Option<String>,
163164
full_bootstrap: Option<bool>,
164165
extended: Option<bool>,
166+
build_all_tools: Option<bool>,
165167
verbose: Option<usize>,
166168
sanitizers: Option<bool>,
167169
profiler: Option<bool>,
@@ -320,6 +322,7 @@ impl Config {
320322
set(&mut config.vendor, build.vendor);
321323
set(&mut config.full_bootstrap, build.full_bootstrap);
322324
set(&mut config.extended, build.extended);
325+
set(&mut config.build_all_tools, build.build_all_tools);
323326
set(&mut config.verbose, build.verbose);
324327
set(&mut config.sanitizers, build.sanitizers);
325328
set(&mut config.profiler, build.profiler);
@@ -482,6 +485,7 @@ impl Config {
482485
("VENDOR", self.vendor),
483486
("FULL_BOOTSTRAP", self.full_bootstrap),
484487
("EXTENDED", self.extended),
488+
("BUILD_ALL_TOOLS", self.build_all_tools),
485489
("SANITIZERS", self.sanitizers),
486490
("PROFILER", self.profiler),
487491
("DIST_SRC", self.rust_dist_src),

src/bootstrap/config.toml.example

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,18 @@
143143
# option to true.
144144
#full-bootstrap = false
145145

146-
# Enable a build of the and extended rust tool set which is not only the
147-
# compiler but also tools such as Cargo. This will also produce "combined
148-
# installers" which are used to install Rust and Cargo together. This is
146+
# Enable a build of the extended rust tool set which is not only the
147+
# compiler but also tools such as Cargo or RLS. This will also produce "combined
148+
# installers" which are used to install Rust, Cargo and RLS together. This is
149149
# disabled by default.
150150
#extended = false
151151

152+
# Build all the tools as part of the "build" phase instead of lazily
153+
# waiting for those to be needed. This will cause tools such as rust-installer
154+
# and rustbook to be built early on instead of during installation or
155+
# documentation generation. This is disabled by default.
156+
#build-all-tools = false
157+
152158
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
153159
#verbose = 0
154160

src/bootstrap/step.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,52 +541,77 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
541541
//
542542
// Tools used during the build system but not shipped
543543
rules.build("tool-rustbook", "src/tools/rustbook")
544+
.default(build.config.build_all_tools)
545+
.host(true)
544546
.dep(|s| s.name("maybe-clean-tools"))
545547
.dep(|s| s.name("librustc-tool"))
546548
.run(move |s| compile::tool(build, s.stage, s.target, "rustbook"));
547549
rules.build("tool-error-index", "src/tools/error_index_generator")
550+
.default(build.config.build_all_tools)
551+
.host(true)
548552
.dep(|s| s.name("maybe-clean-tools"))
549553
.dep(|s| s.name("librustc-tool"))
550554
.run(move |s| compile::tool(build, s.stage, s.target, "error_index_generator"));
551555
rules.build("tool-unstable-book-gen", "src/tools/unstable-book-gen")
556+
.default(build.config.build_all_tools)
557+
.host(true)
552558
.dep(|s| s.name("maybe-clean-tools"))
553559
.dep(|s| s.name("libstd-tool"))
554560
.run(move |s| compile::tool(build, s.stage, s.target, "unstable-book-gen"));
555561
rules.build("tool-tidy", "src/tools/tidy")
562+
.default(build.config.build_all_tools)
563+
.host(true)
564+
.only_build(true)
556565
.dep(|s| s.name("maybe-clean-tools"))
557566
.dep(|s| s.name("libstd-tool"))
558567
.run(move |s| compile::tool(build, s.stage, s.target, "tidy"));
559568
rules.build("tool-linkchecker", "src/tools/linkchecker")
569+
.default(build.config.build_all_tools)
570+
.host(true)
560571
.dep(|s| s.name("maybe-clean-tools"))
561572
.dep(|s| s.name("libstd-tool"))
562573
.run(move |s| compile::tool(build, s.stage, s.target, "linkchecker"));
563574
rules.build("tool-cargotest", "src/tools/cargotest")
575+
.default(build.config.build_all_tools)
576+
.host(true)
564577
.dep(|s| s.name("maybe-clean-tools"))
565578
.dep(|s| s.name("libstd-tool"))
566579
.run(move |s| compile::tool(build, s.stage, s.target, "cargotest"));
567580
rules.build("tool-compiletest", "src/tools/compiletest")
581+
.default(build.config.build_all_tools)
582+
.host(true)
568583
.dep(|s| s.name("maybe-clean-tools"))
569584
.dep(|s| s.name("libtest-tool"))
570585
.run(move |s| compile::tool(build, s.stage, s.target, "compiletest"));
571586
rules.build("tool-build-manifest", "src/tools/build-manifest")
587+
.default(build.config.build_all_tools)
588+
.host(true)
589+
.only_build(true)
590+
.only_host_build(true)
572591
.dep(|s| s.name("maybe-clean-tools"))
573592
.dep(|s| s.name("libstd-tool"))
574593
.run(move |s| compile::tool(build, s.stage, s.target, "build-manifest"));
575594
rules.build("tool-remote-test-server", "src/tools/remote-test-server")
595+
.default(build.config.build_all_tools)
596+
.host(true)
576597
.dep(|s| s.name("maybe-clean-tools"))
577598
.dep(|s| s.name("libstd-tool"))
578599
.run(move |s| compile::tool(build, s.stage, s.target, "remote-test-server"));
579600
rules.build("tool-remote-test-client", "src/tools/remote-test-client")
601+
.default(build.config.build_all_tools)
602+
.host(true)
580603
.dep(|s| s.name("maybe-clean-tools"))
581604
.dep(|s| s.name("libstd-tool"))
582605
.run(move |s| compile::tool(build, s.stage, s.target, "remote-test-client"));
583606
rules.build("tool-rust-installer", "src/tools/rust-installer")
607+
.default(build.config.build_all_tools)
608+
.host(true)
584609
.dep(|s| s.name("maybe-clean-tools"))
585610
.dep(|s| s.name("libstd-tool"))
586611
.run(move |s| compile::tool(build, s.stage, s.target, "rust-installer"));
587612
rules.build("tool-cargo", "src/tools/cargo")
613+
.default(build.config.extended || build.config.build_all_tools)
588614
.host(true)
589-
.default(build.config.extended)
590615
.dep(|s| s.name("maybe-clean-tools"))
591616
.dep(|s| s.name("libstd-tool"))
592617
.dep(|s| s.stage(0).host(s.target).name("openssl"))
@@ -599,8 +624,8 @@ pub fn build_rules<'a>(build: &'a Build) -> Rules {
599624
})
600625
.run(move |s| compile::tool(build, s.stage, s.target, "cargo"));
601626
rules.build("tool-rls", "src/tools/rls")
627+
.default(build.config.extended || build.config.build_all_tools)
602628
.host(true)
603-
.default(build.config.extended)
604629
.dep(|s| s.name("librustc-tool"))
605630
.dep(|s| s.stage(0).host(s.target).name("openssl"))
606631
.dep(move |s| {

0 commit comments

Comments
 (0)