about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro.albini@ferrous-systems.com>2021-07-19 13:06:24 +0200
committerPietro Albini <pietro.albini@ferrous-systems.com>2021-07-19 16:15:48 +0200
commit0c8baa729dc3bb61713fdc198062e721c1ffa7c1 (patch)
tree9150106e1f3393382ccea878bafafe7bfc8478f3
parent8f3844ff07449ebd045ba8fd9adcac62e957cfe8 (diff)
downloadrust-0c8baa729dc3bb61713fdc198062e721c1ffa7c1.tar.gz
rust-0c8baa729dc3bb61713fdc198062e721c1ffa7c1.zip
refactor gating of dist docs
-rw-r--r--src/bootstrap/dist.rs21
-rw-r--r--src/bootstrap/install.rs8
2 files changed, 11 insertions, 18 deletions
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 1d7dbeddee9..b0764791907 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<GeneratedTarball>;
+    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<GeneratedTarball> {
+    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 8a1b6df0daf..1eb516fb771 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 {