Skip to content

Commit 5e97a39

Browse files
committed
Make sure the target dir is always explicitly set when using cargo
1 parent 450257c commit 5e97a39

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

build_system/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,15 @@ pub(crate) enum SysrootKind {
4848
pub fn main() {
4949
env::set_var("CG_CLIF_DISPLAY_CG_TIME", "1");
5050
env::set_var("CG_CLIF_DISABLE_INCR_CACHE", "1");
51-
// The target dir is expected in the default location. Guard against the user changing it.
52-
env::set_var("CARGO_TARGET_DIR", "target");
51+
52+
{
53+
// Make sure we always explicitly specify the target dir
54+
let target = "build/target_dir_should_be_set_explicitly";
55+
env::set_var("CARGO_TARGET_DIR", target);
56+
std::fs::create_dir_all("build").unwrap();
57+
let _ = std::fs::remove_file(target);
58+
let file = std::fs::File::create(target).unwrap();
59+
}
5360

5461
if is_ci() {
5562
// Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway

0 commit comments

Comments
 (0)