Inline BootstrapCommand::force_coloring_in_ci into its only call site · rust-lang/rust@0e7dc32 (original) (raw)

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@ use std::env;
2 2 use std::ffi::{OsStr, OsString};
3 3 use std::path::{Path, PathBuf};
4 4
5 +use build_helper::ci::CiEnv;
6 +
5 7 use super::{Builder, Kind};
6 8 use crate::core::build_steps::test;
7 9 use crate::core::build_steps::tool::SourceType;
@@ -1334,7 +1336,13 @@ impl Builder<'_> {
1334 1336 // Try to use a sysroot-relative bindir, in case it was configured absolutely.
1335 1337 cargo.env("RUSTC_INSTALL_BINDIR", self.config.bindir_relative());
1336 1338
1337 - cargo.force_coloring_in_ci();
1339 +if CiEnv::is_ci() {
1340 +// Tell cargo to use colored output for nicer logs in CI, even
1341 +// though CI isn't printing to a terminal.
1342 +// Also set an explicit `TERM=xterm` so that cargo doesn't warn
1343 +// about TERM not being set.
1344 + cargo.env("TERM", "xterm").args(["--color=always"]);
1345 +};
1338 1346
1339 1347 // When we build Rust dylibs they're all intended for intermediate
1340 1348 // usage, so make sure we pass the -Cprefer-dynamic flag instead of
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ use std::process::{
21 21 use std::sync::{Arc, Mutex};
22 22 use std::time::{Duration, Instant};
23 23
24 -use build_helper::ci::CiEnv;
25 24 use build_helper::drop_bomb::DropBomb;
26 25 use build_helper::exit;
27 26
@@ -390,18 +389,6 @@ impl<'a> BootstrapCommand {
390 389 self.drop_bomb.get_created_location()
391 390 }
392 391
393 -/// If in a CI environment, forces the command to run with colors.
394 - pub fn force_coloring_in_ci(&mut self) {
395 -if CiEnv::is_ci() {
396 -// Due to use of stamp/docker, the output stream of bootstrap is not
397 -// a TTY in CI, so coloring is by-default turned off.
398 -// The explicit `TERM=xterm` environment is needed for
399 -// `--color always` to actually work. This env var was lost when
400 -// compiling through the Makefile. Very strange.
401 -self.env("TERM", "xterm").args(["--color", "always"]);
402 -}
403 -}
404 -
405 392 pub fn fingerprint(&self) -> CommandFingerprint {
406 393 let command = &self.command;
407 394 CommandFingerprint {