mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 01:28:18 +03:00
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:
committed by
Jakub Beránek
parent
8cffb475fd
commit
ff9c488344
@@ -2095,9 +2095,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);
|
||||
|
||||
// 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 @@ fn cargo(
|
||||
// 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 @@ pub fn mark_as_executed(&mut self) {
|
||||
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 @@ pub fn current() -> 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 {
|
||||
|
||||
Reference in New Issue
Block a user