I am trying to query the list of Bazel targets having public visibility. Some of our Bazel targets have visibility
specified explicitly, e.g.:
cc_library(
name = "xxx_util",
visibility = ["//visibility:public",],
...
)
while most targets are implicitly public, as their BUILD
files have default public visibility specified, e.g.
package(default_visibility = ["//visibility:public"])
I need a list of all such targets, so that I can copy their output to a certain location automatically after my Bazel workspace is built.
I am new to Bazel and can't figure out the query...
Visibility controls whether a target can be used (depended on) by targets in other packages. This helps other people distinguish between your library's public API and its implementation details, and is an important tool to help enforce structure as your workspace grows.
Targets. A package is a container. The elements of a package are called targets.
On Linux/macOS/Unixes: /etc/bazel. bazelrc. On Windows: %ProgramData%\bazel.
I think the previous answer does cover the attribute query for visibility attribute restricted results. For posterity, I would add that if you simply want to find all targets from current directory, you could do:
bazel query ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With