Skip to content

Commit 6972a9e

Browse files
committed
feat(build-analysis): build.analysis configuration
When enabled, set timing output format to HTML to pretend we are persisting timing data for now.
1 parent 6e3e1e5 commit 6972a9e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/cargo/core/compiler/build_config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ impl BuildConfig {
115115
(None, _) => false,
116116
};
117117

118-
let timing_outputs = match (cfg.analysis.enabled, gctx.cli_unstable().build_analysis) {
118+
let timing_outputs = match (cfg.analysis.as_ref(), gctx.cli_unstable().build_analysis) {
119119
// Enable HTML output to pretend we are persisting timing data for now.
120-
(true, true) => vec![TimingOutput::Html],
121-
(true, false) => {
120+
(Some(analysis), true) if analysis.enabled => vec![TimingOutput::Html],
121+
(Some(_), false) => {
122122
gctx.shell().warn(
123123
"ignoring 'build.analysis' config, pass `-Zbuild-analysis` to enable it",
124124
)?;

src/cargo/util/context/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2769,7 +2769,7 @@ pub struct CargoBuildConfig {
27692769
/// Unstable feature `-Zsbom`.
27702770
pub sbom: Option<bool>,
27712771
/// Unstable feature `-Zbuild-analysis`.
2772-
pub analysis: CargoBuildAnalysis,
2772+
pub analysis: Option<CargoBuildAnalysis>,
27732773
}
27742774

27752775
/// Metrics collection for build analysis.

tests/testsuite/build_analysis.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff 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
"#]])

0 commit comments

Comments
 (0)