8
8
use std:: fs:: { self , OpenOptions } ;
9
9
use std:: io:: { self , BufRead , BufReader , IsTerminal , Write } ;
10
10
use std:: str:: FromStr ;
11
+ use std:: time:: Instant ;
11
12
use std:: { env, process} ;
12
13
13
14
use bootstrap:: {
@@ -17,11 +18,17 @@ use bootstrap::{
17
18
#[ cfg( feature = "tracing" ) ]
18
19
use tracing:: instrument;
19
20
21
+ fn is_bootstrap_profiling_enabled ( ) -> bool {
22
+ env:: var ( "BOOTSTRAP_PROFILE" ) . is_ok_and ( |v| v == "1" )
23
+ }
24
+
20
25
#[ cfg_attr( feature = "tracing" , instrument( level = "trace" , name = "main" ) ) ]
21
26
fn main ( ) {
22
27
#[ cfg( feature = "tracing" ) ]
23
28
let _guard = setup_tracing ( ) ;
24
29
30
+ let start_time = Instant :: now ( ) ;
31
+
25
32
let args = env:: args ( ) . skip ( 1 ) . collect :: < Vec < _ > > ( ) ;
26
33
27
34
if Flags :: try_parse_verbose_help ( & args) {
@@ -96,7 +103,8 @@ fn main() {
96
103
let out_dir = config. out . clone ( ) ;
97
104
98
105
debug ! ( "creating new build based on config" ) ;
99
- Build :: new ( config) . build ( ) ;
106
+ let mut build = Build :: new ( config) ;
107
+ build. build ( ) ;
100
108
101
109
if suggest_setup {
102
110
println ! ( "WARNING: you have not made a `bootstrap.toml`" ) ;
@@ -147,6 +155,10 @@ fn main() {
147
155
t ! ( file. write_all( lines. join( "\n " ) . as_bytes( ) ) ) ;
148
156
}
149
157
}
158
+
159
+ if is_bootstrap_profiling_enabled ( ) {
160
+ build. report_summary ( start_time) ;
161
+ }
150
162
}
151
163
152
164
fn check_version ( config : & Config ) -> Option < String > {
@@ -226,7 +238,7 @@ fn setup_tracing() -> impl Drop {
226
238
let mut chrome_layer = tracing_chrome:: ChromeLayerBuilder :: new ( ) . include_args ( true ) ;
227
239
228
240
// Writes the Chrome profile to trace-<unix-timestamp>.json if enabled
229
- if !env :: var ( "BOOTSTRAP_PROFILE" ) . is_ok_and ( |v| v == "1" ) {
241
+ if !is_bootstrap_profiling_enabled ( ) {
230
242
chrome_layer = chrome_layer. writer ( io:: sink ( ) ) ;
231
243
}
232
244
0 commit comments