From 21723cb0513a6cba95556822138dd7cb65ea3ac8 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 17 Jan 2024 09:43:04 +0100 Subject: [PATCH] Run metadata on sysroot for CI metrics --- crates/rust-analyzer/src/cli/analysis_stats.rs | 1 + crates/rust-analyzer/src/cli/flags.rs | 4 ++++ xtask/src/metrics.rs | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index e69302dbac..f601f00442 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -63,6 +63,7 @@ impl flags::AnalysisStats { true => None, false => Some(RustLibSource::Discover), }; + cargo_config.sysroot_query_metadata = self.query_sysroot_metadata; let no_progress = &|_| (); let mut db_load_sw = self.stop_watch(); diff --git a/crates/rust-analyzer/src/cli/flags.rs b/crates/rust-analyzer/src/cli/flags.rs index 5633c0c488..cc9e2a7ce2 100644 --- a/crates/rust-analyzer/src/cli/flags.rs +++ b/crates/rust-analyzer/src/cli/flags.rs @@ -71,6 +71,9 @@ xflags::xflags! { optional --with-deps /// Don't load sysroot crates (`std`, `core` & friends). optional --no-sysroot + /// Run cargo metadata on the sysroot to analyze its third-pary dependencies. + /// Requires --no-sysroot to not be set. + optional --query-sysroot-metadata /// Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis. optional --disable-build-scripts @@ -206,6 +209,7 @@ pub struct AnalysisStats { pub only: Option, pub with_deps: bool, pub no_sysroot: bool, + pub query_sysroot_metadata: bool, pub disable_build_scripts: bool, pub disable_proc_macros: bool, pub skip_lowering: bool, diff --git a/xtask/src/metrics.rs b/xtask/src/metrics.rs index 845928432c..db4e1b3582 100644 --- a/xtask/src/metrics.rs +++ b/xtask/src/metrics.rs @@ -113,7 +113,11 @@ impl Metrics { ) -> anyhow::Result<()> { assert!(Path::new(path).exists(), "unable to find bench in {path}"); eprintln!("\nMeasuring analysis-stats/{name}"); - let output = cmd!(sh, "./target/release/rust-analyzer -q analysis-stats {path}").read()?; + let output = cmd!( + sh, + "./target/release/rust-analyzer -q analysis-stats {path} --query-sysroot-metadata" + ) + .read()?; for (metric, value, unit) in parse_metrics(&output) { self.report(&format!("analysis-stats/{name}/{metric}"), value, unit.into()); }