aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2015-11-20 13:07:51 -0800
committerColin Cross <ccross@android.com>2015-11-23 14:18:26 -0800
commiteeabb89426623877f9bc5dafe16e39a2a0cf23d0 (patch)
tree97eeb23a83f3fa4b9fc8a5eddf49aa1c2e1ab2a1 /common
parent6ba99aa2817bf1188ee78fcaae00afe4d0a363cf (diff)
downloadbuild_soong-eeabb89426623877f9bc5dafe16e39a2a0cf23d0.tar.gz
build_soong-eeabb89426623877f9bc5dafe16e39a2a0cf23d0.tar.bz2
build_soong-eeabb89426623877f9bc5dafe16e39a2a0cf23d0.zip
make arch and variant parsing more robust
Post-process the arch and cpu variants to treat the arch name or "generic" as an empty variant. Filter out extra empty abis. Ignore empty arches. Print a useful error message when appending properties fails to find the target field, when an unknown architecture is used, or when a toolchain has not been implemented for the selected architecture. Change-Id: I671d4cd04975f4f29aefc4267b3a624868ce6a75
Diffstat (limited to 'common')
-rw-r--r--common/arch.go38
1 files changed, 32 insertions, 6 deletions
diff --git a/common/arch.go b/common/arch.go
index 52c83476..21f638ab 100644
--- a/common/arch.go
+++ b/common/arch.go
@@ -431,7 +431,13 @@ var dashToUnderscoreReplacer = strings.NewReplacer("-", "_")
func (a *AndroidModuleBase) appendProperties(ctx AndroidBottomUpMutatorContext,
dst, src interface{}, field, srcPrefix string) {
- src = reflect.ValueOf(src).FieldByName(field).Elem().Interface()
+ srcField := reflect.ValueOf(src).FieldByName(field)
+ if !srcField.IsValid() {
+ ctx.ModuleErrorf("field %q does not exist", srcPrefix)
+ return
+ }
+
+ src = srcField.Elem().Interface()
filter := func(property string,
dstField, srcField reflect.StructField,
@@ -647,7 +653,7 @@ func decodeArchProductVariables(variables productVariables) ([]Arch, []Arch, err
hostArches := []Arch{hostArch}
- if variables.HostSecondaryArch != nil {
+ if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
hostSecondaryArch, err := decodeArch(*variables.HostSecondaryArch, nil, nil, nil)
if err != nil {
return nil, nil, err
@@ -667,7 +673,7 @@ func decodeArchProductVariables(variables productVariables) ([]Arch, []Arch, err
deviceArches := []Arch{deviceArch}
- if variables.DeviceSecondaryArch != nil {
+ if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" {
deviceSecondaryArch, err := decodeArch(*variables.DeviceSecondaryArch,
variables.DeviceSecondaryArchVariant, variables.DeviceSecondaryCpuVariant,
variables.DeviceSecondaryAbi)
@@ -696,14 +702,34 @@ func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Ar
return nil
}
- archType := archTypeMap[arch]
+ archType, ok := archTypeMap[arch]
+ if !ok {
+ return Arch{}, fmt.Errorf("unknown arch %q", arch)
+ }
- return Arch{
+ a := Arch{
ArchType: archType,
ArchVariant: stringPtr(archVariant),
CpuVariant: stringPtr(cpuVariant),
Abi: slicePtr(abi),
- }, nil
+ }
+
+ if a.ArchVariant == a.ArchType.Name || a.ArchVariant == "generic" {
+ a.ArchVariant = ""
+ }
+
+ if a.CpuVariant == a.ArchType.Name || a.CpuVariant == "generic" {
+ a.CpuVariant = ""
+ }
+
+ for i := 0; i < len(a.Abi); i++ {
+ if a.Abi[i] == "" {
+ a.Abi = append(a.Abi[:i], a.Abi[i+1:]...)
+ i--
+ }
+ }
+
+ return a, nil
}
// Use the module multilib setting to select one or more arches from an arch list