Skip to content

Commit 0d6b3da

Browse files
committed
Allow preserving the old sysroot
1 parent ad971bb commit 0d6b3da

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

build_system/build_sysroot.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ pub(crate) fn build_sysroot(
121121
fn build_clif_sysroot_for_triple(channel: &str, target_dir: &Path, triple: &str) {
122122
let build_dir = Path::new("build_sysroot").join("target").join(triple).join(channel);
123123

124-
// FIXME add option to skip this
125-
// Cleanup the target dir with the exception of build scripts and the incremental cache
126-
for dir in ["build", "deps", "examples", "native"] {
127-
if build_dir.join(dir).exists() {
128-
fs::remove_dir_all(build_dir.join(dir)).unwrap();
124+
let keep_sysroot =
125+
fs::read_to_string("config.txt").unwrap().lines().any(|line| line.trim() == "keep_sysroot");
126+
if !keep_sysroot {
127+
// Cleanup the target dir with the exception of build scripts and the incremental cache
128+
for dir in ["build", "deps", "examples", "native"] {
129+
if build_dir.join(dir).exists() {
130+
fs::remove_dir_all(build_dir.join(dir)).unwrap();
131+
}
129132
}
130133
}
131134

config.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file allows configuring the build system.
2+
3+
# Disables cleaning of the sysroot dir. This will cause old compiled artifacts to be re-used when
4+
# the sysroot source hasn't changed. This is useful when the codegen backend hasn't been modified.
5+
# This option can be changed while the build system is already running for as long as sysroot
6+
# building hasn't started yet.
7+
#keep_sysroot

0 commit comments

Comments
 (0)