summary refs log tree commit diff
path: root/src/bootstrap/builder.rs
diff options
context:
space:
mode:
authorJoshua Nelson <jnelson@cloudflare.com>2022-05-03 13:29:37 -0500
committerJoshua Nelson <jnelson@cloudflare.com>2022-05-25 17:32:31 -0500
commit53bf24c82ba2102c84949ed2c2ed94fa972b4c2a (patch)
treef3053b7a8f1d7100f6ec458170e6a379ec52d3d6 /src/bootstrap/builder.rs
parent61dd278ade42a2d6d88f1c7b2bf2ee3ffab3b132 (diff)
downloadrust-53bf24c82ba2102c84949ed2c2ed94fa972b4c2a.tar.gz
rust-53bf24c82ba2102c84949ed2c2ed94fa972b4c2a.zip
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.
Diffstat (limited to 'src/bootstrap/builder.rs')
-rw-r--r--src/bootstrap/builder.rs15
1 files changed, 8 insertions, 7 deletions
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