Allow preserving the old sysroot

This commit is contained in:
bjorn3 2021-06-18 13:35:58 +02:00
parent ad971bbed7
commit 0d6b3dab65
2 changed files with 15 additions and 5 deletions

View File

@ -121,11 +121,14 @@ pub(crate) fn build_sysroot(
fn build_clif_sysroot_for_triple(channel: &str, target_dir: &Path, triple: &str) {
let build_dir = Path::new("build_sysroot").join("target").join(triple).join(channel);
// FIXME add option to skip this
// Cleanup the target dir with the exception of build scripts and the incremental cache
for dir in ["build", "deps", "examples", "native"] {
if build_dir.join(dir).exists() {
fs::remove_dir_all(build_dir.join(dir)).unwrap();
let keep_sysroot =
fs::read_to_string("config.txt").unwrap().lines().any(|line| line.trim() == "keep_sysroot");
if !keep_sysroot {
// Cleanup the target dir with the exception of build scripts and the incremental cache
for dir in ["build", "deps", "examples", "native"] {
if build_dir.join(dir).exists() {
fs::remove_dir_all(build_dir.join(dir)).unwrap();
}
}
}

7
config.txt Normal file
View File

@ -0,0 +1,7 @@
# This file allows configuring the build system.
# Disables cleaning of the sysroot dir. This will cause old compiled artifacts to be re-used when
# the sysroot source hasn't changed. This is useful when the codegen backend hasn't been modified.
# This option can be changed while the build system is already running for as long as sysroot
# building hasn't started yet.
#keep_sysroot