Make it possible to extend default_visibility for targets in a macro instead of override it #25314
Labels
team-Loading-API
BUILD file and macro processing: labels, package(), visibility, glob
type: feature request
untriaged
Description of the feature request:
Today, if you want targets within a macro to always be visible to certain other targets, you can't also inherit default visibility.
Which category does this issue belong to?
Loading API
What underlying problem are you trying to solve with this feature?
E.g. consider a macro like
now suppose I want the targets created by foo() to always be visible to
"//bar:__subpackages__"
- regardless of default_visibility. I can writebut this means that the following:
:my_target
won't be visible to//baz:__pkg__
anymore, as the added visibility means we can't pass visibility=None and the default_visibility will then be ignored.Today this has to be manually handled by BUILD file authors or by BUILD file generators.
If bazel included a builtin function that could return the default visibility, e.g.
native.package_default_visibility()
, the macro could call that and use that:which would get us the best of both worlds - macros could opt in to mutate visibility while also honoring default_visibility, without pushing the problem onto BUILD file authors or generators.
Which operating system are you running Bazel on?
linux
What is the output of
bazel info release
?release 6.5.0-b940786cac09f826f5b96eaba2ff36784ad4869d
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: