Disable incr comp globally on CI

This commit is contained in:
bjorn3 2022-08-05 12:57:19 +00:00
parent 41d547892c
commit e7bc81cc77
3 changed files with 15 additions and 4 deletions

View File

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

View File

@ -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") => {

View File

@ -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")
}