Gazelle is a Bazel build file generator for Bazel projects. It natively supports Go and protobuf, and it may be extended to support new languages and custom rule sets.
Apache License 2.0
1.2k
stars
380
forks
source link
default_visibility directive not setting visibility correctly #1457
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
MacOs Ventura 13.2, ARM64
What did you do?
Created a project with multiple subdirectories
Added gazelle directive default_visbility in the top level folder's BUILD.bazel
#gazelle:default_visibility <path_to_project>:__subpackages__
to set default visibility of all folder & its subpackages to this visibility
Ran gazelle
What did you expect to see?
All the subpackages having the following visibility:
package(default_visibility = ["//<path_to_project>:__subpackages__"])
What did you see instead?
In the subfolder instead of the above got the visibility attribute set to public
Running gazelle a 2nd time adds
package(default_visibility = ["//<path_to_project>:__subpackages__"])
However, the first run already set the visibility attribute and according to rules-target-visibility takes precedence over default_visibility. Hence, we default_visibility does not apply.
Thanks for this report. Does the BUILD.bazel file in your subdirectory by any chance include a exports_files function? I have been trying to sort out an issue related to this function.
What version of gazelle are you using?
v0.29.0
What version of rules_go are you using?
v0.38.1
What version of Bazel are you using?
v6.0.0
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
MacOs Ventura 13.2, ARM64
What did you do?
Created a project with multiple subdirectories
Added gazelle directive default_visbility in the top level folder's BUILD.bazel
#gazelle:default_visibility <path_to_project>:__subpackages__
to set default visibility of all folder & its subpackages to this visibilityRan gazelle
What did you expect to see?
All the subpackages having the following visibility:
package(default_visibility = ["//<path_to_project>:__subpackages__"])
What did you see instead?
In the subfolder instead of the above got the visibility attribute set to public
Running gazelle a 2nd time adds
package(default_visibility = ["//<path_to_project>:__subpackages__"])
However, the first run already set the visibility attribute and according to rules-target-visibility takes precedence over default_visibility. Hence, we default_visibility does not apply.