-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Add --output=files mode to cquery
#15552
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
Conversation
--output=files mode to cquery
f37b578 to
a986ca1
Compare
|
I am very hesitant about adding this since it seems to be just a convenience for what can be done with starlark mode. We are trying to reduce the size of bazel and move features to starlark not the other way around. I can look at it later this week. |
I generally agree with this position, but I think this case is a bit special: "Where is my build output?" is a very common question that is also quite relevant for developers that are not core Bazel users and just happen to interface with it. Think of an OSS project that needs to build another OSS project that uses Bazel and has to figure out the set of files it needs to import. If we have the barrier to entry somewhere at "knows about |
|
Disclaimer: I haven't reviewed this in any meaningful way yet. Generally speaking I agree with @aiuto 's comment and default to a position of needing strong justification for new user-facing features. I see @fmeum that you appreciate these points and are trying to make such a justification for this change. Whatever we ultimately decide I think it's fair for us to evaluate your points on their merit. |
|
A wise man once said:
|
|
Still support that statement 100%! I'll hold back from saying more until I've properly read through this, and how all the themes connect. |
|
I think the value is not just from the output paths, but attaching a meaningful labeling to each. The output group name is generally good, but not everything produces that. Sometimes you have to go into the rule specific providers to understand the meaning of a file. Once that happens, we are back at writing rule specific starlark code. |
|
Reviewed further. I support this, with some caveats.
|
|
One more comment: There's also some awkwardness with multi-target builds. I can imagine someone wanting to just replace their
|
In fact, even before working on this change, I have always wondered about why |
With that aim, it is important to keep the following in mind: If content-based output paths are used to make builds more cacheable and if these paths are used throughout Bazel and not just on the level of
Fully agreed. It's not completely uncommon to see
Could you explain what you envision as
I don't have a strong opinion here. When in doubt, I would prefer an output format that plays well with other Unix tools, given that this command will be a common interface to the non-Bazel world. There is
I could implement
That would probably defeat the purpose of decoupling this logic from core Bazel. |
1 similar comment
With that aim, it is important to keep the following in mind: If content-based output paths are used to make builds more cacheable and if these paths are used throughout Bazel and not just on the level of
Fully agreed. It's not completely uncommon to see
Could you explain what you envision as
I don't have a strong opinion here. When in doubt, I would prefer an output format that plays well with other Unix tools, given that this command will be a common interface to the non-Bazel world. There is
I could implement
That would probably defeat the purpose of decoupling this logic from core Bazel. |
Instead of: Something like: To be clear, I'm not asking you to implement this in this PR. I'm just thinking about a forward-facing API. |
src/main/java/com/google/devtools/build/lib/analysis/TopLevelArtifactHelper.java
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/query2/cquery/FilesOutputFormatterCallback.java
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/query2/cquery/FilesOutputFormatterCallback.java
Show resolved
Hide resolved
|
Broadly speaking, and after more discussion with @brandjon , I support the simplest syntax: which you're already doing. The more complex structures quickly get speculative, where the core need is just a simple, easy API. Any extra syntax we add now would make future API changes that much more complicated if we get it wrong. @brandjon had some interesting ideas about separating the content request (outputs vs. BUILD vs. ...) with the format (JSON vs. plain vs. ...). Now's not the time to get caught up in the subtleties. |
|
Stated differently, lacking more experience with this, I think it's fair to assume users know which targets they're requesting outputs for. So we don't have to preemptively add API features to contextualize. |
546a20a to
81da138
Compare
With the new output mode `--output=files`, cquery lists all files advertised by the matched targets in the currently requested output groups. This new mode has the following advantages over `--output=starlark` combined with an appropriate handcrafted `--starlark:expr`: * provides a canonical answer to the very common "Where are my build outputs?" question * is more friendly to new users as it doesn't require knowing about providers and non-BUILD dialect Starlark * takes the value of `--output_groups` into account * stays as close to the logic for build summaries printed by `bazel build` as possible Fixes bazelbuild#8739 RELNOTES: `cquery`'s new output mode [`--output=files`](https://bazel.build/docs/cquery#files-output) lists the output files of the targets matching the query. It takes the current value of `--output_groups` into account. Closes bazelbuild#15552. PiperOrigin-RevId: 462630629 Change-Id: Ic648f22aa160ee57b476180561b444f08799ebb6
|
Hey @fmeum, we are trying to cherry pick this change to release-5.3.0. But presubmit checks are failing. Could you please help us in cherry-picking this PR to release-5.3.0? Thanks! |
|
That might have been a merge discrepancy. I think it's just a matter of the right dependency in a BUILD file being added. |
|
There's some kind of baseline discrepancy. For example, for But the cherrypick also includes which was added by 9994c32. |
|
It should usually be the job of the original PR author to create a PR that
backports a feature to the previous release.
The release team is not responsible for figuring out a complex PR when it
is on a single patch.
…On Mon, Jul 25, 2022 at 4:27 PM Greg ***@***.***> wrote:
There's some kind of baseline discrepancy.
For example, for ProtoOutputFormatterCallback, this commit
<681f534#diff-4f1f5a5f095fc900af3c7a6ce9217da68db4c1d2b3b23644a0a38ff6acf2adaf>
only adjusts the line
super(eventHandler, options, out, skyframeExecutor, accessor, /*uniquifyResults=*/ false);
But the cherrypick
<https://github.com/bazelbuild/bazel/pull/15955/files#diff-4f1f5a5f095fc900af3c7a6ce9217da68db4c1d2b3b23644a0a38ff6acf2adaf>
also includes
OutputType outputType,
@nullable TransitionFactory<RuleTransitionData> trimmingTransitionFactory) {
which was added by 9994c32
<9994c32>
.
—
Reply to this email directly, view it on GitHub
<#15552 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAXHHHFEXGYBLOGBEB6DSJDVV32CJANCNFSM5WVWQ6XA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
With the new output mode `--output=files`, cquery lists all files advertised by the matched targets in the currently requested output groups. This new mode has the following advantages over `--output=starlark` combined with an appropriate handcrafted `--starlark:expr`: * provides a canonical answer to the very common "Where are my build outputs?" question * is more friendly to new users as it doesn't require knowing about providers and non-BUILD dialect Starlark * takes the value of `--output_groups` into account * stays as close to the logic for build summaries printed by `bazel build` as possible Fixes bazelbuild#8739 RELNOTES: `cquery`'s new output mode [`--output=files`](https://bazel.build/docs/cquery#files-output) lists the output files of the targets matching the query. It takes the current value of `--output_groups` into account. Closes bazelbuild#15552. PiperOrigin-RevId: 462630629 Change-Id: Ic648f22aa160ee57b476180561b444f08799ebb6
|
I submitted #15979 with the merge conflicts resolved. |
With the new output mode `--output=files`, cquery lists all files advertised by the matched targets in the currently requested output groups. This new mode has the following advantages over `--output=starlark` combined with an appropriate handcrafted `--starlark:expr`: * provides a canonical answer to the very common "Where are my build outputs?" question * is more friendly to new users as it doesn't require knowing about providers and non-BUILD dialect Starlark * takes the value of `--output_groups` into account * stays as close to the logic for build summaries printed by `bazel build` as possible Fixes #8739 RELNOTES: `cquery`'s new output mode [`--output=files`](https://bazel.build/docs/cquery#files-output) lists the output files of the targets matching the query. It takes the current value of `--output_groups` into account. Closes #15552. PiperOrigin-RevId: 462630629 Change-Id: Ic648f22aa160ee57b476180561b444f08799ebb6
With the new output mode
--output=files, cquery lists all files advertised by the matched targets in the currently requested output groups.This new mode has the following advantages over
--output=starlarkcombined with an appropriate handcrafted--starlark:expr:--output_groupsinto accountbazel buildas possibleFixes #8739
RELNOTES:
cquery's new output mode--output=fileslists the output files of the targets matching the query. It takes the current value of--output_groupsinto account.