Merge "Friendly error message on apex_available and min_sdk_version checks"

This commit is contained in:
Treehugger Robot 2021-03-05 03:30:11 +00:00 committed by Gerrit Code Review
commit 4a349ab66b
3 changed files with 11 additions and 5 deletions

View file

@ -849,8 +849,12 @@ func CheckMinSdkVersion(m UpdatableModule, ctx ModuleContext, minSdkVersion ApiL
if err := to.ShouldSupportSdkVersion(ctx, minSdkVersion); err != nil {
toName := ctx.OtherModuleName(to)
if ver, ok := minSdkVersionAllowlist[toName]; !ok || ver.GreaterThan(minSdkVersion) {
ctx.OtherModuleErrorf(to, "should support min_sdk_version(%v) for %q: %v. Dependency path: %s",
minSdkVersion, ctx.ModuleName(), err.Error(), ctx.GetPathString(false))
ctx.OtherModuleErrorf(to, "should support min_sdk_version(%v) for %q: %v."+
"\n\nDependency path: %s\n\n"+
"Consider adding 'min_sdk_version: %q' to %q",
minSdkVersion, ctx.ModuleName(), err.Error(),
ctx.GetPathString(false),
minSdkVersion, ctx.ModuleName())
return false
}
}

View file

@ -2244,8 +2244,10 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) {
return true
}
ctx.ModuleErrorf("%q requires %q that doesn't list the APEX under 'apex_available'. Dependency path:%s",
fromName, toName, ctx.GetPathString(true))
ctx.ModuleErrorf("%q requires %q that doesn't list the APEX under 'apex_available'."+
"\n\nDependency path:%s\n\n"+
"Consider adding %q to 'apex_available' property of %q",
fromName, toName, ctx.GetPathString(true), apexName, toName)
// Visit this module's dependencies to check and report any issues with their availability.
return true
})

View file

@ -5315,7 +5315,7 @@ func TestApexAvailable_DirectDep(t *testing.T) {
func TestApexAvailable_IndirectDep(t *testing.T) {
// libbbaz is an indirect dep
testApexError(t, `requires "libbaz" that doesn't list the APEX under 'apex_available'. Dependency path:
testApexError(t, `requires "libbaz" that doesn't list the APEX under 'apex_available'.\n\nDependency path:
.*via tag apex\.dependencyTag.*name:sharedLib.*
.*-> libfoo.*link:shared.*
.*via tag cc\.libraryDependencyTag.*Kind:sharedLibraryDependency.*