From 39cf1da81c73e9bcd7b60dad927cbe1f360bc1f3 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Tue, 27 Jun 2017 13:49:21 -0600 Subject: [PATCH] Store verbosity on Build Prevents accidental mistakes in not using the right verbosity by going to only config or flags. --- src/bootstrap/check.rs | 2 +- src/bootstrap/flags.rs | 10 ---------- src/bootstrap/lib.rs | 17 +++++++++++++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 1ee33c1f4657..a06d925e2ef8 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -249,7 +249,7 @@ pub fn compiletest(build: &Build, cmd.args(&build.flags.cmd.test_args()); - if build.config.verbose() || build.flags.verbose() { + if build.is_verbose() { cmd.arg("--verbose"); } diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs index 593b06517585..5804df34e8b3 100644 --- a/src/bootstrap/flags.rs +++ b/src/bootstrap/flags.rs @@ -41,16 +41,6 @@ pub struct Flags { pub incremental: bool, } -impl Flags { - pub fn verbose(&self) -> bool { - self.verbose > 0 - } - - pub fn very_verbose(&self) -> bool { - self.verbose > 1 - } -} - pub enum Subcommand { Build { paths: Vec, diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 978e1d2be162..be28975c3ea3 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -168,6 +168,7 @@ pub struct Build { rls_info: channel::GitInfo, local_rebuild: bool, fail_fast: bool, + verbosity: usize, // Stage 0 (downloaded) compiler and cargo or their local rust equivalents. initial_rustc: PathBuf, @@ -247,6 +248,7 @@ pub fn new(flags: Flags, config: Config) -> Build { initial_cargo: config.initial_cargo.clone(), local_rebuild: config.local_rebuild, fail_fast: flags.cmd.fail_fast(), + verbosity: cmp::max(flags.verbose, config.verbose), flags: flags, config: config, @@ -428,8 +430,7 @@ fn cargo(&self, cargo.env("RUSTC_ON_FAIL", on_fail); } - let verbose = cmp::max(self.config.verbose, self.flags.verbose); - cargo.env("RUSTC_VERBOSE", format!("{}", verbose)); + cargo.env("RUSTC_VERBOSE", format!("{}", self.verbosity)); // Specify some various options for build scripts used throughout // the build. @@ -467,7 +468,7 @@ fn cargo(&self, // FIXME: should update code to not require this env var cargo.env("CFG_COMPILER_HOST_TRIPLE", target); - if self.config.verbose() || self.flags.verbose() { + if self.is_verbose() { cargo.arg("-v"); } // FIXME: cargo bench does not accept `--release` @@ -779,9 +780,17 @@ fn try_run_quiet(&self, cmd: &mut Command) -> bool { try_run_suppressed(cmd) } + pub fn is_verbose(&self) -> bool { + self.verbosity > 0 + } + + pub fn is_very_verbose(&self) -> bool { + self.verbosity > 1 + } + /// Prints a message if this build is configured in verbose mode. fn verbose(&self, msg: &str) { - if self.flags.verbose() || self.config.verbose() { + if self.is_verbose() { println!("{}", msg); } }