about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-06-18 13:35:58 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2021-06-19 13:58:32 +0200
commit0d6b3dab658d76078741cc78b0bda1682b43a7ec (patch)
tree0aba04e697fb01b828fe7d696ca1147a0c64e79a
parentad971bbed773cad7cb446b49b07c64504e9a79fb (diff)
downloadrust-0d6b3dab658d76078741cc78b0bda1682b43a7ec.tar.gz
rust-0d6b3dab658d76078741cc78b0bda1682b43a7ec.zip
Allow preserving the old sysroot
-rw-r--r--build_system/build_sysroot.rs13
-rw-r--r--config.txt7
2 files changed, 15 insertions, 5 deletions
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