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 {
937
937
938
938
/// Execute a command and return its output.
939
939
/// This method should be used for all command executions in bootstrap.
940
+ #[ track_caller]
940
941
fn run ( & self , command : & mut BootstrapCommand ) -> CommandOutput {
941
942
command. mark_as_executed ( ) ;
942
943
if self . config . dry_run ( ) && !command. run_always {
943
944
return CommandOutput :: default ( ) ;
944
945
}
945
946
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
+ } ) ;
947
953
948
954
let stdout = command. stdout . stdio ( ) ;
949
955
command. as_command_mut ( ) . stdout ( stdout) ;
@@ -962,8 +968,11 @@ impl Build {
962
968
Ok ( output) => {
963
969
writeln ! (
964
970
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}"# ,
967
976
output. status,
968
977
)
969
978
. unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -160,17 +160,23 @@ impl BootstrapCommand {
160
160
& mut self . command
161
161
}
162
162
163
- /// Mark the command as being executd , disarming the drop bomb.
163
+ /// Mark the command as being executed , disarming the drop bomb.
164
164
/// If this method is not called before the command is dropped, its drop will panic.
165
165
pub fn mark_as_executed ( & mut self ) {
166
166
self . drop_bomb . defuse ( ) ;
167
167
}
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
+ }
168
173
}
169
174
170
175
impl From < Command > for BootstrapCommand {
171
176
#[ track_caller]
172
177
fn from ( command : Command ) -> Self {
173
178
let program = command. get_program ( ) . to_owned ( ) ;
179
+
174
180
Self {
175
181
command,
176
182
failure_behavior : BehaviorOnFailure :: Exit ,
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ impl DropBomb {
31
31
}
32
32
}
33
33
34
+ pub fn get_created_location ( & self ) -> panic:: Location < ' static > {
35
+ self . armed_location
36
+ }
37
+
34
38
/// Defuse the [`DropBomb`]. This will prevent the drop bomb from panicking when dropped.
35
39
pub fn defuse ( & mut self ) {
36
40
self . defused = true ;
You can’t perform that action at this time.
0 commit comments