Add aquery output format with one command per line #22389
Labels
awaiting-user-response
Awaiting a response from the author
team-CLI
Console UI
type: feature request
Description of the feature request:
Make it so that
bazel aquery --output=commands
prints a list of commands with one command per line, similar toninja -t commands
.Which category does this issue belong to?
CLI
What underlying problem are you trying to solve with this feature?
When debugging build issues I frequently need to extract specific compile commands. Although
bazel aquery 'deps(target)'
prints the command lines used to build a specific target, each command will be printed over N lines with one argument per line, which makes it harder to use command line tools to extract commands. For example, I cannotgrep
the output for a particular file name to extract all commands dealing with that file. And when I copy-paste the command into my terminal to edit it before running it, one-line-per-argument would typically cause the command to become taller than my terminal window, which makes it harder to edit in most shells. When working with Ninja-based build systems, I normally use thecommands
tool andgrep
its output. With Bazel I ended up writing anawk
script that converts theaquery
output into the one-line-per-command format:But this script is clearly sensitive to Bazel's specific
aquery
format, which I imagine might change in the future. It also doesn't include environment variables, which fortunately I haven't needed so far. I guess it might be possible to feed one of the proto output formats into a separate program that converts the protos into the one-line-per-command format, but that would be a lot more work than my simple awk script. So the request is to add a straightforward and future-proof way to print the command list in this format, for example by adding an--output=commands
flag.Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?release 7.1.2
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: