summaryrefslogtreecommitdiff
path: root/android/override_module.go
diff options
context:
space:
mode:
author Jaewoong Jung <jungjw@google.com> 2019-06-06 08:45:58 -0700
committer Jaewoong Jung <jungjw@google.com> 2019-11-15 15:06:06 -0800
commit26dedd36ed3853dc210730a41da5afbc95afcc0a (patch)
treee6027ad2829919ed80e29ff8c09dc0606284a21f /android/override_module.go
parent9f88ce26a80dc85cb3a6033f52e9fbc82c400ed1 (diff)
Add override_android_test.
This change also adds instrumentation_target_package to android_test, so that the target package name in a test manifest can be easily overridden. Fixes: 134624457 Test: app_test.go Change-Id: Ib8dd703da0038ac76210c92d79e133e37c718122
Diffstat (limited to 'android/override_module.go')
-rw-r--r--android/override_module.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/android/override_module.go b/android/override_module.go
index 22fb7de44..09959e43d 100644
--- a/android/override_module.go
+++ b/android/override_module.go
@@ -175,6 +175,7 @@ func RegisterOverridePostDepsMutators(ctx RegisterMutatorsContext) {
ctx.TopDown("register_override", registerOverrideMutator).Parallel()
ctx.BottomUp("perform_override", performOverrideMutator).Parallel()
ctx.BottomUp("overridable_deps", overridableModuleDepsMutator).Parallel()
+ ctx.BottomUp("replace_deps_on_override", replaceDepsOnOverridingModuleMutator).Parallel()
}
type overrideBaseDependencyTag struct {
@@ -218,6 +219,9 @@ func performOverrideMutator(ctx BottomUpMutatorContext) {
variants[i+1] = o.(Module).Name()
}
mods := ctx.CreateLocalVariations(variants...)
+ // Make the original variation the default one to depend on if no other override module variant
+ // is specified.
+ ctx.AliasVariation(variants[0])
for i, o := range overrides {
mods[i+1].(OverridableModule).override(ctx, o)
}
@@ -226,17 +230,24 @@ func performOverrideMutator(ctx BottomUpMutatorContext) {
// variant name rule for overridden modules, and thus allows ReplaceDependencies to match the
// two.
ctx.CreateLocalVariations(o.Name())
+ // To allow dependencies to be added without having to know the above variation.
+ ctx.AliasVariation(o.Name())
}
}
func overridableModuleDepsMutator(ctx BottomUpMutatorContext) {
if b, ok := ctx.Module().(OverridableModule); ok {
+ b.OverridablePropertiesDepsMutator(ctx)
+ }
+}
+
+func replaceDepsOnOverridingModuleMutator(ctx BottomUpMutatorContext) {
+ if b, ok := ctx.Module().(OverridableModule); ok {
if o := b.getOverriddenBy(); o != "" {
// Redirect dependencies on the overriding module to this overridden module. Overriding
// modules are basically pseudo modules, and all build actions are associated to overridden
// modules. Therefore, dependencies on overriding modules need to be forwarded there as well.
ctx.ReplaceDependencies(o)
}
- b.OverridablePropertiesDepsMutator(ctx)
}
}