-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add support for reading a list of target patterns for from a file #8609
Comments
You can achieve this using:
Would that work for you? |
I would like this feature too. Bazel supports actions that use args files, so maybe why not bazel too? The bazelrc approach would not work for us, our repo has a checked in .bazelrc. |
@kastiglione you can probably use |
I didn't know about |
@jin thanks for the suggestion, I did not know you could put build targets into the bazelrc. I guess that technically fixes my issue, although I agree with @kastiglione that having general argfile support would be nice. Should I open a general issue for that or do you want to keep this one open and rename it to "Add support for argfiles". |
@jin I tried this and it works for the number of targets we have in our repository today, but when I tried to do it with a list double the number of targets I get an odd grpc error:
Any idea why this could be? |
We've been using this for a while and while it works, it makes It would be great if Bazel could support running from argfiles. Any pointers for where to start? |
I debugged the
grpc/grpc-java's I looked a bit through Bazel's source code to find out where to add functionality to read target patterns from a file and stumbled upon the undocumented bazel/src/main/java/com/google/devtools/build/lib/runtime/CommonCommandOptions.java Lines 435 to 443 in f17441a
Based on what I've read in
where bazel/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java Lines 1546 to 1554 in f9bc968
as no module implements Should I try to implement a |
There's some prior art for this in query (--query_file, see also QueryEnvironmentBasedCommand.java). This could be a more direct route with less gotchas than full param file support or "project file" support. |
An alternative to bazelbuild#10796 to fix bazelbuild#8609. As bazelbuild#8609 (comment) points out there's currently a --query_file to read a query pattern from file, but there's no analogous feature available for build/test. Generic parameter file support attempted in bazelbuild#10796 turns out to be a little more complex than expected due to bazel's client/server architecture and likely requires some design document. This PR would fix help bazelbuild#8609 without rushing into any designs, so we can spend time properly designing generic parameter files while also alleviating the immediate problem with a known/simpler pattern.
An alternative to bazelbuild#10796 to fix bazelbuild#8609. As bazelbuild#8609 (comment) points out there's currently a `--query_file` to read a query pattern from file, but there's no analogous feature available for build/test. Generic parameter file support attempted in bazelbuild#10796 turns out to be a little more complex than expected due to bazel's client/server architecture and likely requires some design document. This PR would fix help bazelbuild#8609 without rushing into any designs, so we can spend time properly designing generic parameter files while also alleviating the immediate problem with a known/simpler pattern. Closes bazelbuild#10856. PiperOrigin-RevId: 298953350
Description of the problem / feature request:
Add support for reading a list of target patterns for from a file for
bazel {build,test}
(in addition to supporting target patterns in argv)Feature requests: what underlying problem are you trying to solve with this feature?
We have a command based on query that selects a set of targets (based on this bazel-discuss and #7962) and passes these to bazel build. Roughly something like:
However, this becomes problematic if the output of query + modifications is long, specifically longer than the
ARG_MAX
the system supports:I currently work around this by using xargs, as it splits the incoming stream into multiple bazel invocations if it is too big.
I don't however want multiple bazel invocations as this means I need to support reading/merging multiple logs, build event files etc etc.
Ideally bazel would support reading a list of arguments from a file, maybe even generically like:
But at least I'd like to find a way to have bazel test and build read the list of target patterns from a file (or any other method of passing it a list of arbitrary length).
What operating system are you running Bazel on?
MacOS / Linux
What's the output of
bazel info release
?release 0.26.1
Have you found anything relevant by searching the web?
The bazel query documentation suggests using shell command substitution like:
However, this fails once the query output is longer than
ARG_MAX
as described above.bazel/site/docs/query.html
Lines 490 to 493 in aca672f
The text was updated successfully, but these errors were encountered: