diff --git a/build_system/build_sysroot.rs b/build_system/build_sysroot.rs index 9988b35b363..fb34875f50f 100644 --- a/build_system/build_sysroot.rs +++ b/build_system/build_sysroot.rs @@ -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(); + } } } diff --git a/config.txt b/config.txt new file mode 100644 index 00000000000..f707b9322af --- /dev/null +++ b/config.txt @@ -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