Add explicit visibility on the self package in EffectiveVisibilityRules.
Modules in a package is implicitly visible within the same package.
When making effective visibility rules which work from another location
that visibility needs to be mentioned explicitly. In practice this
allows prebuilts to remain visible to other modules in the source
package when the prebuilts are preferred.
Test: m nothing
Test: m conscrypt-module-sdk, check that the snapshot Soong modules give
visibility to //external/conscrypt
Bug: 151303681
Merged-In: I404f6e5ca7021974a8c7be5e4d6b4982c050b8a5
Change-Id: I404f6e5ca7021974a8c7be5e4d6b4982c050b8a5
(cherry picked from commit 0641d189d0
)
This commit is contained in:
parent
68e9d96d61
commit
f8533bc636
2 changed files with 23 additions and 4 deletions
|
@ -496,6 +496,13 @@ func EffectiveVisibilityRules(ctx BaseModuleContext, module Module) []string {
|
|||
|
||||
rule := effectiveVisibilityRules(ctx.Config(), qualified)
|
||||
|
||||
// Modules are implicitly visible to other modules in the same package,
|
||||
// without checking the visibility rules. Here we need to add that visibility
|
||||
// explicitly.
|
||||
if rule != nil && !rule.matches(qualified) {
|
||||
rule = append(rule, packageRule{dir})
|
||||
}
|
||||
|
||||
return rule.Strings()
|
||||
}
|
||||
|
||||
|
|
|
@ -155,14 +155,20 @@ func TestSnapshotVisibility(t *testing.T) {
|
|||
java_import {
|
||||
name: "mysdk_myjavalib@current",
|
||||
sdk_member_name: "myjavalib",
|
||||
visibility: ["//other/foo"],
|
||||
visibility: [
|
||||
"//other/foo",
|
||||
"//package",
|
||||
],
|
||||
jars: ["java/myjavalib.jar"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "myjavalib",
|
||||
prefer: false,
|
||||
visibility: ["//other/foo"],
|
||||
visibility: [
|
||||
"//other/foo",
|
||||
"//package",
|
||||
],
|
||||
jars: ["java/myjavalib.jar"],
|
||||
}
|
||||
|
||||
|
@ -183,14 +189,20 @@ java_import {
|
|||
java_import {
|
||||
name: "mysdk_mydefaultedjavalib@current",
|
||||
sdk_member_name: "mydefaultedjavalib",
|
||||
visibility: ["//other/bar"],
|
||||
visibility: [
|
||||
"//other/bar",
|
||||
"//package",
|
||||
],
|
||||
jars: ["java/mydefaultedjavalib.jar"],
|
||||
}
|
||||
|
||||
java_import {
|
||||
name: "mydefaultedjavalib",
|
||||
prefer: false,
|
||||
visibility: ["//other/bar"],
|
||||
visibility: [
|
||||
"//other/bar",
|
||||
"//package",
|
||||
],
|
||||
jars: ["java/mydefaultedjavalib.jar"],
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue