Dynamically generate arch struct am: b1957a5021
am: cb55b8d2ef
Change-Id: I8982a53b03d7414c88ead966722b8a765720289b
This commit is contained in:
421
android/arch.go
421
android/arch.go
@@ -25,6 +25,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
archTypeList []ArchType
|
||||||
|
|
||||||
Arm = newArch("arm", "lib32")
|
Arm = newArch("arm", "lib32")
|
||||||
Arm64 = newArch("arm64", "lib64")
|
Arm64 = newArch("arm64", "lib64")
|
||||||
Mips = newArch("mips", "lib32")
|
Mips = newArch("mips", "lib32")
|
||||||
@@ -102,185 +104,32 @@ module {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
type Embed interface{}
|
var archVariants = map[ArchType][]string{}
|
||||||
|
var archFeatures = map[ArchType][]string{}
|
||||||
type archProperties struct {
|
|
||||||
// Properties to vary by target architecture
|
|
||||||
Arch struct {
|
|
||||||
// Properties for module variants being built to run on arm (host or device)
|
|
||||||
Arm struct {
|
|
||||||
Embed `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\")"`
|
|
||||||
Cortex_a53 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Cortex_a53_a57 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Krait interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Denver interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Properties for module variants being built to run on arm64 (host or device)
|
|
||||||
Arm64 struct {
|
|
||||||
Embed `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
|
|
||||||
// Arm64 arch variants
|
|
||||||
Armv8_a interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
|
|
||||||
// Arm64 cpu variants
|
|
||||||
Cortex_a53 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Denver64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Properties for module variants being built to run on mips (host or device)
|
|
||||||
Mips struct {
|
|
||||||
Embed `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
|
|
||||||
// Mips arch variants
|
|
||||||
Mips32_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Mips32r2_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Mips32r2_fp_xburst interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Mips32r2dsp_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Mips32r2dspr2_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Mips32r6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
|
|
||||||
// Mips arch features
|
|
||||||
Rev6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Properties for module variants being built to run on mips64 (host or device)
|
|
||||||
Mips64 struct {
|
|
||||||
Embed `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
|
|
||||||
// Mips64 arch variants
|
|
||||||
Mips64r2 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Mips64r6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
|
|
||||||
// Mips64 arch features
|
|
||||||
Rev6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Properties for module variants being built to run on x86 (host or device)
|
|
||||||
X86 struct {
|
|
||||||
Embed `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
|
|
||||||
// X86 arch variants
|
|
||||||
Atom interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Haswell interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Ivybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Sandybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Silvermont interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Generic variant for X86 on X86_64
|
|
||||||
X86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
|
|
||||||
// X86 arch features
|
|
||||||
Ssse3 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Sse4 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Sse4_1 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Sse4_2 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Aes_ni interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Avx interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Popcnt interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Movbe interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Properties for module variants being built to run on x86_64 (host or device)
|
|
||||||
X86_64 struct {
|
|
||||||
Embed `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
|
|
||||||
// X86 arch variants
|
|
||||||
Haswell interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Ivybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Sandybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Silvermont interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
|
|
||||||
// X86 arch features
|
|
||||||
Ssse3 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Sse4 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Sse4_1 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Sse4_2 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Aes_ni interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Avx interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
Popcnt 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
|
|
||||||
Lib32 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on 64-bit devices
|
|
||||||
Lib64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
}
|
|
||||||
// Properties to vary by build target (host or device, os, os+archictecture)
|
|
||||||
Target struct {
|
|
||||||
// Properties for module variants being built to run on the host
|
|
||||||
Host interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on the device
|
|
||||||
Android interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on arm devices
|
|
||||||
Android_arm interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on arm64 devices
|
|
||||||
Android_arm64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on mips devices
|
|
||||||
Android_mips interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on mips64 devices
|
|
||||||
Android_mips64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on x86 devices
|
|
||||||
Android_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on x86_64 devices
|
|
||||||
Android_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on devices that support 64-bit
|
|
||||||
Android64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on devices that do not support 64-bit
|
|
||||||
Android32 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on linux hosts
|
|
||||||
Linux interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on linux x86 hosts
|
|
||||||
Linux_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on linux x86_64 hosts
|
|
||||||
Linux_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on darwin hosts
|
|
||||||
Darwin interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on darwin x86 hosts
|
|
||||||
Darwin_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on darwin x86_64 hosts
|
|
||||||
Darwin_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on windows hosts
|
|
||||||
Windows interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on windows x86 hosts
|
|
||||||
Windows_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on windows x86_64 hosts
|
|
||||||
Windows_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
// Properties for module variants being built to run on linux or darwin hosts
|
|
||||||
Not_windows interface{} `blueprint:"filter(android:\"arch_variant\")"`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var archFeatureMap = map[ArchType]map[string][]string{}
|
var archFeatureMap = map[ArchType]map[string][]string{}
|
||||||
|
|
||||||
func RegisterArchFeatures(arch ArchType, variant string, features ...string) {
|
func RegisterArchVariants(arch ArchType, variants ...string) {
|
||||||
archField := proptools.FieldNameForProperty(arch.Name)
|
checkCalledFromInit()
|
||||||
variantField := proptools.FieldNameForProperty(variant)
|
archVariants[arch] = append(archVariants[arch], variants...)
|
||||||
archStruct := reflect.ValueOf(archProperties{}.Arch).FieldByName(archField)
|
}
|
||||||
if variant != "" {
|
|
||||||
if !archStruct.FieldByName(variantField).IsValid() {
|
func RegisterArchFeatures(arch ArchType, features ...string) {
|
||||||
panic(fmt.Errorf("Invalid variant %q for arch %q", variant, arch))
|
checkCalledFromInit()
|
||||||
}
|
archFeatures[arch] = append(archFeatures[arch], features...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterArchVariantFeatures(arch ArchType, variant string, features ...string) {
|
||||||
|
checkCalledFromInit()
|
||||||
|
if variant != "" && !inList(variant, archVariants[arch]) {
|
||||||
|
panic(fmt.Errorf("Invalid variant %q for arch %q", variant, arch))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, feature := range features {
|
for _, feature := range features {
|
||||||
field := proptools.FieldNameForProperty(feature)
|
if !inList(feature, archFeatures[arch]) {
|
||||||
if !archStruct.FieldByName(field).IsValid() {
|
|
||||||
panic(fmt.Errorf("Invalid feature %q for arch %q variant %q", feature, arch, variant))
|
panic(fmt.Errorf("Invalid feature %q for arch %q variant %q", feature, arch, variant))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if archFeatureMap[arch] == nil {
|
if archFeatureMap[arch] == nil {
|
||||||
archFeatureMap[arch] = make(map[string][]string)
|
archFeatureMap[arch] = make(map[string][]string)
|
||||||
}
|
}
|
||||||
@@ -310,14 +159,18 @@ func (a Arch) String() string {
|
|||||||
|
|
||||||
type ArchType struct {
|
type ArchType struct {
|
||||||
Name string
|
Name string
|
||||||
|
Field string
|
||||||
Multilib string
|
Multilib string
|
||||||
}
|
}
|
||||||
|
|
||||||
func newArch(name, multilib string) ArchType {
|
func newArch(name, multilib string) ArchType {
|
||||||
return ArchType{
|
archType := ArchType{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
Field: proptools.FieldNameForProperty(name),
|
||||||
Multilib: multilib,
|
Multilib: multilib,
|
||||||
}
|
}
|
||||||
|
archTypeList = append(archTypeList, archType)
|
||||||
|
return archType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a ArchType) String() string {
|
func (a ArchType) String() string {
|
||||||
@@ -343,6 +196,13 @@ var (
|
|||||||
Darwin = NewOsType("darwin", Host)
|
Darwin = NewOsType("darwin", Host)
|
||||||
Windows = NewOsType("windows", HostCross)
|
Windows = NewOsType("windows", HostCross)
|
||||||
Android = NewOsType("android", Device)
|
Android = NewOsType("android", Device)
|
||||||
|
|
||||||
|
osArchTypeMap = map[OsType][]ArchType{
|
||||||
|
Linux: []ArchType{X86, X86_64},
|
||||||
|
Darwin: []ArchType{X86, X86_64},
|
||||||
|
Windows: []ArchType{X86, X86_64},
|
||||||
|
Android: []ArchType{Arm, Arm64, Mips, Mips64, X86, X86_64},
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type OsType struct {
|
type OsType struct {
|
||||||
@@ -458,6 +318,142 @@ func ArchMutator(mctx BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func filterArchStruct(prop reflect.Type) (reflect.Type, bool) {
|
||||||
|
var fields []reflect.StructField
|
||||||
|
|
||||||
|
ptr := prop.Kind() == reflect.Ptr
|
||||||
|
if ptr {
|
||||||
|
prop = prop.Elem()
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < prop.NumField(); i++ {
|
||||||
|
field := prop.Field(i)
|
||||||
|
if !proptools.HasTag(field, "android", "arch_variant") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// The arch_variant field isn't necessary past this point
|
||||||
|
// Instead of wasting space, just remove it. Go also has a
|
||||||
|
// 16-bit limit on structure name length. The name is constructed
|
||||||
|
// based on the Go source representation of the structure, so
|
||||||
|
// the tag names count towards that length.
|
||||||
|
//
|
||||||
|
// TODO: handle the uncommon case of other tags being involved
|
||||||
|
if field.Tag == `android:"arch_variant"` {
|
||||||
|
field.Tag = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recurse into structs
|
||||||
|
switch field.Type.Kind() {
|
||||||
|
case reflect.Struct:
|
||||||
|
var ok bool
|
||||||
|
field.Type, ok = filterArchStruct(field.Type)
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
case reflect.Ptr:
|
||||||
|
if field.Type.Elem().Kind() == reflect.Struct {
|
||||||
|
nestedType, ok := filterArchStruct(field.Type.Elem())
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
field.Type = reflect.PtrTo(nestedType)
|
||||||
|
}
|
||||||
|
case reflect.Interface:
|
||||||
|
panic("Interfaces are not supported in arch_variant properties")
|
||||||
|
}
|
||||||
|
|
||||||
|
fields = append(fields, field)
|
||||||
|
}
|
||||||
|
if len(fields) == 0 {
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
|
ret := reflect.StructOf(fields)
|
||||||
|
if ptr {
|
||||||
|
ret = reflect.PtrTo(ret)
|
||||||
|
}
|
||||||
|
return ret, true
|
||||||
|
}
|
||||||
|
|
||||||
|
func createArchType(props reflect.Type) reflect.Type {
|
||||||
|
props, ok := filterArchStruct(props)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
variantFields := func(names []string) []reflect.StructField {
|
||||||
|
ret := make([]reflect.StructField, len(names))
|
||||||
|
|
||||||
|
for i, name := range names {
|
||||||
|
ret[i].Name = name
|
||||||
|
ret[i].Type = props
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
archFields := make([]reflect.StructField, len(archTypeList))
|
||||||
|
for i, arch := range archTypeList {
|
||||||
|
variants := []string{}
|
||||||
|
|
||||||
|
for _, archVariant := range archVariants[arch] {
|
||||||
|
variants = append(variants, proptools.FieldNameForProperty(archVariant))
|
||||||
|
}
|
||||||
|
for _, feature := range archFeatures[arch] {
|
||||||
|
variants = append(variants, proptools.FieldNameForProperty(feature))
|
||||||
|
}
|
||||||
|
|
||||||
|
fields := variantFields(variants)
|
||||||
|
|
||||||
|
fields = append([]reflect.StructField{reflect.StructField{
|
||||||
|
Name: "BlueprintEmbed",
|
||||||
|
Type: props,
|
||||||
|
Anonymous: true,
|
||||||
|
}}, fields...)
|
||||||
|
|
||||||
|
archFields[i] = reflect.StructField{
|
||||||
|
Name: arch.Field,
|
||||||
|
Type: reflect.StructOf(fields),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
archType := reflect.StructOf(archFields)
|
||||||
|
|
||||||
|
multilibType := reflect.StructOf(variantFields([]string{"Lib32", "Lib64"}))
|
||||||
|
|
||||||
|
targets := []string{
|
||||||
|
"Host",
|
||||||
|
"Android64",
|
||||||
|
"Android32",
|
||||||
|
"Not_windows",
|
||||||
|
}
|
||||||
|
for _, os := range osTypeList {
|
||||||
|
targets = append(targets, os.Field)
|
||||||
|
|
||||||
|
for _, archType := range osArchTypeMap[os] {
|
||||||
|
targets = append(targets, os.Field+"_"+archType.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
targetType := reflect.StructOf(variantFields(targets))
|
||||||
|
return reflect.StructOf([]reflect.StructField{
|
||||||
|
reflect.StructField{
|
||||||
|
Name: "Arch",
|
||||||
|
Type: archType,
|
||||||
|
},
|
||||||
|
reflect.StructField{
|
||||||
|
Name: "Multilib",
|
||||||
|
Type: multilibType,
|
||||||
|
},
|
||||||
|
reflect.StructField{
|
||||||
|
Name: "Target",
|
||||||
|
Type: targetType,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var archPropTypeMap OncePer
|
||||||
|
|
||||||
func InitArchModule(m Module,
|
func InitArchModule(m Module,
|
||||||
propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
|
propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
|
||||||
|
|
||||||
@@ -480,19 +476,23 @@ func InitArchModule(m Module,
|
|||||||
propertiesValue.Interface()))
|
propertiesValue.Interface()))
|
||||||
}
|
}
|
||||||
|
|
||||||
archProperties := &archProperties{}
|
archPropType := archPropTypeMap.Once(t, func() interface{} {
|
||||||
forEachInterface(reflect.ValueOf(archProperties), func(v reflect.Value) {
|
return createArchType(t)
|
||||||
newValue := reflect.Zero(t)
|
|
||||||
v.Set(newValue)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
base.archProperties = append(base.archProperties, archProperties)
|
if archPropType != nil {
|
||||||
|
base.archProperties = append(base.archProperties, reflect.New(archPropType.(reflect.Type)).Interface())
|
||||||
|
} else {
|
||||||
|
base.archProperties = append(base.archProperties, nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var allProperties []interface{}
|
var allProperties []interface{}
|
||||||
allProperties = append(allProperties, base.generalProperties...)
|
allProperties = append(allProperties, base.generalProperties...)
|
||||||
for _, asp := range base.archProperties {
|
for _, asp := range base.archProperties {
|
||||||
allProperties = append(allProperties, asp)
|
if asp != nil {
|
||||||
|
allProperties = append(allProperties, asp)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
base.customizableProperties = allProperties
|
base.customizableProperties = allProperties
|
||||||
@@ -503,37 +503,18 @@ func InitArchModule(m Module,
|
|||||||
var variantReplacer = strings.NewReplacer("-", "_", ".", "_")
|
var variantReplacer = strings.NewReplacer("-", "_", ".", "_")
|
||||||
|
|
||||||
func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
|
func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
|
||||||
dst, src interface{}, field, srcPrefix string) interface{} {
|
dst interface{}, src reflect.Value, field, srcPrefix string) reflect.Value {
|
||||||
|
|
||||||
srcField := reflect.ValueOf(src).FieldByName(field)
|
src = src.FieldByName(field)
|
||||||
if !srcField.IsValid() {
|
if !src.IsValid() {
|
||||||
ctx.ModuleErrorf("field %q does not exist", srcPrefix)
|
ctx.ModuleErrorf("field %q does not exist", srcPrefix)
|
||||||
return nil
|
return src
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := srcField
|
ret := src
|
||||||
|
|
||||||
if srcField.Kind() == reflect.Struct {
|
if src.Kind() == reflect.Struct {
|
||||||
srcField = srcField.FieldByName("Embed")
|
src = src.FieldByName("BlueprintEmbed")
|
||||||
}
|
|
||||||
|
|
||||||
src = srcField.Elem().Interface()
|
|
||||||
|
|
||||||
filter := func(property string,
|
|
||||||
dstField, srcField reflect.StructField,
|
|
||||||
dstValue, srcValue interface{}) (bool, error) {
|
|
||||||
|
|
||||||
srcProperty := srcPrefix + "." + property
|
|
||||||
|
|
||||||
if !proptools.HasTag(dstField, "android", "arch_variant") {
|
|
||||||
if ctx.ContainsProperty(srcProperty) {
|
|
||||||
return false, fmt.Errorf("can't be specific to a build variant")
|
|
||||||
} else {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
order := func(property string,
|
order := func(property string,
|
||||||
@@ -546,7 +527,7 @@ func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := proptools.ExtendProperties(dst, src, filter, order)
|
err := proptools.ExtendMatchingProperties([]interface{}{dst}, src.Interface(), nil, order)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
|
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
|
||||||
ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
|
ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
|
||||||
@@ -555,7 +536,7 @@ func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret.Interface()
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rewrite the module's properties structs to contain arch-specific values.
|
// Rewrite the module's properties structs to contain arch-specific values.
|
||||||
@@ -569,7 +550,15 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
|
|
||||||
for i := range a.generalProperties {
|
for i := range a.generalProperties {
|
||||||
genProps := a.generalProperties[i]
|
genProps := a.generalProperties[i]
|
||||||
archProps := a.archProperties[i]
|
if a.archProperties[i] == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
archProps := reflect.ValueOf(a.archProperties[i]).Elem()
|
||||||
|
|
||||||
|
archProp := archProps.FieldByName("Arch")
|
||||||
|
multilibProp := archProps.FieldByName("Multilib")
|
||||||
|
targetProp := archProps.FieldByName("Target")
|
||||||
|
|
||||||
// Handle arch-specific properties in the form:
|
// Handle arch-specific properties in the form:
|
||||||
// arch: {
|
// arch: {
|
||||||
// arm64: {
|
// arm64: {
|
||||||
@@ -580,7 +569,7 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
|
|
||||||
field := proptools.FieldNameForProperty(t.Name)
|
field := proptools.FieldNameForProperty(t.Name)
|
||||||
prefix := "arch." + t.Name
|
prefix := "arch." + t.Name
|
||||||
archStruct := a.appendProperties(ctx, genProps, archProps.Arch, field, prefix)
|
archStruct := a.appendProperties(ctx, genProps, archProp, field, prefix)
|
||||||
|
|
||||||
// Handle arch-variant-specific properties in the form:
|
// Handle arch-variant-specific properties in the form:
|
||||||
// arch: {
|
// arch: {
|
||||||
@@ -628,7 +617,7 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
// },
|
// },
|
||||||
field = proptools.FieldNameForProperty(t.Multilib)
|
field = proptools.FieldNameForProperty(t.Multilib)
|
||||||
prefix = "multilib." + t.Multilib
|
prefix = "multilib." + t.Multilib
|
||||||
a.appendProperties(ctx, genProps, archProps.Multilib, field, prefix)
|
a.appendProperties(ctx, genProps, multilibProp, field, prefix)
|
||||||
|
|
||||||
// Handle host-specific properties in the form:
|
// Handle host-specific properties in the form:
|
||||||
// target: {
|
// target: {
|
||||||
@@ -639,7 +628,7 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
if os.Class == Host || os.Class == HostCross {
|
if os.Class == Host || os.Class == HostCross {
|
||||||
field = "Host"
|
field = "Host"
|
||||||
prefix = "target.host"
|
prefix = "target.host"
|
||||||
a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle target OS properties in the form:
|
// Handle target OS properties in the form:
|
||||||
@@ -669,16 +658,16 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
// },
|
// },
|
||||||
field = os.Field
|
field = os.Field
|
||||||
prefix = "target." + os.Name
|
prefix = "target." + os.Name
|
||||||
a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
|
|
||||||
field = os.Field + "_" + t.Name
|
field = os.Field + "_" + t.Name
|
||||||
prefix = "target." + os.Name + "_" + t.Name
|
prefix = "target." + os.Name + "_" + t.Name
|
||||||
a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
|
|
||||||
if (os.Class == Host || os.Class == HostCross) && os != Windows {
|
if (os.Class == Host || os.Class == HostCross) && os != Windows {
|
||||||
field := "Not_windows"
|
field := "Not_windows"
|
||||||
prefix := "target.not_windows"
|
prefix := "target.not_windows"
|
||||||
a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle 64-bit device properties in the form:
|
// Handle 64-bit device properties in the form:
|
||||||
@@ -698,11 +687,11 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
|||||||
if ctx.AConfig().Android64() {
|
if ctx.AConfig().Android64() {
|
||||||
field := "Android64"
|
field := "Android64"
|
||||||
prefix := "target.android64"
|
prefix := "target.android64"
|
||||||
a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
} else {
|
} else {
|
||||||
field := "Android32"
|
field := "Android32"
|
||||||
prefix := "target.android32"
|
prefix := "target.android32"
|
||||||
a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -262,7 +262,7 @@ type ModuleBase struct {
|
|||||||
variableProperties variableProperties
|
variableProperties variableProperties
|
||||||
hostAndDeviceProperties hostAndDeviceProperties
|
hostAndDeviceProperties hostAndDeviceProperties
|
||||||
generalProperties []interface{}
|
generalProperties []interface{}
|
||||||
archProperties []*archProperties
|
archProperties []interface{}
|
||||||
customizableProperties []interface{}
|
customizableProperties []interface{}
|
||||||
|
|
||||||
noAddressSanitizer bool
|
noAddressSanitizer bool
|
||||||
|
@@ -14,7 +14,11 @@
|
|||||||
|
|
||||||
package android
|
package android
|
||||||
|
|
||||||
import "sort"
|
import (
|
||||||
|
"runtime"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
func JoinWithPrefix(strs []string, prefix string) string {
|
func JoinWithPrefix(strs []string, prefix string) string {
|
||||||
if len(strs) == 0 {
|
if len(strs) == 0 {
|
||||||
@@ -76,3 +80,63 @@ func sortedKeys(m map[string][]string) []string {
|
|||||||
sort.Strings(s)
|
sort.Strings(s)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func indexList(s string, list []string) int {
|
||||||
|
for i, l := range list {
|
||||||
|
if l == s {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
func inList(s string, list []string) bool {
|
||||||
|
return indexList(s, list) != -1
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkCalledFromInit panics if a Go package's init function is not on the
|
||||||
|
// call stack.
|
||||||
|
func checkCalledFromInit() {
|
||||||
|
for skip := 3; ; skip++ {
|
||||||
|
_, funcName, ok := callerName(skip)
|
||||||
|
if !ok {
|
||||||
|
panic("not called from an init func")
|
||||||
|
}
|
||||||
|
|
||||||
|
if funcName == "init" || strings.HasPrefix(funcName, "init·") {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// callerName returns the package path and function name of the calling
|
||||||
|
// function. The skip argument has the same meaning as the skip argument of
|
||||||
|
// runtime.Callers.
|
||||||
|
func callerName(skip int) (pkgPath, funcName string, ok bool) {
|
||||||
|
var pc [1]uintptr
|
||||||
|
n := runtime.Callers(skip+1, pc[:])
|
||||||
|
if n != 1 {
|
||||||
|
return "", "", false
|
||||||
|
}
|
||||||
|
|
||||||
|
f := runtime.FuncForPC(pc[0])
|
||||||
|
fullName := f.Name()
|
||||||
|
|
||||||
|
lastDotIndex := strings.LastIndex(fullName, ".")
|
||||||
|
if lastDotIndex == -1 {
|
||||||
|
panic("unable to distinguish function name from package")
|
||||||
|
}
|
||||||
|
|
||||||
|
if fullName[lastDotIndex-1] == ')' {
|
||||||
|
// The caller is a method on some type, so it's name looks like
|
||||||
|
// "pkg/path.(type).method". We need to go back one dot farther to get
|
||||||
|
// to the package name.
|
||||||
|
lastDotIndex = strings.LastIndex(fullName[:lastDotIndex], ".")
|
||||||
|
}
|
||||||
|
|
||||||
|
pkgPath = fullName[:lastDotIndex]
|
||||||
|
funcName = fullName[lastDotIndex+1:]
|
||||||
|
ok = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@@ -89,6 +89,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
android.RegisterArchVariants(android.Arm64,
|
||||||
|
"armv8_a",
|
||||||
|
"cortex_a53",
|
||||||
|
"denver64")
|
||||||
|
|
||||||
pctx.StaticVariable("arm64GccVersion", arm64GccVersion)
|
pctx.StaticVariable("arm64GccVersion", arm64GccVersion)
|
||||||
|
|
||||||
pctx.SourcePathVariable("Arm64GccRoot",
|
pctx.SourcePathVariable("Arm64GccRoot",
|
||||||
|
@@ -145,6 +145,19 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
android.RegisterArchVariants(android.Arm,
|
||||||
|
"armv5te",
|
||||||
|
"armv7_a",
|
||||||
|
"armv7_a_neon",
|
||||||
|
"cortex_a7",
|
||||||
|
"cortex_a8",
|
||||||
|
"cortex_a9",
|
||||||
|
"cortex_a15",
|
||||||
|
"cortex_a53",
|
||||||
|
"cortex_a53_a57",
|
||||||
|
"krait",
|
||||||
|
"denver")
|
||||||
|
|
||||||
replaceFirst := func(slice []string, from, to string) {
|
replaceFirst := func(slice []string, from, to string) {
|
||||||
if slice[0] != from {
|
if slice[0] != from {
|
||||||
panic(fmt.Errorf("Expected %q, found %q", from, to))
|
panic(fmt.Errorf("Expected %q, found %q", from, to))
|
||||||
|
@@ -90,7 +90,11 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterArchFeatures(android.Mips64, "mips64r6",
|
android.RegisterArchVariants(android.Mips64,
|
||||||
|
"mips64r2",
|
||||||
|
"mips64r6")
|
||||||
|
android.RegisterArchFeatures(android.Mips64, "rev6")
|
||||||
|
android.RegisterArchVariantFeatures(android.Mips64, "mips64r6",
|
||||||
"rev6")
|
"rev6")
|
||||||
|
|
||||||
pctx.StaticVariable("mips64GccVersion", mips64GccVersion)
|
pctx.StaticVariable("mips64GccVersion", mips64GccVersion)
|
||||||
|
@@ -126,7 +126,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterArchFeatures(android.Mips, "mips32r6",
|
android.RegisterArchVariants(android.Mips,
|
||||||
|
"mips32_fp",
|
||||||
|
"mips32r2_fp",
|
||||||
|
"mips32r2_fp_xburst",
|
||||||
|
"mips32r2dsp_fp",
|
||||||
|
"mips32r2dspr2_fp",
|
||||||
|
"mips32r6")
|
||||||
|
android.RegisterArchFeatures(android.Mips, "rev6")
|
||||||
|
android.RegisterArchVariantFeatures(android.Mips, "mips32r6",
|
||||||
"rev6")
|
"rev6")
|
||||||
|
|
||||||
pctx.StaticVariable("mipsGccVersion", mipsGccVersion)
|
pctx.StaticVariable("mipsGccVersion", mipsGccVersion)
|
||||||
|
@@ -99,13 +99,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterArchFeatures(android.X86_64, "",
|
android.RegisterArchVariants(android.X86_64,
|
||||||
"ssse3",
|
"haswell",
|
||||||
"sse4",
|
"ivybridge",
|
||||||
"sse4_1",
|
"sandybridge",
|
||||||
"sse4_2",
|
"silvermont")
|
||||||
"popcnt")
|
android.RegisterArchFeatures(android.X86_64,
|
||||||
android.RegisterArchFeatures(android.X86_64, "haswell",
|
|
||||||
"ssse3",
|
"ssse3",
|
||||||
"sse4",
|
"sse4",
|
||||||
"sse4_1",
|
"sse4_1",
|
||||||
@@ -113,7 +112,13 @@ func init() {
|
|||||||
"aes_ni",
|
"aes_ni",
|
||||||
"avx",
|
"avx",
|
||||||
"popcnt")
|
"popcnt")
|
||||||
android.RegisterArchFeatures(android.X86_64, "ivybridge",
|
android.RegisterArchVariantFeatures(android.X86_64, "",
|
||||||
|
"ssse3",
|
||||||
|
"sse4",
|
||||||
|
"sse4_1",
|
||||||
|
"sse4_2",
|
||||||
|
"popcnt")
|
||||||
|
android.RegisterArchVariantFeatures(android.X86_64, "haswell",
|
||||||
"ssse3",
|
"ssse3",
|
||||||
"sse4",
|
"sse4",
|
||||||
"sse4_1",
|
"sse4_1",
|
||||||
@@ -121,13 +126,21 @@ func init() {
|
|||||||
"aes_ni",
|
"aes_ni",
|
||||||
"avx",
|
"avx",
|
||||||
"popcnt")
|
"popcnt")
|
||||||
android.RegisterArchFeatures(android.X86_64, "sandybridge",
|
android.RegisterArchVariantFeatures(android.X86_64, "ivybridge",
|
||||||
|
"ssse3",
|
||||||
|
"sse4",
|
||||||
|
"sse4_1",
|
||||||
|
"sse4_2",
|
||||||
|
"aes_ni",
|
||||||
|
"avx",
|
||||||
|
"popcnt")
|
||||||
|
android.RegisterArchVariantFeatures(android.X86_64, "sandybridge",
|
||||||
"ssse3",
|
"ssse3",
|
||||||
"sse4",
|
"sse4",
|
||||||
"sse4_1",
|
"sse4_1",
|
||||||
"sse4_2",
|
"sse4_2",
|
||||||
"popcnt")
|
"popcnt")
|
||||||
android.RegisterArchFeatures(android.X86_64, "silvermont",
|
android.RegisterArchVariantFeatures(android.X86_64, "silvermont",
|
||||||
"ssse3",
|
"ssse3",
|
||||||
"sse4",
|
"sse4",
|
||||||
"sse4_1",
|
"sse4_1",
|
||||||
|
@@ -113,16 +113,14 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterArchFeatures(android.X86, "x86_64",
|
android.RegisterArchVariants(android.X86,
|
||||||
"ssse3",
|
"atom",
|
||||||
"sse4",
|
"haswell",
|
||||||
"sse4_1",
|
"ivybridge",
|
||||||
"sse4_2",
|
"sandybridge",
|
||||||
"popcnt")
|
"silvermont",
|
||||||
android.RegisterArchFeatures(android.X86, "atom",
|
"x86_64")
|
||||||
"ssse3",
|
android.RegisterArchFeatures(android.X86,
|
||||||
"movbe")
|
|
||||||
android.RegisterArchFeatures(android.X86, "haswell",
|
|
||||||
"ssse3",
|
"ssse3",
|
||||||
"sse4",
|
"sse4",
|
||||||
"sse4_1",
|
"sse4_1",
|
||||||
@@ -131,7 +129,25 @@ func init() {
|
|||||||
"avx",
|
"avx",
|
||||||
"popcnt",
|
"popcnt",
|
||||||
"movbe")
|
"movbe")
|
||||||
android.RegisterArchFeatures(android.X86, "ivybridge",
|
android.RegisterArchVariantFeatures(android.X86, "x86_64",
|
||||||
|
"ssse3",
|
||||||
|
"sse4",
|
||||||
|
"sse4_1",
|
||||||
|
"sse4_2",
|
||||||
|
"popcnt")
|
||||||
|
android.RegisterArchVariantFeatures(android.X86, "atom",
|
||||||
|
"ssse3",
|
||||||
|
"movbe")
|
||||||
|
android.RegisterArchVariantFeatures(android.X86, "haswell",
|
||||||
|
"ssse3",
|
||||||
|
"sse4",
|
||||||
|
"sse4_1",
|
||||||
|
"sse4_2",
|
||||||
|
"aes_ni",
|
||||||
|
"avx",
|
||||||
|
"popcnt",
|
||||||
|
"movbe")
|
||||||
|
android.RegisterArchVariantFeatures(android.X86, "ivybridge",
|
||||||
"ssse3",
|
"ssse3",
|
||||||
"sse4",
|
"sse4",
|
||||||
"sse4_1",
|
"sse4_1",
|
||||||
@@ -139,13 +155,13 @@ func init() {
|
|||||||
"aes_ni",
|
"aes_ni",
|
||||||
"avx",
|
"avx",
|
||||||
"popcnt")
|
"popcnt")
|
||||||
android.RegisterArchFeatures(android.X86, "sandybridge",
|
android.RegisterArchVariantFeatures(android.X86, "sandybridge",
|
||||||
"ssse3",
|
"ssse3",
|
||||||
"sse4",
|
"sse4",
|
||||||
"sse4_1",
|
"sse4_1",
|
||||||
"sse4_2",
|
"sse4_2",
|
||||||
"popcnt")
|
"popcnt")
|
||||||
android.RegisterArchFeatures(android.X86, "silvermont",
|
android.RegisterArchVariantFeatures(android.X86, "silvermont",
|
||||||
"ssse3",
|
"ssse3",
|
||||||
"sse4",
|
"sse4",
|
||||||
"sse4_1",
|
"sse4_1",
|
||||||
|
Reference in New Issue
Block a user