From 0c8baa729dc3bb61713fdc198062e721c1ffa7c1 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 19 Jul 2021 13:06:24 +0200 Subject: [PATCH] refactor gating of dist docs --- src/bootstrap/dist.rs | 21 +++++++++------------ src/bootstrap/install.rs | 8 ++------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 1d7dbeddee98..b0764791907b 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -51,11 +51,12 @@ pub struct Docs { } impl Step for Docs { - type Output = Option; + type Output = GeneratedTarball; const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("src/doc") + let default = run.builder.config.docs; + run.path("src/doc").default_condition(default) } fn make_run(run: RunConfig<'_>) { @@ -63,11 +64,8 @@ impl Step for Docs { } /// Builds the `rust-docs` installer component. - fn run(self, builder: &Builder<'_>) -> Option { + fn run(self, builder: &Builder<'_>) -> GeneratedTarball { let host = self.host; - if !builder.config.docs { - return None; - } builder.default_doc(&[]); let dest = "share/doc/rust/html"; @@ -76,7 +74,7 @@ impl Step for Docs { tarball.set_product_name("Rust Documentation"); tarball.add_bulk_dir(&builder.doc_out(host), dest); tarball.add_file(&builder.src.join("src/doc/robots.txt"), dest, 0o644); - Some(tarball.generate()) + tarball.generate() } } @@ -1354,6 +1352,10 @@ impl Step for Extended { tarballs.push(builder.ensure(Rustc { compiler: builder.compiler(stage, target) })); tarballs.push(builder.ensure(Std { compiler, target }).expect("missing std")); + if builder.config.docs { + tarballs.push(builder.ensure(Docs { host: target })); + } + let cargo_installer = builder.ensure(Cargo { compiler, target }); let rustfmt_installer = builder.ensure(Rustfmt { compiler, target }); let rust_demangler_installer = builder.ensure(RustDemangler { compiler, target }); @@ -1365,8 +1367,6 @@ impl Step for Extended { let mingw_installer = builder.ensure(Mingw { host: target }); let analysis_installer = builder.ensure(Analysis { compiler, target }); - let docs_installer = builder.ensure(Docs { host: target }); - let etc = builder.src.join("src/etc/installer"); // Avoid producing tarballs during a dry run. @@ -1385,9 +1385,6 @@ impl Step for Extended { if let Some(analysis_installer) = analysis_installer { tarballs.push(analysis_installer); } - if let Some(docs_installer) = docs_installer { - tarballs.push(docs_installer); - } if target.contains("pc-windows-gnu") { tarballs.push(mingw_installer.unwrap()); } diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 8a1b6df0dafe..1eb516fb7712 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -139,12 +139,8 @@ macro_rules! install { install!((self, builder, _config), Docs, "src/doc", _config.docs, only_hosts: false, { - if let Some(tarball) = builder.ensure(dist::Docs { host: self.target }) { - install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball); - } else { - panic!("docs are not available to install, \ - check that `build.docs` is true in `config.toml`"); - } + let tarball = builder.ensure(dist::Docs { host: self.target }); + install_sh(builder, "docs", self.compiler.stage, Some(self.target), &tarball); }; Std, "library/std", true, only_hosts: false, { for target in &builder.targets {