Add support for building queried targets in 1 command#28996
Open
keith wants to merge 8 commits intobazelbuild:masterfrom
Open
Add support for building queried targets in 1 command#28996keith wants to merge 8 commits intobazelbuild:masterfrom
keith wants to merge 8 commits intobazelbuild:masterfrom
Conversation
This allows combining the common pattern of build and then query into a single build command that executes the passed query (or query_file) Fixes bazelbuild#26938 RELNOTES[inc]: Add 'build --query' flag for building the result of a bazel query in a single command
fmeum
approved these changes
Mar 13, 2026
| List<String> queryTargets; | ||
| if (hasQuery) { | ||
| try { | ||
| queryTargets = executeQuery(env, buildRequestOptions.query, options); |
Collaborator
There was a problem hiding this comment.
I don't know whether there are any, but it would be good to verify that bazel query options that affect the results of a query are taken into account here.
Member
Author
There was a problem hiding this comment.
are you thinking options like --tool_deps or something else? since those aren't accepted by the arg parsing
src/main/java/com/google/devtools/build/lib/runtime/commands/TargetPatternsHelper.java
Outdated
Show resolved
Hide resolved
| StarlarkSemantics starlarkSemantics = | ||
| options.getOptions(BuildLanguageOptions.class).toStarlarkSemantics(); | ||
| LabelPrinter labelPrinter = | ||
| new QueryOptions().getLabelPrinter(starlarkSemantics, mainRepoTargetParser.getRepoMapping()); |
Collaborator
There was a problem hiding this comment.
Could we take the actual query options into account or leave a comment explaining why they don't matter (it's not super surprising given that this is about printing labels and we don't).
Member
Author
There was a problem hiding this comment.
I think some could matter, like --notool_deps, but im not sure we want to expose all of those to the build command
src/main/java/com/google/devtools/build/lib/runtime/commands/TargetPatternsHelper.java
Show resolved
Hide resolved
src/main/java/com/google/devtools/build/lib/runtime/commands/TargetPatternsHelper.java
Outdated
Show resolved
Hide resolved
fmeum
approved these changes
Mar 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows combining the common pattern of build and then query into a
single build command that executes the passed query (or query_file)
Fixes #26938
RELNOTES[NEW]: Add 'build --target_query' /
--target_query_fileflags forbuilding the result of a bazel query in a single command