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 {
115
115
( None , _) => false ,
116
116
} ;
117
117
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
+
118
130
Ok ( BuildConfig {
119
131
requested_kinds,
120
132
jobs,
@@ -130,7 +142,7 @@ impl BuildConfig {
130
142
rustfix_diagnostic_server : Rc :: new ( RefCell :: new ( None ) ) ,
131
143
export_dir : None ,
132
144
future_incompat_report : false ,
133
- timing_outputs : Vec :: new ( ) ,
145
+ timing_outputs,
134
146
sbom,
135
147
compile_time_deps_only : false ,
136
148
} )
Original file line number Diff line number Diff line change @@ -2768,6 +2768,15 @@ pub struct CargoBuildConfig {
2768
2768
pub warnings : Option < WarningHandling > ,
2769
2769
/// Unstable feature `-Zsbom`.
2770
2770
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 ,
2771
2780
}
2772
2781
2773
2782
/// 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() {
17
17
p. cargo ( "check" )
18
18
. env ( "CARGO_BUILD_ANALYSIS_ENABLED" , "true" )
19
19
. with_stderr_data ( str![ [ r#"
20
+ [WARNING] ignoring 'build.analysis' config, pass `-Zbuild-analysis` to enable it
20
21
[CHECKING] foo v0.0.0 ([ROOT]/foo)
21
22
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
22
23
@@ -35,6 +36,7 @@ fn gated_no_z_flag() {
35
36
. env ( "CARGO_BUILD_ANALYSIS_ENABLED" , "true" )
36
37
. masquerade_as_nightly_cargo ( & [ "build-analysis" ] )
37
38
. with_stderr_data ( str![ [ r#"
39
+ [WARNING] ignoring 'build.analysis' config, pass `-Zbuild-analysis` to enable it
38
40
[CHECKING] foo v0.0.0 ([ROOT]/foo)
39
41
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
40
42
@@ -54,6 +56,7 @@ fn simple() {
54
56
. masquerade_as_nightly_cargo ( & [ "build-analysis" ] )
55
57
. with_stderr_data ( str![ [ r#"
56
58
[CHECKING] foo v0.0.0 ([ROOT]/foo)
59
+ Timing report saved to [ROOT]/foo/target/cargo-timings/cargo-timing-[..].html
57
60
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
58
61
59
62
"# ] ] )
You can’t perform that action at this time.
0 commit comments