about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-10-01 23:53:35 -0700
committerGitHub <noreply@github.com>2016-10-01 23:53:35 -0700
commitfe36876ce144e6f30fa6d0d5647e54ade812b169 (patch)
tree064327333487e63af999ae348be9328c8502668b
parent7b33876fcc8f186b24a33459fd9d82bc8568fae2 (diff)
parent62fb242ad64ed97faaf61a8d2d13c237480d4bb5 (diff)
downloadrust-fe36876ce144e6f30fa6d0d5647e54ade812b169.tar.gz
rust-fe36876ce144e6f30fa6d0d5647e54ade812b169.zip
Auto merge of #36853 - TimNN:rustbuild-out-of-tree, r=alexcrichton
fix out-of-tree rustbuild

See https://github.com/rust-lang/rust/pull/36456#issuecomment-250589906

r? @alexcrichton
-rw-r--r--src/bootstrap/lib.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 033cefb8dea..b4f61605d47 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -557,17 +557,22 @@ impl Build {
                 continue
             }
 
-            if !submodule.path.exists() {
-                t!(fs::create_dir_all(&submodule.path));
-            }
+            // `submodule.path` is the relative path to a submodule (from the repository root)
+            // `submodule_path` is the path to a submodule from the cwd
+
+            // use `submodule.path` when e.g. executing a submodule specific command from the
+            // repository root
+            // use `submodule_path` when e.g. executing a normal git command for the submodule
+            // (set via `current_dir`)
+            let submodule_path = self.src.join(submodule.path);
 
             match submodule.state {
                 State::MaybeDirty => {
                     // drop staged changes
-                    self.run(git().current_dir(submodule.path)
+                    self.run(git().current_dir(&submodule_path)
                                   .args(&["reset", "--hard"]));
                     // drops unstaged changes
-                    self.run(git().current_dir(submodule.path)
+                    self.run(git().current_dir(&submodule_path)
                                   .args(&["clean", "-fdx"]));
                 },
                 State::NotInitialized => {
@@ -577,9 +582,9 @@ impl Build {
                 State::OutOfSync => {
                     // drops submodule commits that weren't reported to the (outer) git repository
                     self.run(git_submodule().arg("update").arg(submodule.path));
-                    self.run(git().current_dir(submodule.path)
+                    self.run(git().current_dir(&submodule_path)
                                   .args(&["reset", "--hard"]));
-                    self.run(git().current_dir(submodule.path)
+                    self.run(git().current_dir(&submodule_path)
                                   .args(&["clean", "-fdx"]));
                 },
             }