From df915ff3db45fdf52f2423be81ce29a7e2c47ab6 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Mon, 30 Mar 2020 17:58:21 +0100 Subject: [PATCH] Improve missing apex_available message The apex available check can traverse quite a long path (5+ steps) to get from the apex to a module that is missing the apex from its apex_available property. Understanding where that dependency came from can often require examining the dependency path which can be difficult. This change adds the path to the error to simplify that process. Test: m nothing Bug: 152762638 Change-Id: Ic4eb169dc2026cd8339d49e23b25d6d1c3879750 --- apex/apex.go | 8 ++++++-- apex/apex_test.go | 8 +++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index ebc59694e..bc992f063 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -1976,7 +1976,7 @@ func (c *flattenedApexContext) InstallBypassMake() bool { // 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 { + ctx.WalkDeps(func(child, parent android.Module) bool { am, ok := child.(android.ApexModule) if !ok || !am.CanHaveApexVariants() { return false @@ -2037,7 +2037,11 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { if externalDep || to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) { return } - ctx.ModuleErrorf("%q requires %q that is not available for the APEX.", fromName, toName) + message := "" + for _, m := range ctx.GetWalkPath()[1:] { + message = fmt.Sprintf("%s\n -> %s", message, m.String()) + } + ctx.ModuleErrorf("%q requires %q that is not available for the APEX. Dependency path:%s", fromName, toName, message) }) } diff --git a/apex/apex_test.go b/apex/apex_test.go index 2bdecb73c..c01ba1459 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -3538,7 +3538,13 @@ func TestApexAvailable_DirectDep(t *testing.T) { func TestApexAvailable_IndirectDep(t *testing.T) { // libbbaz is an indirect dep - testApexError(t, "requires \"libbaz\" that is not available for the APEX", ` + testApexError(t, `requires "libbaz" that is not available for the APEX. Dependency path: +.*-> libfoo.*link:shared.* +.*-> libfoo.*link:static.* +.*-> libbar.*link:shared.* +.*-> libbar.*link:static.* +.*-> libbaz.*link:shared.* +.*-> libbaz.*link:static.*`, ` apex { name: "myapex", key: "myapex.key",