From 201cedd608b8442bdb861fdb816b5ac84e115eba Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 7 Feb 2020 17:25:49 +0900 Subject: [PATCH] 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 --- apex/apex.go | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index d15b6c990..1adeb7dbb 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1936,21 +1936,9 @@ func (c *flattenedApexContext) InstallBypassMake() bool { 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 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { // 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 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { // 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 {