Make sure to clear out the stageN-{rustc,std,tools} directories.

We copy built tool binaries into a dedicated directory to avoid deleting
them, stageN-tools-bin. These aren't ever cleared out by code, since
there should be no reason to do so, and we'll simply overwrite them as
necessary.

When clearing out the stageN-{std,rustc,tools} directories, make sure to
delete both Cargo directories -- per-target and build scripts. This
ensures that changing libstd doesn't cause problems due to build scripts
not being rebuilt, even though they should be.
This commit is contained in:
Mark Simulacrum
2017-10-16 11:40:47 -06:00
parent b7960878ba
commit 0fcd3e7b07
5 changed files with 72 additions and 31 deletions

View File

@@ -385,16 +385,19 @@ impl Build {
/// Clear out `dir` if `input` is newer.
///
/// After this executes, it will also ensure that `dir` exists.
fn clear_if_dirty(&self, dir: &Path, input: &Path) {
fn clear_if_dirty(&self, dir: &Path, input: &Path) -> bool {
let stamp = dir.join(".stamp");
let mut cleared = false;
if mtime(&stamp) < mtime(input) {
self.verbose(&format!("Dirty - {}", dir.display()));
let _ = fs::remove_dir_all(dir);
cleared = true;
} else if stamp.exists() {
return
return cleared;
}
t!(fs::create_dir_all(dir));
t!(File::create(stamp));
cleared
}
/// Get the space-separated set of activated features for the standard
@@ -435,6 +438,12 @@ impl Build {
if self.config.rust_optimize {"release"} else {"debug"}
}
fn tools_dir(&self, compiler: Compiler) -> PathBuf {
let out = self.out.join(&*compiler.host).join(format!("stage{}-tools-bin", compiler.stage));
t!(fs::create_dir_all(&out));
out
}
/// Get the directory for incremental by-products when using the
/// given compiler.
fn incremental_dir(&self, compiler: Compiler) -> PathBuf {