apex: apex_available with prefix

We now support prefix form (com.foo.*) in apex_available list.

Bug: 360265761
Test: m --no-skip-soong-tests
Change-Id: I50ab884651dd6321950cfd4563b59ef3ed0f07fd
This commit is contained in:
Jooyung Han
2024-08-16 17:14:21 +09:00
parent a5289ac9ef
commit 9a419e28f5
3 changed files with 141 additions and 6 deletions

View File

@@ -2767,10 +2767,21 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) {
return true
}
// Let's give some hint for apex_available
hint := fmt.Sprintf("%q", apexName)
if strings.HasPrefix(apexName, "com.") && !strings.HasPrefix(apexName, "com.android.") && strings.Count(apexName, ".") >= 2 {
// In case of a partner APEX, prefix format might be an option.
components := strings.Split(apexName, ".")
components[len(components)-1] = "*"
hint += fmt.Sprintf(" or %q", strings.Join(components, "."))
}
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)
"Consider adding %s to 'apex_available' property of %q",
fromName, toName, ctx.GetPathString(true), hint, toName)
// Visit this module's dependencies to check and report any issues with their availability.
return true
})