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
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user