-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add support for building queried targets in 1 command #27058
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
base: master
Are you sure you want to change the base?
Conversation
decad34
to
4307f8c
Compare
} catch (QueryException | InterruptedException | IOException e) { | ||
throw new TargetPatternsHelperException( | ||
"Error executing query: " + e.getMessage(), | ||
TargetPatterns.Code.TARGET_PATTERNS_UNKNOWN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk what exit codes i should really use here, i didn't want to force all callers to handle this same logic, so I kept only this 1 exception type that they're already handling
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[inc]: Add 'build --query' flag for building the result of a bazel query in a single command
4307f8c
to
fbb7c00
Compare
3d6f761
to
2d3e949
Compare
RELNOTES[NEW] seems more appropriate for a new flag, it's not an incompatible change. |
help = | ||
"If set, build will evaluate the query expression and build the resulting targets. " | ||
+ "Example: --query='deps(//foo) - deps(//bar)'. It is an error to specify this " | ||
+ "along with command-line patterns or --target_pattern_file.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or --target_query_file
?
if (!targets.isEmpty() && !buildRequestOptions.targetPatternFile.isEmpty()) { | ||
|
||
int optionCount = 0; | ||
if (!targets.isEmpty()) optionCount++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Google style dislikes single line ifs.
TargetPatterns.Code.TARGET_PATTERNS_UNKNOWN); | ||
} | ||
|
||
return new ArrayList<>(targetPatterns); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer ImmutableList.copyOf
here and make the return type more specific.
if (!targets.isEmpty() && !buildRequestOptions.targetPatternFile.isEmpty()) { | ||
|
||
int optionCount = 0; | ||
if (!targets.isEmpty()) optionCount++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a design reason that residue targets can't be mixed with a query?
I am specifically interested in how it interacts with --remote_download_outputs=toplevel
, as that is one place where we use a query like this to download only certain files, while still building everything:
bazel test --remote_download_outputs=top-level //... $(bazel query 'attr(tags, ci-download-outputs, //...)')
I haven't figured out if there is an existing technical limitation that would make supporting that difficult.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing inherent, i inherited this logic from targetPatternFile and I haven't traced back why it was done for that case
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' flag for building the result of a
bazel query in a single command