diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2020-11-30 13:25:34 +0100 |
|---|---|---|
| committer | Pietro Albini <pietro@pietroalbini.org> | 2020-12-23 19:35:22 +0100 |
| commit | 1906c42962b1f2bef084474e09b211e48ed2bda7 (patch) | |
| tree | 876fae4db3160f9d2bd50c9901ea9dfea25d26f8 /src/bootstrap | |
| parent | 2e0a16cf0d67f61d85ff7631846e9c3c6e20c85a (diff) | |
| download | rust-1906c42962b1f2bef084474e09b211e48ed2bda7.tar.gz rust-1906c42962b1f2bef084474e09b211e48ed2bda7.zip | |
bootstrap: convert rust-src to use Tarball
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/dist.rs | 30 | ||||
| -rw-r--r-- | src/bootstrap/tarball.rs | 31 |
2 files changed, 28 insertions, 33 deletions
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index b1a61500a70..c89b378f820 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -814,9 +814,7 @@ impl Step for Src { /// Creates the `rust-src` installer component fn run(self, builder: &Builder<'_>) -> PathBuf { - let name = pkgname(builder, "rust-src"); - let image = tmpdir(builder).join(format!("{}-image", name)); - let _ = fs::remove_dir_all(&image); + let tarball = Tarball::new_targetless(builder, "rust-src"); // A lot of tools expect the rust-src component to be entirely in this directory, so if you // change that (e.g. by adding another directory `lib/rustlib/src/foo` or @@ -825,8 +823,7 @@ impl Step for Src { // // NOTE: if you update the paths here, you also should update the "virtual" path // translation code in `imported_source_files` in `src/librustc_metadata/rmeta/decoder.rs` - let dst_src = image.join("lib/rustlib/src/rust"); - t!(fs::create_dir_all(&dst_src)); + let dst_src = tarball.image_dir().join("lib/rustlib/src/rust"); let src_files = ["Cargo.lock"]; // This is the reduced set of paths which will become the rust-src component @@ -846,28 +843,7 @@ impl Step for Src { builder.copy(&builder.src.join(file), &dst_src.join(file)); } - // Create source tarball in rust-installer format - let mut cmd = rust_installer(builder); - cmd.arg("generate") - .arg("--product-name=Rust") - .arg("--rel-manifest-dir=rustlib") - .arg("--success-message=Awesome-Source.") - .arg("--image-dir") - .arg(&image) - .arg("--work-dir") - .arg(&tmpdir(builder)) - .arg("--output-dir") - .arg(&distdir(builder)) - .arg(format!("--package-name={}", name)) - .arg("--component-name=rust-src") - .arg("--legacy-manifest-dirs=rustlib,cargo"); - - builder.info("Dist src"); - let _time = timeit(builder); - builder.run(&mut cmd); - - builder.remove_dir(&image); - distdir(builder).join(&format!("{}.tar.gz", name)) + tarball.generate() } } diff --git a/src/bootstrap/tarball.rs b/src/bootstrap/tarball.rs index 8a23d36346e..27769cab5af 100644 --- a/src/bootstrap/tarball.rs +++ b/src/bootstrap/tarball.rs @@ -84,7 +84,7 @@ pub(crate) struct Tarball<'a> { pkgname: String, component: String, - target: String, + target: Option<String>, product_name: String, overlay: OverlayKind, @@ -99,6 +99,14 @@ pub(crate) struct Tarball<'a> { impl<'a> Tarball<'a> { pub(crate) fn new(builder: &'a Builder<'a>, component: &str, target: &str) -> Self { + Self::new_inner(builder, component, Some(target.into())) + } + + pub(crate) fn new_targetless(builder: &'a Builder<'a>, component: &str) -> Self { + Self::new_inner(builder, component, None) + } + + fn new_inner(builder: &'a Builder<'a>, component: &str, target: Option<String>) -> Self { let pkgname = crate::dist::pkgname(builder, component); let temp_dir = builder.out.join("tmp").join("tarball").join(component); @@ -113,7 +121,7 @@ impl<'a> Tarball<'a> { pkgname, component: component.into(), - target: target.into(), + target, product_name: "Rust".into(), overlay: OverlayKind::Rust, @@ -197,7 +205,14 @@ impl<'a> Tarball<'a> { let mut cmd = self.builder.tool_cmd(crate::tool::Tool::RustInstaller); - self.builder.info(&format!("Dist {} ({})", self.component, self.target)); + let package_name = if let Some(target) = &self.target { + self.builder.info(&format!("Dist {} ({})", self.component, target)); + format!("{}-{}", self.pkgname, target) + } else { + self.builder.info(&format!("Dist {}", self.component)); + self.pkgname.clone() + }; + let _time = crate::util::timeit(self.builder); let mut component_name = self.component.clone(); @@ -206,7 +221,11 @@ impl<'a> Tarball<'a> { } if self.include_target_in_component_name { component_name.push('-'); - component_name.push_str(&self.target); + component_name.push_str( + &self + .target + .expect("include_target_in_component_name used in a targetless tarball"), + ); } let distdir = crate::dist::distdir(self.builder); @@ -222,12 +241,12 @@ impl<'a> Tarball<'a> { .arg(&distdir) .arg("--non-installed-overlay") .arg(self.overlay_dir) - .arg(format!("--package-name={}-{}", self.pkgname, self.target)) + .arg(format!("--package-name={}", package_name)) .arg("--legacy-manifest-dirs=rustlib,cargo") .arg(format!("--component-name={}", component_name)); self.builder.run(&mut cmd); t!(std::fs::remove_dir_all(&self.temp_dir)); - distdir.join(format!("{}-{}.tar.gz", self.pkgname, self.target)) + distdir.join(format!("{}.tar.gz", package_name)) } } |
