Export OsTypeList through a function.
This is a cleanup CL to make the OsTypeList accessor consistent with
ArchTypeList by creating a function that creates a copy of the
underlying slice.
Test: TH
Change-Id: I346c5c3937bbdb8a373e4d7135b896a5274cc1f1
diff --git a/android/arch.go b/android/arch.go
index 3eff5d5..6826f3b 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -167,7 +167,8 @@
return archType
}
-// ArchTypeList returns the 4 supported ArchTypes for arm, arm64, x86 and x86_64.
+// ArchTypeList returns the a slice copy of the 4 supported ArchTypes for arm,
+// arm64, x86 and x86_64.
func ArchTypeList() []ArchType {
return append([]ArchType(nil), archTypeList...)
}
@@ -266,7 +267,7 @@
DefaultDisabled: defDisabled,
}
- OsTypeList = append(OsTypeList, os)
+ osTypeList = append(osTypeList, os)
if _, found := commonTargetMap[name]; found {
panic(fmt.Errorf("Found Os type duplicate during OsType registration: %q", name))
@@ -280,7 +281,7 @@
// osByName returns the OsType that has the given name, or NoOsType if none match.
func osByName(name string) OsType {
- for _, os := range OsTypeList {
+ for _, os := range osTypeList {
if os.Name == name {
return os
}
@@ -312,9 +313,9 @@
}()
var (
- // OsTypeList contains a list of all the supported OsTypes, including ones not supported
+ // osTypeList contains a list of all the supported OsTypes, including ones not supported
// by the current build host or the target device.
- OsTypeList []OsType
+ osTypeList []OsType
// commonTargetMap maps names of OsTypes to the corresponding common Target, i.e. the
// Target with the same OsType and the common ArchType.
commonTargetMap = make(map[string]Target)
@@ -347,6 +348,11 @@
CommonArch = Arch{ArchType: Common}
)
+// OsTypeList returns a slice copy of the supported OsTypes.
+func OsTypeList() []OsType {
+ return append([]OsType(nil), osTypeList...)
+}
+
// Target specifies the OS and architecture that a module is being compiled for.
type Target struct {
// Os the OS that the module is being compiled for (e.g. "linux_glibc", "android").
@@ -448,7 +454,7 @@
// Collect a list of OSTypes supported by this module based on the HostOrDevice value
// passed to InitAndroidArchModule and the device_supported and host_supported properties.
var moduleOSList []OsType
- for _, os := range OsTypeList {
+ for _, os := range osTypeList {
for _, t := range mctx.Config().Targets[os] {
if base.supportsTarget(t) {
moduleOSList = append(moduleOSList, os)
@@ -838,7 +844,7 @@
"Arm_on_x86_64",
"Native_bridge",
}
- for _, os := range OsTypeList {
+ for _, os := range osTypeList {
// Add all the OSes.
targets = append(targets, os.Field)
@@ -1742,7 +1748,7 @@
}
// Iterate over the supported OS types
- for _, os := range OsTypeList {
+ for _, os := range osTypeList {
// e.g android, linux_bionic
field := os.Field