Search code examples
bazel

bazel build wildcards with suffix


I have some bazel rules like so:

//a/b/c:foo_x
//a/b/c:foo_y
//a/b/d:bar_x
//a/b/d:bar_y
//a/b/e/f/g:qux_x
//a/b/e/f/g:qux_y

Is there a way to say I want to build all rules with the "_x" suffix? I know that Bazel supports wildcards such as //a/... but I would like greater control over what exactly I am building.


Solution

  • Use a combination of query and grep.

    $ bazel build $(bazel query //a/b/... | grep -E ":.+_x")