bazelbazel-query

How do I query for targets visible from a specific targets?


Bazel uses the concept of visibility to limit which targets can depend on which targets. Given a target //my:foo, I am looking for a way to query Bazel for a list of targets visible to //my:foo.

Basically, I am trying to figure out which targets in the workspace the target //my:foo can depend on. Any idea if this is possible at all?


Solution

  • Query has a visible function. So, bazel query 'visible(//my:foo, //...)' prints all the targets that //my:foo may depend on.