about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-08-05 12:57:19 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-08-05 12:57:19 +0000
commite7bc81cc772b37757077f6b0574eeb5382af3ac4 (patch)
tree462034c0c547933572b19f09c5ce184fb1b37ca4
parent41d547892c03a34b32666f9c629147742fae579f (diff)
downloadrust-e7bc81cc772b37757077f6b0574eeb5382af3ac4.tar.gz
rust-e7bc81cc772b37757077f6b0574eeb5382af3ac4.zip
Disable incr comp globally on CI
-rw-r--r--build_system/build_backend.rs7
-rw-r--r--build_system/mod.rs7
-rw-r--r--build_system/utils.rs5
3 files changed, 15 insertions, 4 deletions
diff --git a/build_system/build_backend.rs b/build_system/build_backend.rs
index 48faec8bc4b..cf04967222f 100644
--- a/build_system/build_backend.rs
+++ b/build_system/build_backend.rs
@@ -2,6 +2,8 @@ use std::env;
 use std::path::{Path, PathBuf};
 use std::process::Command;
 
+use super::utils::is_ci;
+
 pub(crate) fn build_backend(
     channel: &str,
     host_triple: &str,
@@ -14,12 +16,9 @@ pub(crate) fn build_backend(
 
     let mut rustflags = env::var("RUSTFLAGS").unwrap_or_default();
 
-    if env::var("CI").as_ref().map(|val| &**val) == Ok("true") {
+    if is_ci() {
         // Deny warnings on CI
         rustflags += " -Dwarnings";
-
-        // Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
-        cmd.env("CARGO_BUILD_INCREMENTAL", "false");
     }
 
     if use_unstable_features {
diff --git a/build_system/mod.rs b/build_system/mod.rs
index 8c7d05993a5..88c4150dbba 100644
--- a/build_system/mod.rs
+++ b/build_system/mod.rs
@@ -2,6 +2,8 @@ use std::env;
 use std::path::PathBuf;
 use std::process;
 
+use self::utils::is_ci;
+
 mod build_backend;
 mod build_sysroot;
 mod config;
@@ -48,6 +50,11 @@ pub fn main() {
     // The target dir is expected in the default location. Guard against the user changing it.
     env::set_var("CARGO_TARGET_DIR", "target");
 
+    if is_ci() {
+        // Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway
+        env::set_var("CARGO_BUILD_INCREMENTAL", "false");
+    }
+
     let mut args = env::args().skip(1);
     let command = match args.next().as_deref() {
         Some("prepare") => {
diff --git a/build_system/utils.rs b/build_system/utils.rs
index 3282778e254..bdf8f8ecd99 100644
--- a/build_system/utils.rs
+++ b/build_system/utils.rs
@@ -1,3 +1,4 @@
+use std::env;
 use std::fs;
 use std::io::Write;
 use std::path::Path;
@@ -55,3 +56,7 @@ pub(crate) fn copy_dir_recursively(from: &Path, to: &Path) {
         }
     }
 }
+
+pub(crate) fn is_ci() -> bool {
+    env::var("CI").as_ref().map(|val| &**val) == Ok("true")
+}