Move imageMutator before archMutator

Run the imageMutator between osMutator and archMutator so that
different arch variants can be set for the different partitions.

Bug: 142286466
Test: m checkbuild
Change-Id: I65d05714b75aa462bf9816da60fdc2deda4de593
Merged-In: I65d05714b75aa462bf9816da60fdc2deda4de593
(cherry picked from commit 9c8f687584)
This commit is contained in:
Colin Cross
2019-11-20 17:12:35 -08:00
parent bd0624304e
commit fb0c16e95a
9 changed files with 70 additions and 41 deletions

View File

@@ -822,7 +822,7 @@ func archMutator(mctx BottomUpMutatorContext) {
os := base.commonProperties.CompileOS
osTargets := mctx.Config().Targets[os]
image := base.commonProperties.ImageVariation
// Filter NativeBridge targets unless they are explicitly supported
if os == Android && !Bool(base.commonProperties.Native_bridge_supported) {
var targets []Target
@@ -859,6 +859,12 @@ func archMutator(mctx BottomUpMutatorContext) {
}
}
if image == RecoveryVariation {
primaryArch := mctx.Config().DevicePrimaryArchType()
targets = filterToArch(targets, primaryArch)
multiTargets = filterToArch(multiTargets, primaryArch)
}
if len(targets) == 0 {
base.commonProperties.Enabled = boolPtr(false)
return
@@ -907,6 +913,16 @@ func decodeMultilib(base *ModuleBase, class OsClass) (multilib, extraMultilib st
}
}
func filterToArch(targets []Target, arch ArchType) []Target {
for i := 0; i < len(targets); i++ {
if targets[i].Arch.ArchType != arch {
targets = append(targets[:i], targets[i+1:]...)
i--
}
}
return targets
}
// createArchType takes a reflect.Type that is either a struct or a pointer to a struct, and returns a list of
// reflect.Type that contains the arch-variant properties inside structs for each architecture, os, target, multilib,
// etc.