mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
feat(build-analysis): build.analysis configuration
When enabled, set timing output format to HTML to pretend we are persisting timing data for now.
This commit is contained in:
parent
973f7410a8
commit
b43404de7e
@ -115,6 +115,18 @@ impl BuildConfig {
|
||||
(None, _) => false,
|
||||
};
|
||||
|
||||
let timing_outputs = match (cfg.analysis.as_ref(), gctx.cli_unstable().build_analysis) {
|
||||
// Enable HTML output to pretend we are persisting timing data for now.
|
||||
(Some(analysis), true) if analysis.enabled => vec![TimingOutput::Html],
|
||||
(Some(_), false) => {
|
||||
gctx.shell().warn(
|
||||
"ignoring 'build.analysis' config, pass `-Zbuild-analysis` to enable it",
|
||||
)?;
|
||||
Vec::new()
|
||||
}
|
||||
_ => Vec::new(),
|
||||
};
|
||||
|
||||
Ok(BuildConfig {
|
||||
requested_kinds,
|
||||
jobs,
|
||||
@ -130,7 +142,7 @@ impl BuildConfig {
|
||||
rustfix_diagnostic_server: Rc::new(RefCell::new(None)),
|
||||
export_dir: None,
|
||||
future_incompat_report: false,
|
||||
timing_outputs: Vec::new(),
|
||||
timing_outputs,
|
||||
sbom,
|
||||
compile_time_deps_only: false,
|
||||
})
|
||||
|
@ -2768,6 +2768,15 @@ pub struct CargoBuildConfig {
|
||||
pub warnings: Option<WarningHandling>,
|
||||
/// Unstable feature `-Zsbom`.
|
||||
pub sbom: Option<bool>,
|
||||
/// Unstable feature `-Zbuild-analysis`.
|
||||
pub analysis: Option<CargoBuildAnalysis>,
|
||||
}
|
||||
|
||||
/// Metrics collection for build analysis.
|
||||
#[derive(Debug, Deserialize, Default)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct CargoBuildAnalysis {
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
/// Whether warnings should warn, be allowed, or cause an error.
|
||||
|
@ -17,6 +17,7 @@ fn gated() {
|
||||
.env("CARGO_BUILD_ANALYSIS_ENABLED", "true")
|
||||
.masquerade_as_nightly_cargo(&["build-analysis"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[WARNING] ignoring 'build.analysis' config, pass `-Zbuild-analysis` to enable it
|
||||
[CHECKING] foo v0.0.0 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
@ -36,6 +37,7 @@ fn simple() {
|
||||
.masquerade_as_nightly_cargo(&["build-analysis"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[CHECKING] foo v0.0.0 ([ROOT]/foo)
|
||||
Timing report saved to [ROOT]/foo/target/cargo-timings/cargo-timing-[..].html
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
|
Loading…
x
Reference in New Issue
Block a user