summaryrefslogtreecommitdiff
path: root/android/deapexer.go
diff options
context:
space:
mode:
author Martin Stjernholm <mast@google.com> 2021-09-17 01:44:12 +0100
committer Martin Stjernholm <mast@google.com> 2021-09-23 17:19:55 +0100
commit4482560cc73f16f09eecda42751cf2f8dc72e7de (patch)
tree21b3906c4fa5b2844bc9bb7527e26a4d0d6df17e /android/deapexer.go
parent8be1e6db1640d51ca4478fec2c4f20d71b115734 (diff)
Consolidate the code to resolve a deapexer module dependency.
It will get more logic in upcoming CLs. Add a property to DeapexerInfo for the APEX name, for use in error messages. Test: m nothing Bug: 192006406 Change-Id: I957f3df8b34543a38cde38768dac93e78132d672
Diffstat (limited to 'android/deapexer.go')
-rw-r--r--android/deapexer.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/android/deapexer.go b/android/deapexer.go
index 9290481d4..bed657464 100644
--- a/android/deapexer.go
+++ b/android/deapexer.go
@@ -69,6 +69,8 @@ import (
// The information exported by the `deapexer` module, access it using `DeapxerInfoProvider`.
type DeapexerInfo struct {
+ apexModuleName string
+
// map from the name of an exported file from a prebuilt_apex to the path to that file. The
// exported file name is the apex relative path, e.g. javalib/core-libart.jar.
//
@@ -76,6 +78,11 @@ type DeapexerInfo struct {
exports map[string]WritablePath
}
+// ApexModuleName returns the name of the APEX module that provided the info.
+func (i DeapexerInfo) ApexModuleName() string {
+ return i.apexModuleName
+}
+
// PrebuiltExportPath provides the path, or nil if not available, of a file exported from the
// prebuilt_apex that created this ApexInfo.
//
@@ -95,9 +102,10 @@ var DeapexerProvider = blueprint.NewProvider(DeapexerInfo{})
// for use with a prebuilt_apex module.
//
// See apex/deapexer.go for more information.
-func NewDeapexerInfo(exports map[string]WritablePath) DeapexerInfo {
+func NewDeapexerInfo(apexModuleName string, exports map[string]WritablePath) DeapexerInfo {
return DeapexerInfo{
- exports: exports,
+ apexModuleName: apexModuleName,
+ exports: exports,
}
}
@@ -133,3 +141,20 @@ type RequiresFilesFromPrebuiltApexTag interface {
// Method that differentiates this interface from others.
RequiresFilesFromPrebuiltApex()
}
+
+// FindDeapexerProviderForModule searches through the direct dependencies of the current context
+// module for a DeapexerTag dependency and returns its DeapexerInfo. If there is an error then it is
+// reported with ctx.ModuleErrorf and nil is returned.
+func FindDeapexerProviderForModule(ctx ModuleContext) *DeapexerInfo {
+ var di *DeapexerInfo
+ ctx.VisitDirectDepsWithTag(DeapexerTag, func(m Module) {
+ p := ctx.OtherModuleProvider(m, DeapexerProvider).(DeapexerInfo)
+ di = &p
+ })
+ if di != nil {
+ return di
+ }
+ ai := ctx.Provider(ApexInfoProvider).(ApexInfo)
+ ctx.ModuleErrorf("No prebuilt APEX provides a deapexer module for APEX variant %s", ai.ApexVariationName)
+ return nil
+}