From 06d64ea4c413c94e158a167020b4a5fb57958710 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Mon, 29 Jul 2024 16:31:21 +0300 Subject: [PATCH] simplify the use of `CiEnv` Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/test.rs | 2 +- src/bootstrap/src/core/builder.rs | 2 +- src/bootstrap/src/core/config/config.rs | 2 +- src/bootstrap/src/lib.rs | 4 +--- src/bootstrap/src/utils/exec.rs | 4 ++-- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 79b7dd78810..aa0c76ab157 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2087,7 +2087,7 @@ fn run(self, builder: &Builder<'_>) { let git_config = builder.config.git_config(); cmd.arg("--git-repository").arg(git_config.git_repository); cmd.arg("--nightly-branch").arg(git_config.nightly_branch); - cmd.force_coloring_in_ci(builder.ci_env); + cmd.force_coloring_in_ci(); #[cfg(feature = "build-metrics")] builder.metrics.begin_test_suite( diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 9eb4ca033a8..84c23c059e9 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -2157,7 +2157,7 @@ fn cargo( // Try to use a sysroot-relative bindir, in case it was configured absolutely. cargo.env("RUSTC_INSTALL_BINDIR", self.config.bindir_relative()); - cargo.force_coloring_in_ci(self.ci_env); + cargo.force_coloring_in_ci(); // When we build Rust dylibs they're all intended for intermediate // usage, so make sure we pass the -Cprefer-dynamic flag instead of diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index b0a967d756b..1343e257efe 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2092,7 +2092,7 @@ fn get_table(option: &str) -> Result { // CI should always run stage 2 builds, unless it specifically states otherwise #[cfg(not(test))] - if flags.stage.is_none() && crate::CiEnv::current() != crate::CiEnv::None { + if flags.stage.is_none() && build_helper::ci::CiEnv::is_ci() { match config.cmd { Subcommand::Test { .. } | Subcommand::Miri { .. } diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index d2f5d166718..453fb39327d 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -26,7 +26,7 @@ use std::time::SystemTime; use std::{env, io, str}; -use build_helper::ci::{gha, CiEnv}; +use build_helper::ci::gha; use build_helper::exit; use sha2::digest::Digest; use termcolor::{ColorChoice, StandardStream, WriteColor}; @@ -168,7 +168,6 @@ pub struct Build { crates: HashMap, crate_paths: HashMap, is_sudo: bool, - ci_env: CiEnv, delayed_failures: RefCell>, prerelease_version: Cell>, @@ -400,7 +399,6 @@ pub fn new(mut config: Config) -> Build { crates: HashMap::new(), crate_paths: HashMap::new(), is_sudo, - ci_env: CiEnv::current(), delayed_failures: RefCell::new(Vec::new()), prerelease_version: Cell::new(None), diff --git a/src/bootstrap/src/utils/exec.rs b/src/bootstrap/src/utils/exec.rs index e1387bbbd35..9f0d0b7e969 100644 --- a/src/bootstrap/src/utils/exec.rs +++ b/src/bootstrap/src/utils/exec.rs @@ -175,8 +175,8 @@ pub fn get_created_location(&self) -> std::panic::Location<'static> { } /// If in a CI environment, forces the command to run with colors. - pub fn force_coloring_in_ci(&mut self, ci_env: CiEnv) { - if ci_env != CiEnv::None { + pub fn force_coloring_in_ci(&mut self) { + if CiEnv::is_ci() { // Due to use of stamp/docker, the output stream of bootstrap is not // a TTY in CI, so coloring is by-default turned off. // The explicit `TERM=xterm` environment is needed for