-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
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:
bazel query ... | grep | sed | awk > foo
bazel test $(<foo)
However, this becomes problematic if the output of query + modifications is long, specifically longer than the ARG_MAX the system supports:
# write non-null arg file that is longer than getconf ARG_MAX
$ dd if=/dev/zero bs=1 count=$((1+$(getconf ARG_MAX))) | tr "\0" "\7" > foo
$ bazel build $(<foo)
-bash: /usr/local/bin/bazel: Argument list too long
I currently work around this by using xargs, as it splits the incoming stream into multiple bazel invocations if it is too big.
bazel query ... | grep | sed | awk | xargs bazel test --
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:
$ cat argfile.txt
--bazelrc=/dev/null
build
--
//some/...
...
//targets:here
$ bazel --argfile=argfile.txt
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:
bazel query deps(//my:target) --output=label | grep ... | sed ... | awk ... > foo
bazel query "kind(cc_binary, set($(<foo)))"
However, this fails once the query output is longer than ARG_MAX as described above.
Lines 490 to 493 in aca672f
| <pre> | |
| bazel query deps(//my:target) --output=label | grep ... | sed ... | awk ... > foo | |
| bazel query "kind(cc_binary, set($(<foo)))" | |
| </pre> |
- Issue Windows: Add response file support #3750 seems related, but this is not restricted to windows.