summaryrefslogtreecommitdiff
path: root/android/deapexer.go
diff options
context:
space:
mode:
Diffstat (limited to 'android/deapexer.go')
-rw-r--r--android/deapexer.go58
1 files changed, 45 insertions, 13 deletions
diff --git a/android/deapexer.go b/android/deapexer.go
index 6a93f6087..61ae64ea5 100644
--- a/android/deapexer.go
+++ b/android/deapexer.go
@@ -15,6 +15,7 @@
package android
import (
+ "fmt"
"strings"
"github.com/google/blueprint"
@@ -78,6 +79,14 @@ type DeapexerInfo struct {
//
// See Prebuilt.ApexInfoMutator for more information.
exports map[string]WritablePath
+
+ // name of the java libraries exported from the apex
+ // e.g. core-libart
+ exportedModuleNames []string
+
+ // name of the java libraries exported from the apex that should be dexpreopt'd with the .prof
+ // file embedded in the apex
+ dexpreoptProfileGuidedExportedModuleNames []string
}
// ApexModuleName returns the name of the APEX module that provided the info.
@@ -96,21 +105,34 @@ func (i DeapexerInfo) PrebuiltExportPath(apexRelativePath string) WritablePath {
return path
}
+func (i DeapexerInfo) GetExportedModuleNames() []string {
+ return i.exportedModuleNames
+}
+
// Provider that can be used from within the `GenerateAndroidBuildActions` of a module that depends
// on a `deapexer` module to retrieve its `DeapexerInfo`.
-var DeapexerProvider = blueprint.NewProvider(DeapexerInfo{})
+var DeapexerProvider = blueprint.NewProvider[DeapexerInfo]()
// NewDeapexerInfo creates and initializes a DeapexerInfo that is suitable
// for use with a prebuilt_apex module.
//
// See apex/deapexer.go for more information.
-func NewDeapexerInfo(apexModuleName string, exports map[string]WritablePath) DeapexerInfo {
+func NewDeapexerInfo(apexModuleName string, exports map[string]WritablePath, moduleNames []string) DeapexerInfo {
return DeapexerInfo{
- apexModuleName: apexModuleName,
- exports: exports,
+ apexModuleName: apexModuleName,
+ exports: exports,
+ exportedModuleNames: moduleNames,
}
}
+func (i *DeapexerInfo) GetDexpreoptProfileGuidedExportedModuleNames() []string {
+ return i.dexpreoptProfileGuidedExportedModuleNames
+}
+
+func (i *DeapexerInfo) AddDexpreoptProfileGuidedExportedModuleNames(names ...string) {
+ i.dexpreoptProfileGuidedExportedModuleNames = append(i.dexpreoptProfileGuidedExportedModuleNames, names...)
+}
+
type deapexerTagStruct struct {
blueprint.BaseDependencyTag
}
@@ -133,6 +155,9 @@ type RequiredFilesFromPrebuiltApex interface {
// the path to the extracted file will be stored in the DeapexerInfo using the APEX relative file
// path as the key, The path can then be retrieved using the PrebuiltExportPath(key) method.
RequiredFilesFromPrebuiltApex(ctx BaseModuleContext) []string
+
+ // Returns true if a transitive dependency of an apex should use a .prof file to guide dexpreopt
+ UseProfileGuidedDexpreopt() bool
}
// Marker interface that identifies dependencies on modules that may require files from a prebuilt
@@ -146,11 +171,17 @@ type RequiresFilesFromPrebuiltApexTag interface {
// FindDeapexerProviderForModule searches through the direct dependencies of the current context
// module for a DeapexerTag dependency and returns its DeapexerInfo. If a single nonambiguous
-// deapexer module isn't found then errors are reported with ctx.ModuleErrorf and nil is returned.
-func FindDeapexerProviderForModule(ctx ModuleContext) *DeapexerInfo {
+// deapexer module isn't found then it returns it an error
+// clients should check the value of error and call ctx.ModuleErrof if a non nil error is received
+func FindDeapexerProviderForModule(ctx ModuleContext) (*DeapexerInfo, error) {
var di *DeapexerInfo
+ var err error
ctx.VisitDirectDepsWithTag(DeapexerTag, func(m Module) {
- c := ctx.OtherModuleProvider(m, DeapexerProvider).(DeapexerInfo)
+ if err != nil {
+ // An err has been found. Do not visit further.
+ return
+ }
+ c, _ := OtherModuleProvider(ctx, m, DeapexerProvider)
p := &c
if di != nil {
// If two DeapexerInfo providers have been found then check if they are
@@ -159,17 +190,18 @@ func FindDeapexerProviderForModule(ctx ModuleContext) *DeapexerInfo {
di = selected
return
}
- ctx.ModuleErrorf("Multiple installable prebuilt APEXes provide ambiguous deapexers: %s and %s",
- di.ApexModuleName(), p.ApexModuleName())
+ err = fmt.Errorf("Multiple installable prebuilt APEXes provide ambiguous deapexers: %s and %s", di.ApexModuleName(), p.ApexModuleName())
}
di = p
})
+ if err != nil {
+ return nil, err
+ }
if di != nil {
- return di
+ return di, nil
}
- ai := ctx.Provider(ApexInfoProvider).(ApexInfo)
- ctx.ModuleErrorf("No prebuilt APEX provides a deapexer module for APEX variant %s", ai.ApexVariationName)
- return nil
+ ai, _ := ModuleProvider(ctx, ApexInfoProvider)
+ return nil, fmt.Errorf("No prebuilt APEX provides a deapexer module for APEX variant %s", ai.ApexVariationName)
}
// removeCompressedApexSuffix removes the _compressed suffix from the name if present.