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
diff --git a/android/visibility_test.go b/android/visibility_test.go
index a66f0b6..d4add7d 100644
--- a/android/visibility_test.go
+++ b/android/visibility_test.go
@@ -1904,6 +1904,38 @@
}`),
},
},
+ {
+ name: "any_partition visibility works",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ android_filesystem {
+ name: "foo",
+ deps: ["bar"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ package(default_visibility=["//visibility:private"])
+ mock_library {
+ name: "bar",
+ visibility: ["//visibility:any_partition"],
+ }`),
+ },
+ },
+ {
+ name: "any_partition visibility doesn't work for non-partitions",
+ fs: MockFS{
+ "top/Android.bp": []byte(`
+ mock_library {
+ name: "foo",
+ deps: ["bar"],
+ }`),
+ "top/nested/Android.bp": []byte(`
+ mock_library {
+ name: "bar",
+ visibility: ["//visibility:any_partition"],
+ }`),
+ },
+ expectedErrors: []string{`module "foo" variant "android_common": depends on //top/nested:bar which is not visible to this module`},
+ },
}
func TestVisibility(t *testing.T) {
@@ -1925,6 +1957,8 @@
ctx.RegisterModuleType("mock_library", newMockLibraryModule)
ctx.RegisterModuleType("mock_parent", newMockParentFactory)
ctx.RegisterModuleType("mock_defaults", defaultsFactory)
+ // For testing //visibility:any_partition. The module type doesn't matter, just that it's registered under the name "android_filesystem"
+ ctx.RegisterModuleType("android_filesystem", newMockLibraryModule)
}),
prepareForTestWithFakePrebuiltModules,
// Add additional files to the mock filesystem