aboutsummaryrefslogtreecommitdiffstats
path: root/common/arch.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-11-20 15:35:00 -0800
committerColin Cross <ccross@android.com>2015-11-23 14:55:26 -0800
commitc5c24ade6335455ea006499ee7ae449d89e56514 (patch)
treed825c9445873da7096a3853d550bee5c835c2702 /common/arch.go
parenteeabb89426623877f9bc5dafe16e39a2a0cf23d0 (diff)
downloadbuild_soong-c5c24ade6335455ea006499ee7ae449d89e56514.tar.gz
build_soong-c5c24ade6335455ea006499ee7ae449d89e56514.tar.bz2
build_soong-c5c24ade6335455ea006499ee7ae449d89e56514.zip
Add arch features
Allow architecture toolchains to register "features" supported by the current variant, and then apply properties from the selected features. Equivalent to the ARCH_*_HAS_* variables in the combo makefiles. Change-Id: Ib6823be1c1a52da677d081db9f24336a072eaf39
Diffstat (limited to 'common/arch.go')
-rw-r--r--common/arch.go46
1 files changed, 42 insertions, 4 deletions
diff --git a/common/arch.go b/common/arch.go
index 21f638ab..3669e801 100644
--- a/common/arch.go
+++ b/common/arch.go
@@ -208,12 +208,34 @@ type archProperties struct {
}
}
+var archFeatureMap = map[ArchType]map[string][]string{}
+
+func RegisterArchFeatures(arch ArchType, variant string, features ...string) {
+ field := proptools.FieldNameForProperty(variant)
+ if variant != "" {
+ if !reflect.ValueOf(archProperties{}.Arch).FieldByName(field).IsValid() {
+ panic(fmt.Errorf("Invalid variant %q for arch %q", variant, arch))
+ }
+ }
+ for _, feature := range features {
+ field := proptools.FieldNameForProperty(feature)
+ if !reflect.ValueOf(archProperties{}.Arch).FieldByName(field).IsValid() {
+ panic(fmt.Errorf("Invalid feature %q for arch %q variant %q", feature, arch, variant))
+ }
+ }
+ if archFeatureMap[arch] == nil {
+ archFeatureMap[arch] = make(map[string][]string)
+ }
+ archFeatureMap[arch][variant] = features
+}
+
// An Arch indicates a single CPU architecture.
type Arch struct {
- ArchType ArchType
- ArchVariant string
- CpuVariant string
- Abi []string
+ ArchType ArchType
+ ArchVariant string
+ CpuVariant string
+ Abi []string
+ ArchFeatures []string
}
func (a Arch) String() string {
@@ -516,6 +538,18 @@ func (a *AndroidModuleBase) setArchProperties(ctx AndroidBottomUpMutatorContext)
a.appendProperties(ctx, genProps, archProps.Arch, field, prefix)
}
+ // Handle arch-feature-specific properties in the form:
+ // arch: {
+ // feature: {
+ // key: value,
+ // },
+ // },
+ for _, feature := range arch.ArchFeatures {
+ field := proptools.FieldNameForProperty(feature)
+ prefix := "arch." + feature
+ a.appendProperties(ctx, genProps, archProps.Arch, field, prefix)
+ }
+
// Handle multilib-specific properties in the form:
// multilib: {
// lib32: {
@@ -729,6 +763,10 @@ func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Ar
}
}
+ if featureMap, ok := archFeatureMap[archType]; ok {
+ a.ArchFeatures = featureMap[stringPtr(archVariant)]
+ }
+
return a, nil
}