Reputation: 24473
I have a directory structure that looks like this:
some-root/
└── my-stuff/
├── BUILD
├── foo/
│ └── BUILD
├── bar/
│ └── BUILD
└── baz/
└── BUILD
I'd like to have a target like //some-root/my-stuff:update
which runs all of //some-root/my-stuff/foo:update
, //some-root/my-stuff/bar:update
, //some-root/my-stuff/baz:update
.
I can do this by listing each target as a dependency. However, if I have many of these and I want to be able to add more it becomes a pain (it's easy to add a bunch of subdirectories and miss adding one to the parent BUILD
file).
Is there a way to do a wildcard labels or otherwise discover labels from file paths? I'm able to do bazel test //some-root/my-stuff/...
to run all tests under a path, but I can't seem to use that pattern inside of a BUILD
file and what I'd want is more like bazel run //some-root/my-stuff/...:update
which doesn't work either.
Upvotes: 4
Views: 2930
Reputation: 1940
You can get all labels with the name update
from the command line:
bazel query "attr(name, '^update$', //...)"
and take the output of query and manually edit your dependencies.
But unfortunately you can not put this into a genquery rule
(which would generate the list of targets to depend on), because
queries containing wildcard target specifications (e.g. //pkg:* or //pkg:all) are not allowed
Upvotes: 4