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
This commit is contained in:
@@ -557,17 +557,22 @@ impl Build {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !submodule.path.exists() {
|
// `submodule.path` is the relative path to a submodule (from the repository root)
|
||||||
t!(fs::create_dir_all(&submodule.path));
|
// `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 {
|
match submodule.state {
|
||||||
State::MaybeDirty => {
|
State::MaybeDirty => {
|
||||||
// drop staged changes
|
// drop staged changes
|
||||||
self.run(git().current_dir(submodule.path)
|
self.run(git().current_dir(&submodule_path)
|
||||||
.args(&["reset", "--hard"]));
|
.args(&["reset", "--hard"]));
|
||||||
// drops unstaged changes
|
// drops unstaged changes
|
||||||
self.run(git().current_dir(submodule.path)
|
self.run(git().current_dir(&submodule_path)
|
||||||
.args(&["clean", "-fdx"]));
|
.args(&["clean", "-fdx"]));
|
||||||
},
|
},
|
||||||
State::NotInitialized => {
|
State::NotInitialized => {
|
||||||
@@ -577,9 +582,9 @@ impl Build {
|
|||||||
State::OutOfSync => {
|
State::OutOfSync => {
|
||||||
// drops submodule commits that weren't reported to the (outer) git repository
|
// drops submodule commits that weren't reported to the (outer) git repository
|
||||||
self.run(git_submodule().arg("update").arg(submodule.path));
|
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"]));
|
.args(&["reset", "--hard"]));
|
||||||
self.run(git().current_dir(submodule.path)
|
self.run(git().current_dir(&submodule_path)
|
||||||
.args(&["clean", "-fdx"]));
|
.args(&["clean", "-fdx"]));
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user