Skip to content

Commit e59fb6d

Browse files
committed
Only use cargo-vendor if building from git sources
1 parent 06ad8e4 commit e59fb6d

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

Diff for: src/bootstrap/dist.rs

+22-19
Original file line numberDiff line numberDiff line change
@@ -437,29 +437,32 @@ pub fn rust_src(build: &Build) {
437437
copy(&build.src.join(item), &dst_src.join(item));
438438
}
439439

440-
// Get cargo-vendor installed, if it isn't already.
441-
let mut has_cargo_vendor = false;
442-
let mut cmd = Command::new(&build.cargo);
443-
for line in output(cmd.arg("install").arg("--list")).lines() {
444-
has_cargo_vendor |= line.starts_with("cargo-vendor ");
445-
}
446-
if !has_cargo_vendor {
440+
// If we're building from git sources, we need to vendor a complete distribution.
441+
if build.src_is_git {
442+
// Get cargo-vendor installed, if it isn't already.
443+
let mut has_cargo_vendor = false;
444+
let mut cmd = Command::new(&build.cargo);
445+
for line in output(cmd.arg("install").arg("--list")).lines() {
446+
has_cargo_vendor |= line.starts_with("cargo-vendor ");
447+
}
448+
if !has_cargo_vendor {
449+
let mut cmd = Command::new(&build.cargo);
450+
cmd.arg("install")
451+
.arg("--force")
452+
.arg("--debug")
453+
.arg("--vers").arg(CARGO_VENDOR_VERSION)
454+
.arg("cargo-vendor")
455+
.env("RUSTC", &build.rustc);
456+
build.run(&mut cmd);
457+
}
458+
459+
// Vendor all Cargo dependencies
447460
let mut cmd = Command::new(&build.cargo);
448-
cmd.arg("install")
449-
.arg("--force")
450-
.arg("--debug")
451-
.arg("--vers").arg(CARGO_VENDOR_VERSION)
452-
.arg("cargo-vendor")
453-
.env("RUSTC", &build.rustc);
461+
cmd.arg("vendor")
462+
.current_dir(&dst_src.join("src"));
454463
build.run(&mut cmd);
455464
}
456465

457-
// Vendor all Cargo dependencies
458-
let mut cmd = Command::new(&build.cargo);
459-
cmd.arg("vendor")
460-
.current_dir(&dst_src.join("src"));
461-
build.run(&mut cmd);
462-
463466
// Create source tarball in rust-installer format
464467
let mut cmd = Command::new(SH_CMD);
465468
cmd.arg(sanitize_sh(&build.src.join("src/rust-installer/gen-installer.sh")))

Diff for: src/bootstrap/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub struct Build {
162162
cxx: HashMap<String, gcc::Tool>,
163163
crates: HashMap<String, Crate>,
164164
is_sudo: bool,
165+
src_is_git: bool,
165166
}
166167

167168
#[derive(Debug)]
@@ -233,6 +234,7 @@ impl Build {
233234
};
234235
let rust_info = channel::GitInfo::new(&src);
235236
let cargo_info = channel::GitInfo::new(&src.join("cargo"));
237+
let src_is_git = src.join(".git").exists();
236238

237239
Build {
238240
flags: flags,
@@ -251,6 +253,7 @@ impl Build {
251253
lldb_version: None,
252254
lldb_python_dir: None,
253255
is_sudo: is_sudo,
256+
src_is_git: src_is_git,
254257
}
255258
}
256259

@@ -307,10 +310,7 @@ impl Build {
307310
OutOfSync,
308311
}
309312

310-
if !self.config.submodules {
311-
return
312-
}
313-
if fs::metadata(self.src.join(".git")).is_err() {
313+
if !self.src_is_git || !self.config.submodules {
314314
return
315315
}
316316
let git = || {

Diff for: src/bootstrap/sanity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn check(build: &mut Build) {
6565

6666
// If we've got a git directory we're gona need git to update
6767
// submodules and learn about various other aspects.
68-
if fs::metadata(build.src.join(".git")).is_ok() {
68+
if build.src_is_git {
6969
need_cmd("git".as_ref());
7070
}
7171

0 commit comments

Comments
 (0)