From c0609c603c3df0de32571a48c1cdb2860eda59e3 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Mon, 1 Mar 2021 17:27:16 +0000 Subject: [PATCH] Make prebuilt_apex report an error if no apex file is found Previously, if an appropriate src property was not specified it would return "" which resolves to the top level directory. This change causes it to report an error. Bug: 181267622 Test: m droid Change-Id: Ia5be324a0eff18e43b352d71c6768c8767986053 --- apex/apex_test.go | 8 ++++++++ apex/prebuilt.go | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/apex/apex_test.go b/apex/apex_test.go index 87d551b74..bdff41e6d 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -4316,6 +4316,14 @@ func TestPrebuilt(t *testing.T) { } } +func TestPrebuiltMissingSrc(t *testing.T) { + testApexError(t, `module "myapex" variant "android_common".*: prebuilt_apex does not support "arm64_armv8-a"`, ` + prebuilt_apex { + name: "myapex", + } + `) +} + func TestPrebuiltFilenameOverride(t *testing.T) { ctx := testApex(t, ` prebuilt_apex { diff --git a/apex/prebuilt.go b/apex/prebuilt.go index 68f285936..8c7e64c6a 100644 --- a/apex/prebuilt.go +++ b/apex/prebuilt.go @@ -152,14 +152,17 @@ func (p *ApexFileProperties) prebuiltApexSelector(ctx android.BaseModuleContext, src = String(p.Arch.X86.Src) case android.X86_64: src = String(p.Arch.X86_64.Src) - default: - ctx.OtherModuleErrorf(prebuilt, "prebuilt_apex does not support %q", multiTargets[0].Arch.String()) - return nil } if src == "" { src = String(p.Src) } + if src == "" { + ctx.OtherModuleErrorf(prebuilt, "prebuilt_apex does not support %q", multiTargets[0].Arch.String()) + // Drop through to return an empty string as the src (instead of nil) to avoid the prebuilt + // logic from reporting a more general, less useful message. + } + return []string{src} }