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
diff --git a/androidbp/cmd/androidbp.go b/androidbp/cmd/androidbp.go
index 5ab7788..b1e364c 100644
--- a/androidbp/cmd/androidbp.go
+++ b/androidbp/cmd/androidbp.go
@@ -175,6 +175,8 @@
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 @@
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)
}
diff --git a/androidbp/cmd/soong.go b/androidbp/cmd/soong.go
index f3023d5..20bf021 100644
--- a/androidbp/cmd/soong.go
+++ b/androidbp/cmd/soong.go
@@ -108,6 +108,26 @@
"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)",