File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,18 @@ impl BuildConfig {
115115 ( None , _) => false ,
116116 } ;
117117
118+ let timing_outputs = match ( cfg. analysis . as_ref ( ) , gctx. cli_unstable ( ) . build_analysis ) {
119+ // Enable HTML output to pretend we are persisting timing data for now.
120+ ( Some ( analysis) , true ) if analysis. enabled => vec ! [ TimingOutput :: Html ] ,
121+ ( Some ( _) , false ) => {
122+ gctx. shell ( ) . warn (
123+ "ignoring 'build.analysis' config, pass `-Zbuild-analysis` to enable it" ,
124+ ) ?;
125+ Vec :: new ( )
126+ }
127+ _ => Vec :: new ( ) ,
128+ } ;
129+
118130 Ok ( BuildConfig {
119131 requested_kinds,
120132 jobs,
@@ -130,7 +142,7 @@ impl BuildConfig {
130142 rustfix_diagnostic_server : Rc :: new ( RefCell :: new ( None ) ) ,
131143 export_dir : None ,
132144 future_incompat_report : false ,
133- timing_outputs : Vec :: new ( ) ,
145+ timing_outputs,
134146 sbom,
135147 compile_time_deps_only : false ,
136148 } )
Original file line number Diff line number Diff line change @@ -2768,6 +2768,15 @@ pub struct CargoBuildConfig {
27682768 pub warnings : Option < WarningHandling > ,
27692769 /// Unstable feature `-Zsbom`.
27702770 pub sbom : Option < bool > ,
2771+ /// Unstable feature `-Zbuild-analysis`.
2772+ pub analysis : Option < CargoBuildAnalysis > ,
2773+ }
2774+
2775+ /// Metrics collection for build analysis.
2776+ #[ derive( Debug , Deserialize , Default ) ]
2777+ #[ serde( rename_all = "kebab-case" ) ]
2778+ pub struct CargoBuildAnalysis {
2779+ pub enabled : bool ,
27712780}
27722781
27732782/// Whether warnings should warn, be allowed, or cause an error.
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ fn gated() {
1717 p. cargo ( "check" )
1818 . env ( "CARGO_BUILD_ANALYSIS_ENABLED" , "true" )
1919 . with_stderr_data ( str![ [ r#"
20+ [WARNING] ignoring 'build.analysis' config, pass `-Zbuild-analysis` to enable it
2021[CHECKING] foo v0.0.0 ([ROOT]/foo)
2122[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2223
@@ -35,6 +36,7 @@ fn gated_no_z_flag() {
3536 . env ( "CARGO_BUILD_ANALYSIS_ENABLED" , "true" )
3637 . masquerade_as_nightly_cargo ( & [ "build-analysis" ] )
3738 . with_stderr_data ( str![ [ r#"
39+ [WARNING] ignoring 'build.analysis' config, pass `-Zbuild-analysis` to enable it
3840[CHECKING] foo v0.0.0 ([ROOT]/foo)
3941[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
4042
@@ -54,6 +56,7 @@ fn simple() {
5456 . masquerade_as_nightly_cargo ( & [ "build-analysis" ] )
5557 . with_stderr_data ( str![ [ r#"
5658[CHECKING] foo v0.0.0 ([ROOT]/foo)
59+ Timing report saved to [ROOT]/foo/target/cargo-timings/cargo-timing-[..].html
5760[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
5861
5962"# ] ] )
You can’t perform that action at this time.
0 commit comments