about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-04-07 09:20:04 -0400
committerGitHub <noreply@github.com>2017-04-07 09:20:04 -0400
commitef9eee74026bb00b75c45f31a692052855ae7e8a (patch)
tree2f6502c7009a28e7244415df2a1e9dd3183d2146 /src/bootstrap
parentd860b1c0039eca3f013362a6f59b59d27c3e51dc (diff)
parent4d32ff4e498c391d65b44d26cfb453651dc3da7b (diff)
downloadrust-ef9eee74026bb00b75c45f31a692052855ae7e8a.tar.gz
rust-ef9eee74026bb00b75c45f31a692052855ae7e8a.zip
Rollup merge of #41047 - cuviper:src_is_git, r=alexcrichton
Only use cargo-vendor if building from git sources

The only time we need to vendor sources is when building from git.  If one is
building from a rustc source tarball, everything should already be in place.
This also matters for distros which do offline builds, as they can't install
cargo-vendor this way.

This adds a common `Build::src_is_git` flag, and then uses it in the dist-src
target to decide whether to install or use `cargo-vendor` at all.

Fixes #41042.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/dist.rs41
-rw-r--r--src/bootstrap/lib.rs8
-rw-r--r--src/bootstrap/sanity.rs2
3 files changed, 27 insertions, 24 deletions
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index ec992b47a6e..6472b1a928c 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -433,29 +433,32 @@ pub fn rust_src(build: &Build) {
         copy(&build.src.join(item), &dst_src.join(item));
     }
 
-    // Get cargo-vendor installed, if it isn't already.
-    let mut has_cargo_vendor = false;
-    let mut cmd = Command::new(&build.cargo);
-    for line in output(cmd.arg("install").arg("--list")).lines() {
-        has_cargo_vendor |= line.starts_with("cargo-vendor ");
-    }
-    if !has_cargo_vendor {
+    // If we're building from git sources, we need to vendor a complete distribution.
+    if build.src_is_git {
+        // Get cargo-vendor installed, if it isn't already.
+        let mut has_cargo_vendor = false;
+        let mut cmd = Command::new(&build.cargo);
+        for line in output(cmd.arg("install").arg("--list")).lines() {
+            has_cargo_vendor |= line.starts_with("cargo-vendor ");
+        }
+        if !has_cargo_vendor {
+            let mut cmd = Command::new(&build.cargo);
+            cmd.arg("install")
+               .arg("--force")
+               .arg("--debug")
+               .arg("--vers").arg(CARGO_VENDOR_VERSION)
+               .arg("cargo-vendor")
+               .env("RUSTC", &build.rustc);
+            build.run(&mut cmd);
+        }
+
+        // Vendor all Cargo dependencies
         let mut cmd = Command::new(&build.cargo);
-        cmd.arg("install")
-           .arg("--force")
-           .arg("--debug")
-           .arg("--vers").arg(CARGO_VENDOR_VERSION)
-           .arg("cargo-vendor")
-           .env("RUSTC", &build.rustc);
+        cmd.arg("vendor")
+           .current_dir(&dst_src.join("src"));
         build.run(&mut cmd);
     }
 
-    // Vendor all Cargo dependencies
-    let mut cmd = Command::new(&build.cargo);
-    cmd.arg("vendor")
-       .current_dir(&dst_src.join("src"));
-    build.run(&mut cmd);
-
     // Create source tarball in rust-installer format
     let mut cmd = Command::new(SH_CMD);
     cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 84254d7d6ae..8303a40bb69 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -162,6 +162,7 @@ pub struct Build {
     cxx: HashMap<String, gcc::Tool>,
     crates: HashMap<String, Crate>,
     is_sudo: bool,
+    src_is_git: bool,
 }
 
 #[derive(Debug)]
@@ -233,6 +234,7 @@ impl Build {
         };
         let rust_info = channel::GitInfo::new(&src);
         let cargo_info = channel::GitInfo::new(&src.join("cargo"));
+        let src_is_git = src.join(".git").exists();
 
         Build {
             flags: flags,
@@ -251,6 +253,7 @@ impl Build {
             lldb_version: None,
             lldb_python_dir: None,
             is_sudo: is_sudo,
+            src_is_git: src_is_git,
         }
     }
 
@@ -307,10 +310,7 @@ impl Build {
             OutOfSync,
         }
 
-        if !self.config.submodules {
-            return
-        }
-        if fs::metadata(self.src.join(".git")).is_err() {
+        if !self.src_is_git || !self.config.submodules {
             return
         }
         let git = || {
diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
index 235ce9360ef..d1b235f4691 100644
--- a/src/bootstrap/sanity.rs
+++ b/src/bootstrap/sanity.rs
@@ -65,7 +65,7 @@ pub fn check(build: &mut Build) {
 
     // If we've got a git directory we're gona need git to update
     // submodules and learn about various other aspects.
-    if fs::metadata(build.src.join(".git")).is_ok() {
+    if build.src_is_git {
         need_cmd("git".as_ref());
     }