Read aspect providers in cquery
Description of the feature request:
Cquery should be able to read providers that were created by an aspect.
I tested, and the aspects already run during cquery (see https://github.com/bazelbuild/bazel/issues/16310#issuecomment-2113976408). So all I'm asking is that we surface that via cquery. I suspect that this will likely be a relatively simple change, since the aspects already run, but it depends on how it's implemented.
Which category does this issue belong to?
Rules API
What underlying problem are you trying to solve with this feature?
Aspects are very useful for allowing IDEs access to metadata about the build. However, at the moment, IIUC, the way you have to use them is to:
- run
bazel build <something> --aspects=... - Read from the output file generated by your aspect.
Sometimes, however, you don't need anything other than the providers created by the aspect. In cases like this, cquery should be sufficient. For example, generating rust-project.json in rust can be done without building a single target.
The use case that I was trying to do for this is that if I run cquery on the following target:
cc_binary(
name = "foo",
deps = ["//path/to:rust_library"],
)
Then I want cquery to attach a RustAnalyzerInfo object to :foo. This can then be picked up on by the rust-analyzer vscode extension. At the moment we use bazel build instead of bazel cquery, which means that if any bazel target fails to build, then we can't run get IDE support for our rust code.
Which operating system are you running Bazel on?
Linux
What is the output of bazel info release?
7.1.1
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse HEAD ?
No response
Have you found anything relevant by searching the web?
I commented on https://github.com/bazelbuild/bazel/issues/16310#issuecomment-2113976408 last week
Any other information, logs, or outputs that you want to share?
No response