diff options
| author | Jakub Beránek <jakub.beranek@vsb.cz> | 2024-07-07 17:16:44 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2024-07-15 20:07:57 +0200 |
| commit | ff9c4883449ff895942398be656e260891755e4a (patch) | |
| tree | fff1ad1beecf16d71389a1d1f3e9097eefab8217 /src/bootstrap | |
| parent | 8cffb475fd490785ea44367d91161aba9b98a490 (diff) | |
| download | rust-ff9c4883449ff895942398be656e260891755e4a.tar.gz rust-ff9c4883449ff895942398be656e260891755e4a.zip | |
Move `force_coloring_in_ci` from `builder_helper` to `bootstrap`
It was only used in bootstrap. This move allows us to modify the function to work with `BootstrapCommand`, rather than `Command`.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/core/build_steps/test.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/src/core/builder.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/exec.rs | 13 |
3 files changed, 15 insertions, 4 deletions
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 118b6b876ed..3f0cbde64e3 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2095,9 +2095,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the 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); - - // FIXME: Move CiEnv back to bootstrap, it is only used here anyway - builder.ci_env.force_coloring_in_ci(cmd.as_command_mut()); + cmd.force_coloring_in_ci(builder.ci_env); #[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 aeb34743608..08308dbbf73 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -2105,7 +2105,7 @@ impl<'a> Builder<'a> { // Try to use a sysroot-relative bindir, in case it was configured absolutely. cargo.env("RUSTC_INSTALL_BINDIR", self.config.bindir_relative()); - self.ci_env.force_coloring_in_ci(cargo.as_command_mut()); + cargo.force_coloring_in_ci(self.ci_env); // 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/utils/exec.rs b/src/bootstrap/src/utils/exec.rs index b0530164997..a60c0084f3d 100644 --- a/src/bootstrap/src/utils/exec.rs +++ b/src/bootstrap/src/utils/exec.rs @@ -1,4 +1,5 @@ use crate::Build; +use build_helper::ci::CiEnv; use build_helper::drop_bomb::DropBomb; use std::ffi::OsStr; use std::fmt::{Debug, Formatter}; @@ -171,6 +172,18 @@ impl BootstrapCommand { pub fn get_created_location(&self) -> std::panic::Location<'static> { self.drop_bomb.get_created_location() } + + /// 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 { + // 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 + // `--color always` to actually work. This env var was lost when + // compiling through the Makefile. Very strange. + self.env("TERM", "xterm").args(["--color", "always"]); + } + } } impl Debug for BootstrapCommand { |
