Add //visibility:any_partition

When we convert the partitions to be built with soong, there will
likely be separate partition modules per product. This means that a
lot of installable modules will have to be visible to a lot of
partitions. To make this easier, add the //visibility:any_partition
visibility spec, which allows the module to be used from any module
of type android_filesystem or android_system_image.

Fixes: 321000103
Test: go test
Change-Id: Iea1f1ab7d88dfdb1fd00f19eb8c9941693a2375f
This commit is contained in:
Cole Faust
2024-02-07 11:28:26 -08:00
parent 617b3e288a
commit 894bb3b530
4 changed files with 104 additions and 37 deletions

View File

@@ -250,8 +250,8 @@ func (s *singletonContextAdaptor) FinalModule(module Module) Module {
}
func (s *singletonContextAdaptor) ModuleVariantsFromName(referer Module, name string) []Module {
// get qualified module name for visibility enforcement
qualified := createQualifiedModuleName(s.ModuleName(referer), s.ModuleDir(referer))
// get module reference for visibility enforcement
qualified := createVisibilityModuleReference(s.ModuleName(referer), s.ModuleDir(referer), s.ModuleType(referer))
modules := s.SingletonContext.ModuleVariantsFromName(referer, name)
result := make([]Module, 0, len(modules))
@@ -262,7 +262,7 @@ func (s *singletonContextAdaptor) ModuleVariantsFromName(referer Module, name st
depDir := s.ModuleDir(module)
depQualified := qualifiedModuleName{depDir, depName}
// Targets are always visible to other targets in their own package.
if depQualified.pkg != qualified.pkg {
if depQualified.pkg != qualified.name.pkg {
rule := effectiveVisibilityRules(s.Config(), depQualified)
if !rule.matches(qualified) {
s.ModuleErrorf(referer, "module %q references %q which is not visible to this module\nYou may need to add %q to its visibility",