Skip to content

Commit 0e7dc32

Browse files
committed
Inline BootstrapCommand::force_coloring_in_ci into its only call site
This logic is cargo-specific anyway, so there is no need for it to be a generally-available helper method.
1 parent 3f63f52 commit 0e7dc32

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use std::env;
22
use std::ffi::{OsStr, OsString};
33
use std::path::{Path, PathBuf};
44

5+
use build_helper::ci::CiEnv;
6+
57
use super::{Builder, Kind};
68
use crate::core::build_steps::test;
79
use crate::core::build_steps::tool::SourceType;
@@ -1334,7 +1336,13 @@ impl Builder<'_> {
13341336
// Try to use a sysroot-relative bindir, in case it was configured absolutely.
13351337
cargo.env("RUSTC_INSTALL_BINDIR", self.config.bindir_relative());
13361338

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+
};
13381346

13391347
// When we build Rust dylibs they're all intended for intermediate
13401348
// usage, so make sure we pass the -Cprefer-dynamic flag instead of

src/bootstrap/src/utils/exec.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use std::process::{
2121
use std::sync::{Arc, Mutex};
2222
use std::time::{Duration, Instant};
2323

24-
use build_helper::ci::CiEnv;
2524
use build_helper::drop_bomb::DropBomb;
2625
use build_helper::exit;
2726

@@ -390,18 +389,6 @@ impl<'a> BootstrapCommand {
390389
self.drop_bomb.get_created_location()
391390
}
392391

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-
405392
pub fn fingerprint(&self) -> CommandFingerprint {
406393
let command = &self.command;
407394
CommandFingerprint {

0 commit comments

Comments
 (0)