File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed
tools/build_helper/src/drop_bomb Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -937,13 +937,19 @@ impl Build {
937937
938938 /// Execute a command and return its output.
939939 /// This method should be used for all command executions in bootstrap.
940+ #[ track_caller]
940941 fn run ( & self , command : & mut BootstrapCommand ) -> CommandOutput {
941942 command. mark_as_executed ( ) ;
942943 if self . config . dry_run ( ) && !command. run_always {
943944 return CommandOutput :: default ( ) ;
944945 }
945946
946- self . verbose ( || println ! ( "running: {command:?}" ) ) ;
947+ let created_at = command. get_created_location ( ) ;
948+ let executed_at = std:: panic:: Location :: caller ( ) ;
949+
950+ self . verbose ( || {
951+ println ! ( "running: {command:?} (created at {created_at}, executed at {executed_at})" )
952+ } ) ;
947953
948954 let stdout = command. stdout . stdio ( ) ;
949955 command. as_command_mut ( ) . stdout ( stdout) ;
@@ -962,8 +968,11 @@ impl Build {
962968 Ok ( output) => {
963969 writeln ! (
964970 message,
965- "\n \n Command {command:?} did not execute successfully.\
966- \n Expected success, got: {}",
971+ r#"
972+ Command {command:?} did not execute successfully.
973+ Expected success, got {}
974+ Created at: {created_at}
975+ Executed at: {executed_at}"# ,
967976 output. status,
968977 )
969978 . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -160,17 +160,23 @@ impl BootstrapCommand {
160160 & mut self . command
161161 }
162162
163- /// Mark the command as being executd , disarming the drop bomb.
163+ /// Mark the command as being executed , disarming the drop bomb.
164164 /// If this method is not called before the command is dropped, its drop will panic.
165165 pub fn mark_as_executed ( & mut self ) {
166166 self . drop_bomb . defuse ( ) ;
167167 }
168+
169+ /// Returns the source code location where this command was created.
170+ pub fn get_created_location ( & self ) -> std:: panic:: Location < ' static > {
171+ self . drop_bomb . get_created_location ( )
172+ }
168173}
169174
170175impl From < Command > for BootstrapCommand {
171176 #[ track_caller]
172177 fn from ( command : Command ) -> Self {
173178 let program = command. get_program ( ) . to_owned ( ) ;
179+
174180 Self {
175181 command,
176182 failure_behavior : BehaviorOnFailure :: Exit ,
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ impl DropBomb {
3131 }
3232 }
3333
34+ pub fn get_created_location ( & self ) -> panic:: Location < ' static > {
35+ self . armed_location
36+ }
37+
3438 /// Defuse the [`DropBomb`]. This will prevent the drop bomb from panicking when dropped.
3539 pub fn defuse ( & mut self ) {
3640 self . defused = true ;
You can’t perform that action at this time.
0 commit comments