summaryrefslogtreecommitdiff
path: root/apex/apex.go
diff options
context:
space:
mode:
Diffstat (limited to 'apex/apex.go')
-rw-r--r--apex/apex.go81
1 files changed, 43 insertions, 38 deletions
diff --git a/apex/apex.go b/apex/apex.go
index 2e7fbf6ac..40eb712ab 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -73,7 +73,7 @@ func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
// Run mark_platform_availability before the apexMutator as the apexMutator needs to know whether
// it should create a platform variant.
ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel()
- ctx.BottomUp("apex", apexMutator).Parallel()
+ ctx.Transition("apex", &apexTransitionMutator{})
ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).Parallel()
ctx.BottomUp("apex_dcla_deps", apexDCLADepsMutator).Parallel()
// Register after apex_info mutator so that it can use ApexVariationName
@@ -1077,20 +1077,24 @@ type ApexInfoMutator interface {
// specific variant to modules that support the ApexInfoMutator.
// It also propagates updatable=true to apps of updatable apexes
func apexInfoMutator(mctx android.TopDownMutatorContext) {
- if !mctx.Module().Enabled() {
+ if !mctx.Module().Enabled(mctx) {
return
}
if a, ok := mctx.Module().(ApexInfoMutator); ok {
a.ApexInfoMutator(mctx)
}
+
+ if am, ok := mctx.Module().(android.ApexModule); ok {
+ android.ApexInfoMutator(mctx, am)
+ }
enforceAppUpdatability(mctx)
}
// apexStrictUpdatibilityLintMutator propagates strict_updatability_linting to transitive deps of a mainline module
// This check is enforced for updatable modules
func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) {
- if !mctx.Module().Enabled() {
+ if !mctx.Module().Enabled(mctx) {
return
}
if apex, ok := mctx.Module().(*apexBundle); ok && apex.checkStrictUpdatabilityLinting() {
@@ -1117,7 +1121,7 @@ func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) {
// enforceAppUpdatability propagates updatable=true to apps of updatable apexes
func enforceAppUpdatability(mctx android.TopDownMutatorContext) {
- if !mctx.Module().Enabled() {
+ if !mctx.Module().Enabled(mctx) {
return
}
if apex, ok := mctx.Module().(*apexBundle); ok && apex.Updatable() {
@@ -1195,7 +1199,7 @@ func (a *apexBundle) checkStrictUpdatabilityLinting() bool {
// unique apex variations for this module. See android/apex.go for more about unique apex variant.
// TODO(jiyong): move this to android/apex.go?
func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) {
- if !mctx.Module().Enabled() {
+ if !mctx.Module().Enabled(mctx) {
return
}
if am, ok := mctx.Module().(android.ApexModule); ok {
@@ -1207,7 +1211,7 @@ func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) {
// the apex in order to retrieve its contents later.
// TODO(jiyong): move this to android/apex.go?
func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) {
- if !mctx.Module().Enabled() {
+ if !mctx.Module().Enabled(mctx) {
return
}
if am, ok := mctx.Module().(android.ApexModule); ok {
@@ -1222,7 +1226,7 @@ func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) {
// TODO(jiyong): move this to android/apex.go?
func apexTestForMutator(mctx android.BottomUpMutatorContext) {
- if !mctx.Module().Enabled() {
+ if !mctx.Module().Enabled(mctx) {
return
}
if _, ok := mctx.Module().(android.ApexModule); ok {
@@ -1284,40 +1288,41 @@ func markPlatformAvailability(mctx android.BottomUpMutatorContext) {
}
}
-// apexMutator visits each module and creates apex variations if the module was marked in the
-// previous run of apexInfoMutator.
-func apexMutator(mctx android.BottomUpMutatorContext) {
- if !mctx.Module().Enabled() {
- return
- }
-
- // This is the usual path.
- if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
- android.CreateApexVariations(mctx, am)
- return
- }
+type apexTransitionMutator struct{}
+func (a *apexTransitionMutator) Split(ctx android.BaseModuleContext) []string {
// apexBundle itself is mutated so that it and its dependencies have the same apex variant.
- // Note that a default variation "" is also created as an alias, and the default dependency
- // variation is set to the default variation. This is to allow an apex to depend on another
- // module which is outside of the apex. This is because the dependent module is not mutated
- // for this apex variant.
- createApexVariation := func(apexBundleName string) {
- defaultVariation := ""
- mctx.SetDefaultDependencyVariation(&defaultVariation)
- mctx.CreateVariations(apexBundleName)
- mctx.CreateAliasVariation(defaultVariation, apexBundleName)
- }
-
- if ai, ok := mctx.Module().(ApexInfoMutator); ok && apexModuleTypeRequiresVariant(ai) {
- createApexVariation(ai.ApexVariationName())
- } else if o, ok := mctx.Module().(*OverrideApex); ok {
+ if ai, ok := ctx.Module().(ApexInfoMutator); ok && apexModuleTypeRequiresVariant(ai) {
+ return []string{ai.ApexVariationName()}
+ } else if o, ok := ctx.Module().(*OverrideApex); ok {
apexBundleName := o.GetOverriddenModuleName()
if apexBundleName == "" {
- mctx.ModuleErrorf("base property is not set")
- return
+ ctx.ModuleErrorf("base property is not set")
}
- createApexVariation(apexBundleName)
+ return []string{apexBundleName}
+ }
+ return []string{""}
+}
+
+func (a *apexTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
+ return sourceVariation
+}
+
+func (a *apexTransitionMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string {
+ if am, ok := ctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
+ return android.IncomingApexTransition(ctx, incomingVariation)
+ } else if ai, ok := ctx.Module().(ApexInfoMutator); ok {
+ return ai.ApexVariationName()
+ } else if o, ok := ctx.Module().(*OverrideApex); ok {
+ return o.GetOverriddenModuleName()
+ }
+
+ return ""
+}
+
+func (a *apexTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) {
+ if am, ok := ctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
+ android.MutateApexTransition(ctx, variation)
}
}
@@ -1335,7 +1340,7 @@ func apexModuleTypeRequiresVariant(module ApexInfoMutator) bool {
// See android.UpdateDirectlyInAnyApex
// TODO(jiyong): move this to android/apex.go?
func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) {
- if !mctx.Module().Enabled() {
+ if !mctx.Module().Enabled(mctx) {
return
}
if am, ok := mctx.Module().(android.ApexModule); ok {
@@ -1969,7 +1974,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
return false
}
- if mod, ok := child.(android.Module); ok && !mod.Enabled() {
+ if mod, ok := child.(android.Module); ok && !mod.Enabled(ctx) {
return false
}
depName := ctx.OtherModuleName(child)