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.

View File

@ -1005,6 +1005,7 @@ func determineModuleKind(m *ModuleBase, ctx blueprint.BaseModuleContext) moduleK
func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) baseModuleContext {
return baseModuleContext{
BaseModuleContext: ctx,
os: m.commonProperties.CompileOS,
target: m.commonProperties.CompileTarget,
targetPrimary: m.commonProperties.CompilePrimary,
multiTargets: m.commonProperties.CompileMultiTargets,
@ -1117,6 +1118,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
type baseModuleContext struct {
blueprint.BaseModuleContext
os OsType
target Target
multiTargets []Target
targetPrimary bool
@ -1460,27 +1462,27 @@ func (b *baseModuleContext) Arch() Arch {
}
func (b *baseModuleContext) Os() OsType {
return b.target.Os
return b.os
}
func (b *baseModuleContext) Host() bool {
return b.target.Os.Class == Host || b.target.Os.Class == HostCross
return b.os.Class == Host || b.os.Class == HostCross
}
func (b *baseModuleContext) Device() bool {
return b.target.Os.Class == Device
return b.os.Class == Device
}
func (b *baseModuleContext) Darwin() bool {
return b.target.Os == Darwin
return b.os == Darwin
}
func (b *baseModuleContext) Fuchsia() bool {
return b.target.Os == Fuchsia
return b.os == Fuchsia
}
func (b *baseModuleContext) Windows() bool {
return b.target.Os == Windows
return b.os == Windows
}
func (b *baseModuleContext) Debug() bool {

View File

@ -87,9 +87,9 @@ var preArch = []RegisterMutatorFunc{
func registerArchMutator(ctx RegisterMutatorsContext) {
ctx.BottomUp("os", osMutator).Parallel()
ctx.BottomUp("image", imageMutator).Parallel()
ctx.BottomUp("arch", archMutator).Parallel()
ctx.TopDown("arch_hooks", archHookMutator).Parallel()
ctx.BottomUp("image", imageMutator).Parallel()
}
var preDeps = []RegisterMutatorFunc{

View File

@ -257,6 +257,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "host binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: hostTarget.Os,
target: hostTarget,
},
},
@ -268,6 +269,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "system binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
},
@ -278,6 +280,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "vendor binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: socSpecificModule,
},
@ -289,6 +292,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "odm binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: deviceSpecificModule,
},
@ -300,6 +304,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "product binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: productSpecificModule,
},
@ -311,6 +316,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "system_ext binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: systemExtSpecificModule,
},
@ -322,6 +328,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "root binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inRoot: true,
@ -333,6 +340,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "recovery binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inRecovery: true,
@ -344,6 +352,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "recovery root binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inRecovery: true,
@ -357,6 +366,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "system native test binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inData: true,
@ -368,6 +378,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "vendor native test binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: socSpecificModule,
},
@ -380,6 +391,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "odm native test binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: deviceSpecificModule,
},
@ -392,6 +404,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "product native test binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: productSpecificModule,
},
@ -405,6 +418,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "system_ext native test binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: systemExtSpecificModule,
},
@ -418,6 +432,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "sanitized system binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inSanitizerDir: true,
@ -429,6 +444,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "sanitized vendor binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: socSpecificModule,
},
@ -441,6 +457,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "sanitized odm binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: deviceSpecificModule,
},
@ -453,6 +470,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "sanitized product binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: productSpecificModule,
},
@ -466,6 +484,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "sanitized system_ext binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: systemExtSpecificModule,
},
@ -479,6 +498,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "sanitized system native test binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
},
inData: true,
@ -491,6 +511,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "sanitized vendor native test binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: socSpecificModule,
},
@ -504,6 +525,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "sanitized odm native test binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: deviceSpecificModule,
},
@ -517,6 +539,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "sanitized product native test binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: productSpecificModule,
},
@ -530,6 +553,7 @@ func TestPathForModuleInstall(t *testing.T) {
name: "sanitized system_ext native test binary",
ctx: &moduleInstallPathContextImpl{
baseModuleContext: baseModuleContext{
os: deviceTarget.Os,
target: deviceTarget,
kind: systemExtSpecificModule,
},

View File

@ -1097,8 +1097,8 @@ func TestUseVendor(t *testing.T) {
inputsString := strings.Join(inputsList, " ")
// ensure that the apex includes vendor variants of the direct and indirect deps
ensureContains(t, inputsString, "android_arm64_armv8-a_vendor.VER_shared_myapex/mylib.so")
ensureContains(t, inputsString, "android_arm64_armv8-a_vendor.VER_shared_myapex/mylib2.so")
ensureContains(t, inputsString, "android_vendor.VER_arm64_armv8-a_shared_myapex/mylib.so")
ensureContains(t, inputsString, "android_vendor.VER_arm64_armv8-a_shared_myapex/mylib2.so")
// ensure that the apex does not include core variants
ensureNotContains(t, inputsString, "android_arm64_armv8-a_shared_myapex/mylib.so")

View File

@ -2623,14 +2623,6 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
coreVariantNeeded = false
}
if recoveryVariantNeeded {
primaryArch := mctx.Config().DevicePrimaryArchType()
moduleArch := m.Target().Arch.ArchType
if moduleArch != primaryArch {
recoveryVariantNeeded = false
}
}
for _, variant := range android.FirstUniqueStrings(vendorVariants) {
m.Properties.VendorVariants = append(m.Properties.VendorVariants, VendorVariationPrefix+variant)
}

View File

@ -113,8 +113,8 @@ func testCcError(t *testing.T, pattern string, bp string) {
const (
coreVariant = "android_arm64_armv8-a_shared"
vendorVariant = "android_arm64_armv8-a_vendor.VER_shared"
recoveryVariant = "android_arm64_armv8-a_recovery_shared"
vendorVariant = "android_vendor.VER_arm64_armv8-a_shared"
recoveryVariant = "android_recovery_arm64_armv8-a_shared"
)
func TestFuchsiaDeps(t *testing.T) {
@ -376,8 +376,8 @@ func TestVndk(t *testing.T) {
vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core")
vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp")
variant := "android_arm64_armv8-a_vendor.VER_shared"
variant2nd := "android_arm_armv7-a-neon_vendor.VER_shared"
variant := "android_vendor.VER_arm64_armv8-a_shared"
variant2nd := "android_vendor.VER_arm_armv7-a-neon_shared"
checkVndkSnapshot(t, ctx, "libvndk", "libvndk.so", vndkCoreLibPath, variant)
checkVndkSnapshot(t, ctx, "libvndk", "libvndk.so", vndkCoreLib2ndPath, variant2nd)
@ -1525,7 +1525,7 @@ func TestMakeLinkType(t *testing.T) {
assertMapKeys(t, vndkPrivateLibraries(config),
[]string{"libft2", "libllndkprivate", "libvndkprivate"})
vendorVariant27 := "android_arm64_armv8-a_vendor.27_shared"
vendorVariant27 := "android_vendor.27_arm64_armv8-a_shared"
tests := []struct {
variant string
@ -1976,7 +1976,7 @@ func TestLlndkHeaders(t *testing.T) {
`)
// _static variant is used since _shared reuses *.o from the static variant
cc := ctx.ModuleForTests("libvendor", "android_arm_armv7-a-neon_vendor.VER_static").Rule("cc")
cc := ctx.ModuleForTests("libvendor", "android_vendor.VER_arm_armv7-a-neon_static").Rule("cc")
cflags := cc.Args["cFlags"]
if !strings.Contains(cflags, "-Imy_include") {
t.Errorf("cflags for libvendor must contain -Imy_include, but was %#v.", cflags)
@ -2062,7 +2062,7 @@ func TestRuntimeLibs(t *testing.T) {
// runtime_libs for vendor variants have '.vendor' suffixes if the modules have both core
// and vendor variants.
variant = "android_arm64_armv8-a_vendor.VER_shared"
variant = "android_vendor.VER_arm64_armv8-a_shared"
module = ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
checkRuntimeLibs(t, []string{"libvendor_available1.vendor"}, module)
@ -2078,7 +2078,7 @@ func TestExcludeRuntimeLibs(t *testing.T) {
module := ctx.ModuleForTests("libvendor_available3", variant).Module().(*Module)
checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
variant = "android_arm64_armv8-a_vendor.VER_shared"
variant = "android_vendor.VER_arm64_armv8-a_shared"
module = ctx.ModuleForTests("libvendor_available3", variant).Module().(*Module)
checkRuntimeLibs(t, nil, module)
}
@ -2257,7 +2257,7 @@ func TestVendorPublicLibraries(t *testing.T) {
`)
coreVariant := "android_arm64_armv8-a_shared"
vendorVariant := "android_arm64_armv8-a_vendor.VER_shared"
vendorVariant := "android_vendor.VER_arm64_armv8-a_shared"
// test if header search paths are correctly added
// _static variant is used since _shared reuses *.o from the static variant
@ -2304,7 +2304,7 @@ func TestRecovery(t *testing.T) {
`)
variants := ctx.ModuleVariantsForTests("librecovery")
const arm64 = "android_arm64_armv8-a_recovery_shared"
const arm64 = "android_recovery_arm64_armv8-a_shared"
if len(variants) != 1 || !android.InList(arm64, variants) {
t.Errorf("variants of librecovery must be \"%s\" only, but was %#v", arm64, variants)
}

View File

@ -59,12 +59,7 @@ func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext
}
func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleContext) bool {
if Bool(g.Recovery_available) {
primaryArch := ctx.Config().DevicePrimaryArchType()
moduleArch := ctx.Target().Arch.ArchType
return moduleArch == primaryArch
}
return false
return Bool(g.Recovery_available)
}
func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string {

View File

@ -284,10 +284,10 @@ func TestSyspropLibrary(t *testing.T) {
// Check for generated cc_library
for _, variant := range []string{
"android_arm_armv7-a-neon_vendor.VER_shared",
"android_arm_armv7-a-neon_vendor.VER_static",
"android_arm64_armv8-a_vendor.VER_shared",
"android_arm64_armv8-a_vendor.VER_static",
"android_vendor.VER_arm_armv7-a-neon_shared",
"android_vendor.VER_arm_armv7-a-neon_static",
"android_vendor.VER_arm64_armv8-a_shared",
"android_vendor.VER_arm64_armv8-a_static",
} {
ctx.ModuleForTests("libsysprop-platform", variant)
ctx.ModuleForTests("libsysprop-vendor", variant)
@ -311,15 +311,15 @@ func TestSyspropLibrary(t *testing.T) {
// Check for exported includes
coreVariant := "android_arm64_armv8-a_static"
vendorVariant := "android_arm64_armv8-a_vendor.VER_static"
vendorVariant := "android_vendor.VER_arm64_armv8-a_static"
platformInternalPath := "libsysprop-platform/android_arm64_armv8-a_static/gen/sysprop/include"
platformPublicCorePath := "libsysprop-platform/android_arm64_armv8-a_static/gen/sysprop/public/include"
platformPublicVendorPath := "libsysprop-platform/android_arm64_armv8-a_vendor.VER_static/gen/sysprop/public/include"
platformPublicVendorPath := "libsysprop-platform/android_vendor.VER_arm64_armv8-a_static/gen/sysprop/public/include"
platformOnProductPath := "libsysprop-platform-on-product/android_arm64_armv8-a_static/gen/sysprop/public/include"
vendorInternalPath := "libsysprop-vendor/android_arm64_armv8-a_vendor.VER_static/gen/sysprop/include"
vendorInternalPath := "libsysprop-vendor/android_vendor.VER_arm64_armv8-a_static/gen/sysprop/include"
vendorPublicPath := "libsysprop-vendor/android_arm64_armv8-a_static/gen/sysprop/public/include"
platformClient := ctx.ModuleForTests("cc-client-platform", coreVariant)