Make sure the target dir is always explicitly set when using cargo

This commit is contained in:
bjorn3 2022-11-28 15:15:40 +00:00
parent 450257c4c6
commit 5e97a3951d

View File

@ -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