Skip to content

Commit 1a5097d

Browse files
committed
Fix exclusions in gen_rust_project target pattern
Signed-off-by: Patrick Steadman <ptsteadman@gmail.com>
1 parent 59a507e commit 1a5097d

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

tools/rust_analyzer/aquery.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,22 @@ pub fn get_crate_specs(
9494
) -> anyhow::Result<BTreeSet<CrateSpec>> {
9595
log::info!("running bazel aquery...");
9696
log::debug!("Get crate specs with targets: {:?}", targets);
97-
let target_pattern = format!("deps({})", targets.join("+"));
97+
let target_pattern = format!(
98+
"deps({})",
99+
targets
100+
.iter()
101+
.map(|t| {
102+
if let Some(stripped) = t.strip_prefix('-') {
103+
format!(" - {stripped}")
104+
} else {
105+
format!(" + {t}")
106+
}
107+
})
108+
.collect::<Vec<_>>()
109+
.join("")
110+
.trim_start_matches(" + ")
111+
.to_owned()
112+
);
98113

99114
let mut aquery_command = bazel_command(bazel, Some(workspace), Some(output_base));
100115
aquery_command

tools/rust_analyzer/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ fn generate_crate_info(
112112
"--aspects={rules_rust}//rust:defs.bzl%rust_analyzer_aspect"
113113
))
114114
.arg("--output_groups=rust_analyzer_crate_spec,rust_generated_srcs,rust_analyzer_proc_macro_dylib,rust_analyzer_src")
115+
.arg("--")
115116
.args(targets)
116117
.output()?;
117118

0 commit comments

Comments
 (0)