3
3
//! This module provides the [`ExecutionContext`] type, which holds global configuration
4
4
//! relevant during the execution of commands in bootstrap. This includes dry-run
5
5
//! mode, verbosity level, and behavior on failure.
6
+ use std:: panic:: Location ;
6
7
use std:: process:: Child ;
7
8
use std:: sync:: { Arc , Mutex } ;
8
9
@@ -89,22 +90,23 @@ impl ExecutionContext {
89
90
) -> DeferredCommand < ' a > {
90
91
command. mark_as_executed ( ) ;
91
92
93
+ let created_at = command. get_created_location ( ) ;
94
+ let executed_at = std:: panic:: Location :: caller ( ) ;
95
+
92
96
if self . dry_run ( ) && !command. run_always {
93
97
return DeferredCommand {
94
98
process : None ,
95
99
stdout,
96
100
stderr,
97
101
command,
98
102
exec_ctx : Arc :: new ( self . clone ( ) ) ,
103
+ created_at,
99
104
} ;
100
105
}
101
106
102
107
#[ cfg( feature = "tracing" ) ]
103
108
let _run_span = trace_cmd ! ( command) ;
104
109
105
- let created_at = command. get_created_location ( ) ;
106
- let executed_at = std:: panic:: Location :: caller ( ) ;
107
-
108
110
self . verbose ( || {
109
111
println ! ( "running: {command:?} (created at {created_at}, executed at {executed_at})" )
110
112
} ) ;
@@ -121,6 +123,7 @@ impl ExecutionContext {
121
123
stderr,
122
124
command,
123
125
exec_ctx : Arc :: new ( self . clone ( ) ) ,
126
+ created_at,
124
127
}
125
128
}
126
129
@@ -167,6 +170,7 @@ pub struct DeferredCommand<'a> {
167
170
stdout : OutputMode ,
168
171
stderr : OutputMode ,
169
172
exec_ctx : Arc < ExecutionContext > ,
173
+ created_at : Location < ' a > ,
170
174
}
171
175
172
176
impl < ' a > DeferredCommand < ' a > {
@@ -176,7 +180,7 @@ impl<'a> DeferredCommand<'a> {
176
180
}
177
181
let output = self . process . take ( ) . unwrap ( ) . wait_with_output ( ) ;
178
182
179
- let created_at = self . command . get_created_location ( ) ;
183
+ let created_at = self . created_at ;
180
184
let executed_at = std:: panic:: Location :: caller ( ) ;
181
185
182
186
use std:: fmt:: Write ;
0 commit comments