about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-08-09 18:25:01 +0200
committerGitHub <noreply@github.com>2024-08-09 18:25:01 +0200
commitcea3b42f5848f1c8f676ee5830ff67aa50cd8099 (patch)
tree42df35380f272a19d6558a2d8dfe4e63f5bba588 /src/bootstrap
parent665a1a4b55560ceb61d77a4c2e2e52ea5cd63b53 (diff)
parenta380d5e8f68de64441274ca2e56dd3a08a60a121 (diff)
downloadrust-cea3b42f5848f1c8f676ee5830ff67aa50cd8099.tar.gz
rust-cea3b42f5848f1c8f676ee5830ff67aa50cd8099.zip
Rollup merge of #128874 - Kobzol:cmd-verbose-logging, r=onur-ozkan
Disable verbose bootstrap command failure logging by default

One of my recent bootstrap command refactoring PRs enabled verbose logging of command failures by default. While this is great for debugging bootstrap, in many situations it's just too verbose and prevents the user from seeing the actual printed stdout/stderr, which usually contains much more useful information.

This PR reverts that logic, and only prints a detailed error when `-v` is passed to bootstrap.

r? ````@onur-ozkan````
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/src/lib.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
index 453fb39327d..2062d435bfc 100644
--- a/src/bootstrap/src/lib.rs
+++ b/src/bootstrap/src/lib.rs
@@ -986,7 +986,8 @@ impl Build {
     }
 
     /// Execute a command and return its output.
-    /// This method should be used for all command executions in bootstrap.
+    /// Note: Ideally, you should use one of the BootstrapCommand::run* functions to
+    /// execute commands. They internally call this method.
     #[track_caller]
     fn run(
         &self,
@@ -1057,20 +1058,28 @@ Executed at: {executed_at}"#,
                 CommandOutput::did_not_start(stdout, stderr)
             }
         };
+
+        let fail = |message: &str| {
+            if self.is_verbose() {
+                println!("{message}");
+            } else {
+                println!("Command has failed. Rerun with -v to see more details.");
+            }
+            exit!(1);
+        };
+
         if !output.is_success() {
             match command.failure_behavior {
                 BehaviorOnFailure::DelayFail => {
                     if self.fail_fast {
-                        println!("{message}");
-                        exit!(1);
+                        fail(&message);
                     }
 
                     let mut failures = self.delayed_failures.borrow_mut();
                     failures.push(message);
                 }
                 BehaviorOnFailure::Exit => {
-                    println!("{message}");
-                    exit!(1);
+                    fail(&message);
                 }
                 BehaviorOnFailure::Ignore => {
                     // If failures are allowed, either the error has been printed already