Use Targets[Android] instead of DeviceArch funcs.

NDK prebuit script doesn't set device arch product variables, and so
causes SupportedAbis to panic.

Fixes: 158673325
Test: app_test.go, apex_test.go
Test: build-ndk-prebuilts.sh
Change-Id: I8331ef5bca12301318510ec9712770fd8d3a26a9
This commit is contained in:
Jaewoong Jung
2020-06-10 12:23:32 -07:00
parent 4754d4451c
commit 829b7135f3
3 changed files with 26 additions and 22 deletions

View File

@@ -112,17 +112,17 @@ var TargetCpuAbi = map[string]string{
}
func SupportedAbis(ctx android.ModuleContext) []string {
abiName := func(archVar string, deviceArch string) string {
abiName := func(targetIdx int, deviceArch string) string {
if abi, found := TargetCpuAbi[deviceArch]; found {
return abi
}
ctx.ModuleErrorf("Invalid %s: %s", archVar, deviceArch)
ctx.ModuleErrorf("Target %d has invalid Arch: %s", targetIdx, deviceArch)
return "BAD_ABI"
}
result := []string{abiName("TARGET_ARCH", ctx.DeviceConfig().DeviceArch())}
if s := ctx.DeviceConfig().DeviceSecondaryArch(); s != "" {
result = append(result, abiName("TARGET_2ND_ARCH", s))
var result []string
for i, target := range ctx.Config().Targets[android.Android] {
result = append(result, abiName(i, target.Arch.ArchType.String()))
}
return result
}