From 53bf24c82ba2102c84949ed2c2ed94fa972b4c2a Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Tue, 3 May 2022 13:29:37 -0500 Subject: Move download-rustc from bootstrap.py to rustbuild - Remove download-rustc handling from bootstrap.py - Allow a custom `pattern` in `builder.unpack()` - Only download rustc once another part of bootstrap depends on it. This is somewhat necessary since the download functions rely on having a full `Builder`, which isn't available until after config parsing finishes. --- src/bootstrap/builder.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/bootstrap/builder.rs') diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a0ce200883d..94918cb318f 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -915,15 +915,12 @@ impl<'a> Builder<'a> { } } - pub(crate) fn unpack(&self, tarball: &Path, dst: &Path) { + pub(crate) fn unpack(&self, tarball: &Path, dst: &Path, pattern: &str) { println!("extracting {} to {}", tarball.display(), dst.display()); if !dst.exists() { t!(fs::create_dir_all(dst)); } - // FIXME: will need to be a parameter once `download-rustc` is moved to rustbuild - const MATCH: &str = "rust-dev"; - // `tarball` ends with `.tar.xz`; strip that suffix // example: `rust-dev-nightly-x86_64-unknown-linux-gnu` let uncompressed_filename = @@ -943,10 +940,10 @@ impl<'a> Builder<'a> { continue; } let mut short_path = t!(original_path.strip_prefix(directory_prefix)); - if !short_path.starts_with(MATCH) { + if !short_path.starts_with(pattern) { continue; } - short_path = t!(short_path.strip_prefix(MATCH)); + short_path = t!(short_path.strip_prefix(pattern)); let dst_path = dst.join(short_path); self.verbose(&format!("extracting {} to {}", original_path.display(), dst.display())); if !t!(member.unpack_in(dst)) { @@ -1022,7 +1019,7 @@ impl<'a> Builder<'a> { .join("lib"); // Avoid deleting the rustlib/ directory we just copied // (in `impl Step for Sysroot`). - if !builder.config.download_rustc { + if !builder.download_rustc() { let _ = fs::remove_dir_all(&sysroot); t!(fs::create_dir_all(&sysroot)); } @@ -1179,6 +1176,10 @@ impl<'a> Builder<'a> { Config::llvm_link_shared(self) } + pub(crate) fn download_rustc(&self) -> bool { + Config::download_rustc(self) + } + /// Prepares an invocation of `cargo` to be run. /// /// This will create a `Command` that represents a pending execution of -- cgit 1.4.1-3-g733a5