From e501bb4d48414b9bf45f31712d75bdf5e3faa789 Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Thu, 15 Oct 2020 11:46:38 -0700 Subject: [PATCH] Expand visiblity error Expands the error to suggest a potential fix, giving the package path for the module that needs visiblity. Test: go test soong tests Bug: 168926331 Change-Id: Ie95dec03f5e2c3190bfaed1f0e5789eeb0ab1878 --- android/visibility.go | 2 +- android/visibility_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/android/visibility.go b/android/visibility.go index 51d561120..503a02174 100644 --- a/android/visibility.go +++ b/android/visibility.go @@ -443,7 +443,7 @@ func visibilityRuleEnforcer(ctx TopDownMutatorContext) { rule := effectiveVisibilityRules(ctx.Config(), depQualified) if !rule.matches(qualified) { - ctx.ModuleErrorf("depends on %s which is not visible to this module", depQualified) + ctx.ModuleErrorf("depends on %s which is not visible to this module\nYou may need to add %q to its visibility", depQualified, "//"+ctx.ModuleDir()) } }) } diff --git a/android/visibility_test.go b/android/visibility_test.go index 9d9e57438..cb5ef35b3 100644 --- a/android/visibility_test.go +++ b/android/visibility_test.go @@ -731,7 +731,7 @@ var visibilityTests = []struct { }`), }, expectedErrors: []string{ - `module "libnamespace" variant "android_common": depends on //top:libexample which is not visible to this module`, + `module "libnamespace" variant "android_common": depends on //top:libexample which is not visible to this module\nYou may need to add "//namespace" to its visibility`, }, }, { @@ -760,7 +760,7 @@ var visibilityTests = []struct { }`), }, expectedErrors: []string{ - `module "libnamespace" variant "android_common": depends on //top:libexample which is not visible to this module`, + `module "libnamespace" variant "android_common": depends on //top:libexample which is not visible to this module\nYou may need to add "//namespace" to its visibility`, }, }, {