add walkPayloadDeps
The function visits dependencies of an APEX that contribute to the
payload. checkApexAvailability is rewritten using the generic function.
There is no change in behavior.
Bug: N/A
Test: m
Change-Id: I1a8b4eb0a60a432f667a61b4f6f457c3b8f1cd3d
diff --git a/apex/apex.go b/apex/apex.go
index d15b6c9..1adeb7d 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1936,21 +1936,9 @@
return true
}
-// Ensures that the dependencies are marked as available for this APEX
-func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
- // Let's be practical. Availability for test, host, and the VNDK apex isn't important
- if ctx.Host() || a.testApex || a.vndkApex {
- return
- }
-
- checkDep := func(ctx android.ModuleContext, am android.ApexModule) {
- apexName := ctx.ModuleName()
- if am.AvailableFor(apexName) || whitelistedApexAvailable(apexName, am) {
- return
- }
- ctx.ModuleErrorf("requires %q that is not available for the APEX.", am.Name())
- }
-
+// Visit dependencies that contributes to the payload of this APEX
+func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext,
+ do func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool)) {
ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
am, ok := child.(android.ApexModule)
if !ok || !am.CanHaveApexVariants() {
@@ -1960,7 +1948,7 @@
// Check for the direct dependencies that contribute to the payload
if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok {
if dt.payload {
- checkDep(ctx, am)
+ do(ctx, parent, am, false /* externalDep */)
return true
}
return false
@@ -1968,15 +1956,33 @@
// Check for the indirect dependencies if it is considered as part of the APEX
if am.DepIsInSameApex(ctx, am) {
- checkDep(ctx, am)
+ do(ctx, parent, am, false /* externalDep */)
return true
}
+ do(ctx, parent, am, true /* externalDep */)
+
// As soon as the dependency graph crosses the APEX boundary, don't go further.
return false
})
}
+// Ensures that the dependencies are marked as available for this APEX
+func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
+ // Let's be practical. Availability for test, host, and the VNDK apex isn't important
+ if ctx.Host() || a.testApex || a.vndkApex {
+ return
+ }
+
+ a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
+ apexName := ctx.ModuleName()
+ if externalDep || to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, to) {
+ return
+ }
+ ctx.ModuleErrorf("requires %q that is not available for the APEX.", to.Name())
+ })
+}
+
func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
switch a.properties.ApexType {