diff options
| author | bit-aloo <sshourya17@gmail.com> | 2025-07-10 18:20:17 +0530 |
|---|---|---|
| committer | bit-aloo <sshourya17@gmail.com> | 2025-07-10 18:25:43 +0530 |
| commit | eac1ed5b74b9835ac9c7b1a91f23f3bf7707e5dd (patch) | |
| tree | dcf4dca890d099a9569435b06bb9d8bc812f01ae /src | |
| parent | 75b454b3206d6213f4015ecc77b40fd48eadd6cf (diff) | |
| download | rust-eac1ed5b74b9835ac9c7b1a91f23f3bf7707e5dd.tar.gz rust-eac1ed5b74b9835ac9c7b1a91f23f3bf7707e5dd.zip | |
enable report summary when BOOTSTRAP_PROFILE is set
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/src/bin/main.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs index e1862a451f2..181d71f63c2 100644 --- a/src/bootstrap/src/bin/main.rs +++ b/src/bootstrap/src/bin/main.rs @@ -8,6 +8,7 @@ use std::fs::{self, OpenOptions}; use std::io::{self, BufRead, BufReader, IsTerminal, Write}; use std::str::FromStr; +use std::time::Instant; use std::{env, process}; use bootstrap::{ @@ -17,11 +18,17 @@ use bootstrap::{ #[cfg(feature = "tracing")] use tracing::instrument; +fn is_bootstrap_profiling_enabled() -> bool { + env::var("BOOTSTRAP_PROFILE").is_ok_and(|v| v == "1") +} + #[cfg_attr(feature = "tracing", instrument(level = "trace", name = "main"))] fn main() { #[cfg(feature = "tracing")] let _guard = setup_tracing(); + let start_time = Instant::now(); + let args = env::args().skip(1).collect::<Vec<_>>(); if Flags::try_parse_verbose_help(&args) { @@ -96,7 +103,8 @@ fn main() { let out_dir = config.out.clone(); debug!("creating new build based on config"); - Build::new(config).build(); + let mut build = Build::new(config); + build.build(); if suggest_setup { println!("WARNING: you have not made a `bootstrap.toml`"); @@ -147,6 +155,10 @@ fn main() { t!(file.write_all(lines.join("\n").as_bytes())); } } + + if is_bootstrap_profiling_enabled() { + build.report_summary(start_time); + } } fn check_version(config: &Config) -> Option<String> { @@ -226,7 +238,7 @@ fn setup_tracing() -> impl Drop { let mut chrome_layer = tracing_chrome::ChromeLayerBuilder::new().include_args(true); // Writes the Chrome profile to trace-<unix-timestamp>.json if enabled - if !env::var("BOOTSTRAP_PROFILE").is_ok_and(|v| v == "1") { + if !is_bootstrap_profiling_enabled() { chrome_layer = chrome_layer.writer(io::sink()); } |
