about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--build_system/mod.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/build_system/mod.rs b/build_system/mod.rs
index 531f42cf873..ef1109afe0a 100644
--- a/build_system/mod.rs
+++ b/build_system/mod.rs
@@ -48,8 +48,15 @@ pub(crate) enum SysrootKind {
 pub fn main() {
     env::set_var("CG_CLIF_DISPLAY_CG_TIME", "1");
     env::set_var("CG_CLIF_DISABLE_INCR_CACHE", "1");
-    // The target dir is expected in the default location. Guard against the user changing it.
-    env::set_var("CARGO_TARGET_DIR", "target");
+
+    {
+        // Make sure we always explicitly specify the target dir
+        let target = "build/target_dir_should_be_set_explicitly";
+        env::set_var("CARGO_TARGET_DIR", target);
+        std::fs::create_dir_all("build").unwrap();
+        let _ = std::fs::remove_file(target);
+        let file = std::fs::File::create(target).unwrap();
+    }
 
     if is_ci() {
         // Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway