Allow generating modules once per OS instead of once per Class
When building with two OSes of the same class (Host, etc) enabled, independently produce variants of each module for each OS, instead of making `compile_multilib: "first"` select just one of the OSes. My use case this is for Linux + LinuxBionic, which are both considered Host class, but this would also applied if we wanted to generate rules for Linux+Darwin, or some combination of firmware bits (either in addition to Android in the Device Class, or multiple firmwares in a new Class) Bug: 31559095 Test: enable host bionic, see a linux(_glibc) and linux_bionic definition for binaries Change-Id: I55e7f046758b3dc2a31da2c4b20274ec68ece0a0
This commit is contained in:
parent
fa2aee1ca4
commit
0ef639bb59
|
@ -215,7 +215,7 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Mod
|
|||
|
||||
}
|
||||
|
||||
if amod.Arch().ArchType != ctx.Config().Targets[amod.Os().Class][0].Arch.ArchType {
|
||||
if amod.Arch().ArchType != ctx.Config().Targets[amod.Os()][0].Arch.ArchType {
|
||||
prefix = "2ND_" + prefix
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,37 +325,46 @@ func archMutator(mctx BottomUpMutatorContext) {
|
|||
return
|
||||
}
|
||||
|
||||
osClasses := base.OsClassSupported()
|
||||
|
||||
var moduleTargets []Target
|
||||
moduleMultiTargets := make(map[int][]Target)
|
||||
primaryModules := make(map[int]bool)
|
||||
osClasses := base.OsClassSupported()
|
||||
|
||||
for _, class := range osClasses {
|
||||
classTargets := mctx.Config().Targets[class]
|
||||
if len(classTargets) == 0 {
|
||||
for _, os := range osTypeList {
|
||||
supportedClass := false
|
||||
for _, osClass := range osClasses {
|
||||
if os.Class == osClass {
|
||||
supportedClass = true
|
||||
}
|
||||
}
|
||||
if !supportedClass {
|
||||
continue
|
||||
}
|
||||
|
||||
osTargets := mctx.Config().Targets[os]
|
||||
if len(osTargets) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// only the primary arch in the recovery partition
|
||||
if module.InstallInRecovery() {
|
||||
classTargets = []Target{mctx.Config().Targets[Device][0]}
|
||||
if os == Android && module.InstallInRecovery() {
|
||||
osTargets = []Target{osTargets[0]}
|
||||
}
|
||||
|
||||
prefer32 := false
|
||||
if base.prefer32 != nil {
|
||||
prefer32 = base.prefer32(mctx, base, class)
|
||||
prefer32 = base.prefer32(mctx, base, os.Class)
|
||||
}
|
||||
|
||||
multilib, extraMultilib := decodeMultilib(base, class)
|
||||
targets, err := decodeMultilibTargets(multilib, classTargets, prefer32)
|
||||
multilib, extraMultilib := decodeMultilib(base, os.Class)
|
||||
targets, err := decodeMultilibTargets(multilib, osTargets, prefer32)
|
||||
if err != nil {
|
||||
mctx.ModuleErrorf("%s", err.Error())
|
||||
}
|
||||
|
||||
var multiTargets []Target
|
||||
if extraMultilib != "" {
|
||||
multiTargets, err = decodeMultilibTargets(extraMultilib, classTargets, prefer32)
|
||||
multiTargets, err = decodeMultilibTargets(extraMultilib, osTargets, prefer32)
|
||||
if err != nil {
|
||||
mctx.ModuleErrorf("%s", err.Error())
|
||||
}
|
||||
|
@ -839,17 +848,17 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||
}
|
||||
|
||||
if (arch.ArchType == X86 && (hasArmAbi(arch) ||
|
||||
hasArmAndroidArch(ctx.Config().Targets[Device]))) ||
|
||||
hasArmAndroidArch(ctx.Config().Targets[Android]))) ||
|
||||
(arch.ArchType == Arm &&
|
||||
hasX86AndroidArch(ctx.Config().Targets[Device])) {
|
||||
hasX86AndroidArch(ctx.Config().Targets[Android])) {
|
||||
field := "Arm_on_x86"
|
||||
prefix := "target.arm_on_x86"
|
||||
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||
}
|
||||
if (arch.ArchType == X86_64 && (hasArmAbi(arch) ||
|
||||
hasArmAndroidArch(ctx.Config().Targets[Device]))) ||
|
||||
hasArmAndroidArch(ctx.Config().Targets[Android]))) ||
|
||||
(arch.ArchType == Arm &&
|
||||
hasX8664AndroidArch(ctx.Config().Targets[Device])) {
|
||||
hasX8664AndroidArch(ctx.Config().Targets[Android])) {
|
||||
field := "Arm_on_x86_64"
|
||||
prefix := "target.arm_on_x86_64"
|
||||
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||
|
@ -874,10 +883,10 @@ func forEachInterface(v reflect.Value, f func(reflect.Value)) {
|
|||
}
|
||||
|
||||
// Convert the arch product variables into a list of targets for each os class structs
|
||||
func decodeTargetProductVariables(config *config) (map[OsClass][]Target, error) {
|
||||
func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
||||
variables := config.productVariables
|
||||
|
||||
targets := make(map[OsClass][]Target)
|
||||
targets := make(map[OsType][]Target)
|
||||
var targetErr error
|
||||
|
||||
addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi *[]string) {
|
||||
|
@ -891,7 +900,7 @@ func decodeTargetProductVariables(config *config) (map[OsClass][]Target, error)
|
|||
return
|
||||
}
|
||||
|
||||
targets[os.Class] = append(targets[os.Class],
|
||||
targets[os] = append(targets[os],
|
||||
Target{
|
||||
Os: os,
|
||||
Arch: arch,
|
||||
|
@ -938,7 +947,7 @@ func decodeTargetProductVariables(config *config) (map[OsClass][]Target, error)
|
|||
variables.DeviceSecondaryArchVariant, variables.DeviceSecondaryCpuVariant,
|
||||
variables.DeviceSecondaryAbi)
|
||||
|
||||
deviceArches := targets[Device]
|
||||
deviceArches := targets[Android]
|
||||
if deviceArches[0].Arch.ArchType.Multilib == deviceArches[1].Arch.ArchType.Multilib {
|
||||
deviceArches[1].Arch.Native = false
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ type config struct {
|
|||
ConfigFileName string
|
||||
ProductVariablesFileName string
|
||||
|
||||
Targets map[OsClass][]Target
|
||||
Targets map[OsType][]Target
|
||||
BuildOsVariant string
|
||||
BuildOsCommonVariant string
|
||||
|
||||
|
@ -230,18 +230,18 @@ func TestArchConfig(buildDir string, env map[string]string) Config {
|
|||
testConfig := TestConfig(buildDir, env)
|
||||
config := testConfig.config
|
||||
|
||||
config.Targets = map[OsClass][]Target{
|
||||
Device: []Target{
|
||||
config.Targets = map[OsType][]Target{
|
||||
Android: []Target{
|
||||
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Native: true, Abi: []string{"arm64-v8a"}}},
|
||||
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true, Abi: []string{"armeabi-v7a"}}},
|
||||
},
|
||||
Host: []Target{
|
||||
BuildOs: []Target{
|
||||
{BuildOs, Arch{ArchType: X86_64}},
|
||||
{BuildOs, Arch{ArchType: X86}},
|
||||
},
|
||||
}
|
||||
|
||||
config.BuildOsVariant = config.Targets[Host][0].String()
|
||||
config.BuildOsVariant = config.Targets[BuildOs][0].String()
|
||||
|
||||
return testConfig
|
||||
}
|
||||
|
@ -304,16 +304,16 @@ func NewConfig(srcDir, buildDir string) (Config, error) {
|
|||
}
|
||||
|
||||
if archConfig != nil {
|
||||
deviceTargets, err := decodeArchSettings(archConfig)
|
||||
androidTargets, err := decodeArchSettings(archConfig)
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
targets[Device] = deviceTargets
|
||||
targets[Android] = androidTargets
|
||||
}
|
||||
|
||||
config.Targets = targets
|
||||
config.BuildOsVariant = targets[Host][0].String()
|
||||
config.BuildOsCommonVariant = getCommonTargets(targets[Host])[0].String()
|
||||
config.BuildOsVariant = targets[BuildOs][0].String()
|
||||
config.BuildOsCommonVariant = getCommonTargets(targets[BuildOs])[0].String()
|
||||
|
||||
if err := config.fromEnv(); err != nil {
|
||||
return Config{}, err
|
||||
|
@ -587,7 +587,7 @@ func (c *config) DevicePrefer32BitExecutables() bool {
|
|||
}
|
||||
|
||||
func (c *config) DevicePrimaryArchType() ArchType {
|
||||
return c.Targets[Device][0].Arch.ArchType
|
||||
return c.Targets[Android][0].Arch.ArchType
|
||||
}
|
||||
|
||||
func (c *config) SkipDeviceInstall() bool {
|
||||
|
@ -624,7 +624,7 @@ func (c *config) EnableCFI() bool {
|
|||
}
|
||||
|
||||
func (c *config) Android64() bool {
|
||||
for _, t := range c.Targets[Device] {
|
||||
for _, t := range c.Targets[Android] {
|
||||
if t.Arch.ArchType.Multilib == "lib64" {
|
||||
return true
|
||||
}
|
||||
|
@ -663,8 +663,8 @@ func (c *config) LibartImgHostBaseAddress() string {
|
|||
|
||||
func (c *config) LibartImgDeviceBaseAddress() string {
|
||||
archType := Common
|
||||
if len(c.Targets[Device]) > 0 {
|
||||
archType = c.Targets[Device][0].Arch.ArchType
|
||||
if len(c.Targets[Android]) > 0 {
|
||||
archType = c.Targets[Android][0].Arch.ArchType
|
||||
}
|
||||
switch archType {
|
||||
default:
|
||||
|
@ -711,7 +711,7 @@ func (c *config) HostStaticBinaries() bool {
|
|||
|
||||
func (c *deviceConfig) Arches() []Arch {
|
||||
var arches []Arch
|
||||
for _, target := range c.config.Targets[Device] {
|
||||
for _, target := range c.config.Targets[Android] {
|
||||
arches = append(arches, target.Arch)
|
||||
}
|
||||
return arches
|
||||
|
|
|
@ -1071,10 +1071,10 @@ func (a *androidBaseContextImpl) Debug() bool {
|
|||
}
|
||||
|
||||
func (a *androidBaseContextImpl) PrimaryArch() bool {
|
||||
if len(a.config.Targets[a.target.Os.Class]) <= 1 {
|
||||
if len(a.config.Targets[a.target.Os]) <= 1 {
|
||||
return true
|
||||
}
|
||||
return a.target.Arch.ArchType == a.config.Targets[a.target.Os.Class][0].Arch.ArchType
|
||||
return a.target.Arch.ArchType == a.config.Targets[a.target.Os][0].Arch.ArchType
|
||||
}
|
||||
|
||||
func (a *androidBaseContextImpl) AConfig() Config {
|
||||
|
|
|
@ -172,13 +172,13 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
|||
sort.Strings(ndkMigratedLibs)
|
||||
ctx.Strict("NDK_MIGRATED_LIBS", strings.Join(ndkMigratedLibs, " "))
|
||||
|
||||
hostTargets := ctx.Config().Targets[android.Host]
|
||||
hostTargets := ctx.Config().Targets[android.BuildOs]
|
||||
makeVarsToolchain(ctx, "", hostTargets[0])
|
||||
if len(hostTargets) > 1 {
|
||||
makeVarsToolchain(ctx, "2ND_", hostTargets[1])
|
||||
}
|
||||
|
||||
crossTargets := ctx.Config().Targets[android.HostCross]
|
||||
crossTargets := ctx.Config().Targets[android.Windows]
|
||||
if len(crossTargets) > 0 {
|
||||
makeVarsToolchain(ctx, "", crossTargets[0])
|
||||
if len(crossTargets) > 1 {
|
||||
|
@ -186,7 +186,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
|||
}
|
||||
}
|
||||
|
||||
deviceTargets := ctx.Config().Targets[android.Device]
|
||||
deviceTargets := ctx.Config().Targets[android.Android]
|
||||
makeVarsToolchain(ctx, "", deviceTargets[0])
|
||||
if len(deviceTargets) > 1 {
|
||||
makeVarsToolchain(ctx, "2ND_", deviceTargets[1])
|
||||
|
|
Loading…
Reference in New Issue