From 31be3526127a796ce5c243a6a5bca0092ffd6e0a Mon Sep 17 00:00:00 2001 From: Jeongik Cha Date: Tue, 12 Mar 2024 19:34:29 +0900 Subject: [PATCH] //visibility:any_partition can be used with another visibility field Bug: 321000103 Test: m nothing Change-Id: I2f65ff4d51c65f974e2dc79c94dfefe180ddbfe4 --- android/visibility.go | 5 ++++- android/visibility_test.go | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/android/visibility.go b/android/visibility.go index b3875620f..79a534f56 100644 --- a/android/visibility.go +++ b/android/visibility.go @@ -303,7 +303,10 @@ func checkRules(ctx BaseModuleContext, currentPkg, property string, visibility [ if pkg == "visibility" { switch name { - case "private", "public", "any_partition": + case "private", "public": + case "any_partition": + // any_partition can be used with another visibility fields + continue case "legacy_public": ctx.PropertyErrorf(property, "//visibility:legacy_public must not be used") continue diff --git a/android/visibility_test.go b/android/visibility_test.go index d4add7d32..bb43b1fa1 100644 --- a/android/visibility_test.go +++ b/android/visibility_test.go @@ -1920,6 +1920,26 @@ var visibilityTests = []struct { }`), }, }, + { + name: "any_partition visibility works with the other visibility", + fs: MockFS{ + "top/Android.bp": []byte(` + android_filesystem { + name: "foo", + deps: ["bar"], + }`), + "top2/Android.bp": []byte(``), + "top/nested/Android.bp": []byte(` + package(default_visibility=["//visibility:private"]) + mock_library { + name: "bar", + visibility: [ + "//top2", + "//visibility:any_partition" + ], + }`), + }, + }, { name: "any_partition visibility doesn't work for non-partitions", fs: MockFS{