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`.
This commit is contained in:
parent
8cffb475fd
commit
ff9c488344
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
@ -1,5 +1,3 @@
|
||||
use std::process::Command;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub enum CiEnv {
|
||||
/// Not a CI environment.
|
||||
@ -21,18 +19,6 @@ impl CiEnv {
|
||||
pub fn is_ci() -> bool {
|
||||
Self::current() != CiEnv::None
|
||||
}
|
||||
|
||||
/// If in a CI environment, forces the command to run with colors.
|
||||
pub fn force_coloring_in_ci(self, cmd: &mut Command) {
|
||||
if self != 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.
|
||||
cmd.env("TERM", "xterm").args(&["--color", "always"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod gha {
|
||||
|
Loading…
x
Reference in New Issue
Block a user