Friendly error message on apex_available and min_sdk_version checks

1) suggest a fix at the end of the message
2) add new lines around the dependency path so that they are visually
separated from rest of the error message

Bug: N/A
Test: m with an intentional break
error: bionic/apex/Android.bp:32:1: module "com.android.runtime" variant "android_common_com.android.runtime_image": "libutils_headers" requires "libsystem_headers" that doesn't list the APEX under 'apex_available'.

Dependency path:
           via tag apex.dependencyTag: { name:executable payload:true}
    -> crash_dump{os:android,image:,arch:arm_armv8-a,sdk:,apex:apex10000}
           via tag cc.libraryDependencyTag: { Kind:staticLibraryDependency Order:normalLibraryDependency wholeStatic:false reexportFlags:false explicitlyVersioned:false dataLib:false ndk:false staticUnwinder:false makeSuffix: skipApexAllowedDependenciesCheck:false excludeInApex:false}
    -> libtombstoned_client_static{os:android,image:,arch:arm_armv8-a,sdk:,link:static,apex:apex10000}
           via tag cc.libraryDependencyTag: { Kind:staticLibraryDependency Order:normalLibraryDependency wholeStatic:true reexportFlags:true explicitlyVersioned:false dataLib:false ndk:false staticUnwinder:false makeSuffix: skipApexAllowedDependenciesCheck:false excludeInApex:false}
    -> libcutils{os:android,image:,arch:arm_armv8-a,sdk:,link:static,asan:,apex:apex10000}
           via tag cc.libraryDependencyTag: { Kind:headerLibraryDependency Order:normalLibraryDependency wholeStatic:false reexportFlags:false explicitlyVersioned:false dataLib:false ndk:false staticUnwinder:false makeSuffix: skipApexAllowedDependenciesCheck:false excludeInApex:false}
    -> libutils_headers{os:android,image:,arch:arm_armv8-a,sdk:,asan:,apex:apex10000}
           via tag cc.libraryDependencyTag: { Kind:headerLibraryDependency Order:normalLibraryDependency wholeStatic:false reexportFlags:true explicitlyVersioned:false dataLib:false ndk:false staticUnwinder:false makeSuffix: skipApexAllowedDependenciesCheck:false excludeInApex:false}
    -> libsystem_headers{os:android,image:,arch:arm_armv8-a,sdk:,asan:,apex:apex10000}

Consider adding "com.android.runtime" to 'apex_available' property of "libsystem_headers"

Change-Id: I09f92c3086ea433780133a33ba0ad73baee6dc41
This commit is contained in:
Jiyong Park 2021-03-04 13:03:10 +09:00
parent 30e3e9d21d
commit 767dbd9d3b
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 { if err := to.ShouldSupportSdkVersion(ctx, minSdkVersion); err != nil {
toName := ctx.OtherModuleName(to) toName := ctx.OtherModuleName(to)
if ver, ok := minSdkVersionAllowlist[toName]; !ok || ver.GreaterThan(minSdkVersion) { if ver, ok := minSdkVersionAllowlist[toName]; !ok || ver.GreaterThan(minSdkVersion) {
ctx.OtherModuleErrorf(to, "should support min_sdk_version(%v) for %q: %v. Dependency path: %s", ctx.OtherModuleErrorf(to, "should support min_sdk_version(%v) for %q: %v."+
minSdkVersion, ctx.ModuleName(), err.Error(), ctx.GetPathString(false)) "\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 return false
} }
} }

View file

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

View file

@ -5184,7 +5184,7 @@ func TestApexAvailable_DirectDep(t *testing.T) {
func TestApexAvailable_IndirectDep(t *testing.T) { func TestApexAvailable_IndirectDep(t *testing.T) {
// libbbaz is an indirect dep // 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.* .*via tag apex\.dependencyTag.*name:sharedLib.*
.*-> libfoo.*link:shared.* .*-> libfoo.*link:shared.*
.*via tag cc\.libraryDependencyTag.*Kind:sharedLibraryDependency.* .*via tag cc\.libraryDependencyTag.*Kind:sharedLibraryDependency.*