Skip to content

Commit

Permalink
Auto merge of #36853 - TimNN:rustbuild-out-of-tree, r=alexcrichton
Browse files Browse the repository at this point in the history
fix out-of-tree rustbuild

See #36456 (comment)

r? @alexcrichton
  • Loading branch information
bors authored Oct 2, 2016
2 parents 7b33876 + 62fb242 commit fe36876
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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"]));
},
}
Expand Down

0 comments on commit fe36876

Please sign in to comment.