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:
parent
4754d4451c
commit
829b7135f3
|
@ -4786,8 +4786,10 @@ func TestApexSet(t *testing.T) {
|
|||
}
|
||||
`, func(fs map[string][]byte, config android.Config) {
|
||||
config.TestProductVariables.Platform_sdk_version = intPtr(30)
|
||||
config.TestProductVariables.DeviceArch = proptools.StringPtr("arm")
|
||||
config.TestProductVariables.DeviceSecondaryArch = proptools.StringPtr("arm64")
|
||||
config.Targets[android.Android] = []android.Target{
|
||||
{Os: android.Android, Arch: android.Arch{ArchType: android.Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}},
|
||||
{Os: android.Android, Arch: android.Arch{ArchType: android.Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}},
|
||||
}
|
||||
})
|
||||
|
||||
m := ctx.ModuleForTests("myapex", "android_common")
|
||||
|
|
10
java/app.go
10
java/app.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -173,16 +173,17 @@ func TestAndroidAppSet_Variants(t *testing.T) {
|
|||
set: "prebuilts/apks/app.apks",
|
||||
}`
|
||||
testCases := []struct {
|
||||
name string
|
||||
deviceArch *string
|
||||
deviceSecondaryArch *string
|
||||
aaptPrebuiltDPI []string
|
||||
sdkVersion int
|
||||
expected map[string]string
|
||||
name string
|
||||
targets []android.Target
|
||||
aaptPrebuiltDPI []string
|
||||
sdkVersion int
|
||||
expected map[string]string
|
||||
}{
|
||||
{
|
||||
name: "One",
|
||||
deviceArch: proptools.StringPtr("x86"),
|
||||
name: "One",
|
||||
targets: []android.Target{
|
||||
{Os: android.Android, Arch: android.Arch{ArchType: android.X86}},
|
||||
},
|
||||
aaptPrebuiltDPI: []string{"ldpi", "xxhdpi"},
|
||||
sdkVersion: 29,
|
||||
expected: map[string]string{
|
||||
|
@ -194,11 +195,13 @@ func TestAndroidAppSet_Variants(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
name: "Two",
|
||||
deviceArch: proptools.StringPtr("x86_64"),
|
||||
deviceSecondaryArch: proptools.StringPtr("x86"),
|
||||
aaptPrebuiltDPI: nil,
|
||||
sdkVersion: 30,
|
||||
name: "Two",
|
||||
targets: []android.Target{
|
||||
{Os: android.Android, Arch: android.Arch{ArchType: android.X86_64}},
|
||||
{Os: android.Android, Arch: android.Arch{ArchType: android.X86}},
|
||||
},
|
||||
aaptPrebuiltDPI: nil,
|
||||
sdkVersion: 30,
|
||||
expected: map[string]string{
|
||||
"abis": "X86_64,X86",
|
||||
"allow-prereleased": "false",
|
||||
|
@ -213,8 +216,7 @@ func TestAndroidAppSet_Variants(t *testing.T) {
|
|||
config := testAppConfig(nil, bp, nil)
|
||||
config.TestProductVariables.AAPTPrebuiltDPI = test.aaptPrebuiltDPI
|
||||
config.TestProductVariables.Platform_sdk_version = &test.sdkVersion
|
||||
config.TestProductVariables.DeviceArch = test.deviceArch
|
||||
config.TestProductVariables.DeviceSecondaryArch = test.deviceSecondaryArch
|
||||
config.Targets[android.Android] = test.targets
|
||||
ctx := testContext()
|
||||
run(t, ctx, config)
|
||||
module := ctx.ModuleForTests("foo", "android_common")
|
||||
|
|
Loading…
Reference in New Issue