diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 9b0a6e6e19d..26a621c41ca 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -55,7 +55,7 @@ pub struct Docs { } impl Step for Docs { - type Output = PathBuf; + type Output = Option; const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -67,13 +67,10 @@ impl Step for Docs { } /// Builds the `rust-docs` installer component. - fn run(self, builder: &Builder<'_>) -> PathBuf { + fn run(self, builder: &Builder<'_>) -> Option { let host = self.host; - - let name = pkgname(builder, "rust-docs"); - if !builder.config.docs { - return distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple)); + return None; } builder.default_doc(None); @@ -81,34 +78,14 @@ impl Step for Docs { builder.info(&format!("Dist docs ({})", host)); let _time = timeit(builder); - let image = tmpdir(builder).join(format!("{}-{}-image", name, host.triple)); - let _ = fs::remove_dir_all(&image); + let dest = "share/doc/rust/html"; - let dst = image.join("share/doc/rust/html"); - t!(fs::create_dir_all(&dst)); - let src = builder.doc_out(host); - builder.cp_r(&src, &dst); - builder.install(&builder.src.join("src/doc/robots.txt"), &dst, 0o644); + let mut tarball = Tarball::new(builder, "rust-docs", &host.triple); + tarball.set_product_name("Rust Documentation"); + tarball.add_dir(&builder.doc_out(host), dest); + tarball.add_file(&builder.src.join("src/doc/robots.txt"), dest, 0o644); - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust-Documentation") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=Rust-documentation-is-installed.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg(format!("--package-name={}-{}", name, host.triple)) - .arg("--component-name=rust-docs") - .arg("--legacy-manifest-dirs=rustlib,cargo") - .arg("--bulk-dirs=share/doc/rust/html"); - builder.run(&mut cmd); - builder.remove_dir(&image); - - distdir(builder).join(format!("{}-{}.tar.gz", name, host.triple)) + Some(tarball.generate()) } } @@ -1826,7 +1803,7 @@ impl Step for Extended { tarballs.extend(llvm_tools_installer); tarballs.push(analysis_installer); tarballs.push(std_installer); - if builder.config.docs { + if let Some(docs_installer) = docs_installer { tarballs.push(docs_installer); } if target.contains("pc-windows-gnu") { @@ -2509,7 +2486,7 @@ impl Step for RustDev { // Copy the include directory as well; needed mostly to build // librustc_llvm properly (e.g., llvm-config.h is in here). But also // just broadly useful to be able to link against the bundled LLVM. - tarball.add_dir(&builder.llvm_out(target).join("include"), "."); + tarball.add_dir(&builder.llvm_out(target).join("include"), "include"); // Copy libLLVM.so to the target lib dir as well, so the RPATH like // `$ORIGIN/../lib` can find it. It may also be used as a dependency diff --git a/src/bootstrap/tarball.rs b/src/bootstrap/tarball.rs index 2c110a7fb24..50d58d00a66 100644 --- a/src/bootstrap/tarball.rs +++ b/src/bootstrap/tarball.rs @@ -27,6 +27,7 @@ pub(crate) struct Tarball<'a> { pkgname: String, component: String, target: String, + product_name: String, overlay: OverlayKind, temp_dir: PathBuf, @@ -54,6 +55,7 @@ impl<'a> Tarball<'a> { pkgname, component: component.into(), target: target.into(), + product_name: "Rust".into(), overlay: OverlayKind::Rust, temp_dir, @@ -69,6 +71,10 @@ impl<'a> Tarball<'a> { self.overlay = overlay; } + pub(crate) fn set_product_name(&mut self, name: &str) { + self.product_name = name.into(); + } + pub(crate) fn is_preview(&mut self, is: bool) { self.is_preview = is; } @@ -91,12 +97,11 @@ impl<'a> Tarball<'a> { self.builder.install(src.as_ref(), &destdir, perms); } - pub(crate) fn add_dir(&self, src: impl AsRef, destdir: impl AsRef) { - t!(std::fs::create_dir_all(destdir.as_ref())); - self.builder.cp_r( - src.as_ref(), - &self.image_dir.join(destdir.as_ref()).join(src.as_ref().file_name().unwrap()), - ); + pub(crate) fn add_dir(&self, src: impl AsRef, dest: impl AsRef) { + let dest = self.image_dir.join(dest.as_ref()); + + t!(std::fs::create_dir_all(&dest)); + self.builder.cp_r(src.as_ref(), &dest); } pub(crate) fn generate(self) -> PathBuf { @@ -114,7 +119,7 @@ impl<'a> Tarball<'a> { let distdir = crate::dist::distdir(self.builder); let mut cmd = self.builder.tool_cmd(crate::tool::Tool::RustInstaller); cmd.arg("generate") - .arg("--product-name=Rust") + .arg(format!("--product-name={}", self.product_name)) .arg("--rel-manifest-dir=rustlib") .arg(format!("--success-message={} installed.", self.component)) .arg("--image-dir")