Add cpu-variant properties
Add nested properties that can vary based on the specific cpu type, for example cortex-a9 or cortex-a15. Change-Id: I107d6e30527c11d0bdd9bf17fb29513ffb07f9cc
This commit is contained in:
parent
3cc00f1fd8
commit
ec19363c23
3 changed files with 124 additions and 44 deletions
|
@ -175,6 +175,8 @@ func translateTargetConditionals(props []*bpparser.Property,
|
|||
return
|
||||
}
|
||||
|
||||
var secondTargetReplacer = strings.NewReplacer("TARGET_", "TARGET_2ND_")
|
||||
|
||||
func translateSuffixProperties(suffixProps []*bpparser.Property,
|
||||
suffixMap map[string]string) (computedProps []string, err error) {
|
||||
for _, suffixProp := range suffixProps {
|
||||
|
@ -188,6 +190,33 @@ func translateSuffixProperties(suffixProps []*bpparser.Property,
|
|||
return nil, fmt.Errorf("Unsupported property %q", stdProp.Name.Name)
|
||||
}
|
||||
}
|
||||
} else if variant, ok := cpuVariantConditionals[suffixProp.Name.Name]; ok {
|
||||
var conditionalProps []propAssignment
|
||||
for _, stdProp := range suffixProp.Value.MapValue {
|
||||
if assignment, ok, err := translateSingleProperty(stdProp); err != nil {
|
||||
return nil, err
|
||||
} else if ok {
|
||||
conditionalProps = append(conditionalProps, assignment)
|
||||
} else {
|
||||
return nil, fmt.Errorf("Unsupported property %q", stdProp.Name.Name)
|
||||
}
|
||||
}
|
||||
|
||||
appendComputedProps := func() {
|
||||
computedProps = append(computedProps, variant.conditional)
|
||||
for _, prop := range conditionalProps {
|
||||
prop.assigner = "+="
|
||||
computedProps = append(computedProps, prop.assignmentWithSuffix(variant.suffix))
|
||||
}
|
||||
computedProps = append(computedProps, "endif")
|
||||
}
|
||||
|
||||
appendComputedProps()
|
||||
if variant.secondArch {
|
||||
variant.conditional = secondTargetReplacer.Replace(variant.conditional)
|
||||
variant.suffix = secondTargetReplacer.Replace(variant.suffix)
|
||||
appendComputedProps()
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("Unsupported suffix property %q", suffixProp.Name.Name)
|
||||
}
|
||||
|
|
|
@ -108,6 +108,26 @@ var suffixProperties = map[string]map[string]string{
|
|||
"x86": "x86", "x86_64": "x86_64"},
|
||||
}
|
||||
|
||||
var cpuVariantConditionals = map[string]struct {
|
||||
conditional string
|
||||
suffix string
|
||||
secondArch bool
|
||||
}{
|
||||
"armv5te": {"ifeq ($(TARGET_ARCH_VARIANT),armv5te)", "$(TARGET_ARCH)", true},
|
||||
"armv7_a": {"ifeq ($(TARGET_ARCH_VARIANT),armv7-a)", "$(TARGET_ARCH)", true},
|
||||
"armv7_a_neon": {"ifeq ($(TARGET_ARCH_VARIANT),armv7-a-neon)", "$(TARGET_ARCH)", true},
|
||||
"cortex_a7": {"ifeq ($(TARGET_CPU_VARIANT),cortex-a7)", "$(TARGET_ARCH)", true},
|
||||
"cortex_a8": {"ifeq ($(TARGET_CPU_VARIANT),cortex-a8)", "$(TARGET_ARCH)", true},
|
||||
"cortex_a9": {"ifeq ($(TARGET_CPU_VARIANT),cortex-a9)", "$(TARGET_ARCH)", true},
|
||||
"cortex_a15": {"ifeq ($(TARGET_CPU_VARIANT),cortex-a15)", "$(TARGET_ARCH)", true},
|
||||
"krait": {"ifeq ($(TARGET_CPU_VARIANT),krait)", "$(TARGET_ARCH)", true},
|
||||
"denver": {"ifeq ($(TARGET_CPU_VARIANT),denver)", "$(TARGET_ARCH)", true},
|
||||
"denver64": {"ifeq ($(TARGET_CPU_VARIANT),denver64)", "$(TARGET_ARCH)", true},
|
||||
"mips_rev6": {"ifdef ARCH_MIPS_REV6", "mips", false},
|
||||
"atom": {"ifeq ($(TARGET_ARCH_VARIANT),atom)", "$(TARGET_ARCH)", true},
|
||||
"silvermont": {"ifeq ($(TARGET_ARCH_VARIANT),silvermont)", "$(TARGET_ARCH)", true},
|
||||
}
|
||||
|
||||
var hostScopedPropertyConditionals = map[string]string{
|
||||
"host": "",
|
||||
"darwin": "ifeq ($(HOST_OS), darwin)",
|
||||
|
|
119
common/arch.go
119
common/arch.go
|
@ -25,12 +25,12 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
Arm = newArch32("Arm")
|
||||
Arm64 = newArch64("Arm64")
|
||||
Mips = newArch32("Mips")
|
||||
Mips64 = newArch64("Mips64")
|
||||
X86 = newArch32("X86")
|
||||
X86_64 = newArch64("X86_64")
|
||||
Arm = newArch("arm", "lib32")
|
||||
Arm64 = newArch("arm64", "lib64")
|
||||
Mips = newArch("mips", "lib32")
|
||||
Mips64 = newArch("mips64", "lib64")
|
||||
X86 = newArch("x86", "lib32")
|
||||
X86_64 = newArch("x86_64", "lib64")
|
||||
|
||||
Common = ArchType{
|
||||
Name: "common",
|
||||
|
@ -108,7 +108,31 @@ type archProperties struct {
|
|||
X86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
// Properties for module variants being built to run on x86_64 (host or device)
|
||||
X86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
|
||||
// Arm arch variants
|
||||
Armv5te interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
Armv7_a interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
Armv7_a_neon interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
|
||||
// Arm cpu variants
|
||||
Cortex_a7 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
Cortex_a8 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
Cortex_a9 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
Cortex_a15 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
Krait interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
Denver interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
|
||||
// Arm64 cpu variants
|
||||
Denver64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
|
||||
// Mips arch variants
|
||||
Mips_rev6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
|
||||
// X86 cpu variants
|
||||
Atom interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
Silvermont interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
||||
}
|
||||
|
||||
// Properties to vary by 32-bit or 64-bit
|
||||
Multilib struct {
|
||||
// Properties for module variants being built to run on 32-bit devices
|
||||
|
@ -177,27 +201,14 @@ func (a Arch) String() string {
|
|||
}
|
||||
|
||||
type ArchType struct {
|
||||
Name string
|
||||
Field string
|
||||
Multilib string
|
||||
MultilibField string
|
||||
Name string
|
||||
Multilib string
|
||||
}
|
||||
|
||||
func newArch32(field string) ArchType {
|
||||
func newArch(name, multilib string) ArchType {
|
||||
return ArchType{
|
||||
Name: strings.ToLower(field),
|
||||
Field: field,
|
||||
Multilib: "lib32",
|
||||
MultilibField: "Lib32",
|
||||
}
|
||||
}
|
||||
|
||||
func newArch64(field string) ArchType {
|
||||
return ArchType{
|
||||
Name: strings.ToLower(field),
|
||||
Field: field,
|
||||
Multilib: "lib64",
|
||||
MultilibField: "Lib64",
|
||||
Name: name,
|
||||
Multilib: multilib,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,7 +244,7 @@ func (hod HostOrDevice) String() string {
|
|||
}
|
||||
}
|
||||
|
||||
func (hod HostOrDevice) FieldLower() string {
|
||||
func (hod HostOrDevice) Property() string {
|
||||
switch hod {
|
||||
case Device:
|
||||
return "android"
|
||||
|
@ -244,17 +255,6 @@ func (hod HostOrDevice) FieldLower() string {
|
|||
}
|
||||
}
|
||||
|
||||
func (hod HostOrDevice) Field() string {
|
||||
switch hod {
|
||||
case Device:
|
||||
return "Android"
|
||||
case Host:
|
||||
return "Host"
|
||||
default:
|
||||
panic(fmt.Sprintf("unexpected HostOrDevice value %d", hod))
|
||||
}
|
||||
}
|
||||
|
||||
func (hod HostOrDevice) Host() bool {
|
||||
if hod == 0 {
|
||||
panic("HostOrDevice unset")
|
||||
|
@ -282,10 +282,9 @@ var (
|
|||
Abi: "armeabi-v7a",
|
||||
}
|
||||
arm64Arch = Arch{
|
||||
ArchType: Arm64,
|
||||
ArchVariant: "armv8-a",
|
||||
CpuVariant: "denver",
|
||||
Abi: "arm64-v8a",
|
||||
ArchType: Arm64,
|
||||
CpuVariant: "denver64",
|
||||
Abi: "arm64-v8a",
|
||||
}
|
||||
x86Arch = Arch{
|
||||
ArchType: X86,
|
||||
|
@ -423,6 +422,8 @@ func InitArchModule(m AndroidModule, defaultMultilib Multilib,
|
|||
return m, allProperties
|
||||
}
|
||||
|
||||
var dashToUnderscoreReplacer = strings.NewReplacer("-", "_")
|
||||
|
||||
// Rewrite the module's properties structs to contain arch-specific values.
|
||||
func (a *AndroidModuleBase) setArchProperties(ctx blueprint.EarlyMutatorContext) {
|
||||
arch := a.commonProperties.CompileArch
|
||||
|
@ -442,8 +443,35 @@ func (a *AndroidModuleBase) setArchProperties(ctx blueprint.EarlyMutatorContext)
|
|||
// },
|
||||
// },
|
||||
t := arch.ArchType
|
||||
field := proptools.FieldNameForProperty(t.Name)
|
||||
a.extendProperties(ctx, "arch", t.Name, generalPropsValue,
|
||||
reflect.ValueOf(a.archProperties[i].Arch).FieldByName(t.Field).Elem().Elem())
|
||||
reflect.ValueOf(a.archProperties[i].Arch).FieldByName(field).Elem().Elem())
|
||||
|
||||
// Handle arch-variant-specific properties in the form:
|
||||
// arch: {
|
||||
// variant: {
|
||||
// key: value,
|
||||
// },
|
||||
// },
|
||||
v := dashToUnderscoreReplacer.Replace(arch.ArchVariant)
|
||||
if v != "" {
|
||||
field := proptools.FieldNameForProperty(v)
|
||||
a.extendProperties(ctx, "arch", v, generalPropsValue,
|
||||
reflect.ValueOf(a.archProperties[i].Arch).FieldByName(field).Elem().Elem())
|
||||
}
|
||||
|
||||
// Handle cpu-variant-specific properties in the form:
|
||||
// arch: {
|
||||
// variant: {
|
||||
// key: value,
|
||||
// },
|
||||
// },
|
||||
c := dashToUnderscoreReplacer.Replace(arch.CpuVariant)
|
||||
if c != "" {
|
||||
field := proptools.FieldNameForProperty(c)
|
||||
a.extendProperties(ctx, "arch", c, generalPropsValue,
|
||||
reflect.ValueOf(a.archProperties[i].Arch).FieldByName(field).Elem().Elem())
|
||||
}
|
||||
|
||||
// Handle multilib-specific properties in the form:
|
||||
// multilib: {
|
||||
|
@ -451,8 +479,9 @@ func (a *AndroidModuleBase) setArchProperties(ctx blueprint.EarlyMutatorContext)
|
|||
// key: value,
|
||||
// },
|
||||
// },
|
||||
multilibField := proptools.FieldNameForProperty(t.Multilib)
|
||||
a.extendProperties(ctx, "multilib", t.Multilib, generalPropsValue,
|
||||
reflect.ValueOf(a.archProperties[i].Multilib).FieldByName(t.MultilibField).Elem().Elem())
|
||||
reflect.ValueOf(a.archProperties[i].Multilib).FieldByName(multilibField).Elem().Elem())
|
||||
|
||||
// Handle host-or-device-specific properties in the form:
|
||||
// target: {
|
||||
|
@ -460,8 +489,10 @@ func (a *AndroidModuleBase) setArchProperties(ctx blueprint.EarlyMutatorContext)
|
|||
// key: value,
|
||||
// },
|
||||
// },
|
||||
a.extendProperties(ctx, "target", hod.FieldLower(), generalPropsValue,
|
||||
reflect.ValueOf(a.archProperties[i].Target).FieldByName(hod.Field()).Elem().Elem())
|
||||
hodProperty := hod.Property()
|
||||
hodField := proptools.FieldNameForProperty(hodProperty)
|
||||
a.extendProperties(ctx, "target", hodProperty, generalPropsValue,
|
||||
reflect.ValueOf(a.archProperties[i].Target).FieldByName(hodField).Elem().Elem())
|
||||
|
||||
// Handle host target properties in the form:
|
||||
// target: {
|
||||
|
|
Loading…
Reference in a new issue