Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read aspect providers in cquery #22528

Open
matts1 opened this issue May 24, 2024 · 4 comments
Open

Read aspect providers in cquery #22528

matts1 opened this issue May 24, 2024 · 4 comments
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Configurability platforms, toolchains, cquery, select(), config transitions type: feature request

Comments

@matts1
Copy link
Contributor

matts1 commented May 24, 2024

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 #16310 (comment)). 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:

  1. run bazel build <something> --aspects=...
  2. 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 #16310 (comment) last week

Any other information, logs, or outputs that you want to share?

No response

@github-actions github-actions bot added the team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts label May 24, 2024
@comius comius added team-Configurability platforms, toolchains, cquery, select(), config transitions and removed team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts labels May 31, 2024
@comius
Copy link
Contributor

comius commented May 31, 2024

cc @mai93

@mai93
Copy link
Contributor

mai93 commented May 31, 2024

Can specifying only the output group containing the file with aspect provider data via --output_groups in the bazel build <something> --aspects=... invocation help with that? IIUC this will not execute the rest of the actions in the build that may fail.

@matts1
Copy link
Contributor Author

matts1 commented Jun 3, 2024

That's a good point. I just tried it out, and it does appear to work. I still think this suggestion has value, but it can be achieved via other means, so it's probably not a priority.

@mai93 mai93 added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) and removed untriaged labels Jun 3, 2024
@kilian-funk
Copy link

The bazel build <something> --aspect=... workaround is only practical for a few targets. It is not helpful if I want to use this approach to harvest more detailed information on a complete region of my workspace. In my use case, I need to process certain information from an attribute of many targets. Since cquery Starlark does not give me access to the attributes, I need to use an aspect. Using output groups in combination with bazel build would mean reading thousands of files to collect the results.

So I would be very happy if this issue got fixed soon 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Configurability platforms, toolchains, cquery, select(), config transitions type: feature request
Projects
None yet
Development

No branches or pull requests

7 participants