Fix panic in builds with no device
Running prebuilts/build-tools/build-prebuilts.sh in a repo that
contains art/build/art.go panics because config.Targets[Device] is
empty. Check the length before accessing the slice.
Test: prebuilts/build-tools/build-prebuilts.sh
Change-Id: Ifb9fe0fad07b22d6b574f505c08c5c761278aad0
diff --git a/android/config.go b/android/config.go
index c3beb08..1f29d94 100644
--- a/android/config.go
+++ b/android/config.go
@@ -466,7 +466,11 @@
}
func (c *config) LibartImgDeviceBaseAddress() string {
- switch c.Targets[Device][0].Arch.ArchType {
+ archType := Common
+ if len(c.Targets[Device]) > 0 {
+ archType = c.Targets[Device][0].Arch.ArchType
+ }
+ switch archType {
default:
return "0x70000000"
case Mips, Mips64: