Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 1 | // Copyright 2021 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package bazel |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
Cole Faust | c843b99 | 2022-08-02 18:06:50 -0700 | [diff] [blame] | 19 | "math" |
| 20 | "sort" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 21 | "strings" |
| 22 | ) |
| 23 | |
| 24 | const ( |
| 25 | // ArchType names in arch.go |
Colin Cross | f05b0d3 | 2022-07-14 18:10:34 -0700 | [diff] [blame] | 26 | archArm = "arm" |
| 27 | archArm64 = "arm64" |
| 28 | archRiscv64 = "riscv64" |
| 29 | archX86 = "x86" |
| 30 | archX86_64 = "x86_64" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 31 | |
| 32 | // OsType names in arch.go |
Wei Li | 81852ca | 2022-07-27 00:22:06 -0700 | [diff] [blame] | 33 | OsAndroid = "android" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 34 | osDarwin = "darwin" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 35 | osLinux = "linux_glibc" |
Colin Cross | 528d67e | 2021-07-23 22:23:07 +0000 | [diff] [blame] | 36 | osLinuxMusl = "linux_musl" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 37 | osLinuxBionic = "linux_bionic" |
| 38 | osWindows = "windows" |
| 39 | |
| 40 | // Targets in arch.go |
| 41 | osArchAndroidArm = "android_arm" |
| 42 | osArchAndroidArm64 = "android_arm64" |
Colin Cross | f05b0d3 | 2022-07-14 18:10:34 -0700 | [diff] [blame] | 43 | osArchAndroidRiscv64 = "android_riscv64" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 44 | osArchAndroidX86 = "android_x86" |
| 45 | osArchAndroidX86_64 = "android_x86_64" |
Dan Willemsen | 8528f4e | 2021-10-19 00:22:06 -0700 | [diff] [blame] | 46 | osArchDarwinArm64 = "darwin_arm64" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 47 | osArchDarwinX86_64 = "darwin_x86_64" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 48 | osArchLinuxX86 = "linux_glibc_x86" |
| 49 | osArchLinuxX86_64 = "linux_glibc_x86_64" |
Colin Cross | a9b2aac | 2022-06-15 17:25:51 -0700 | [diff] [blame] | 50 | osArchLinuxMuslArm = "linux_musl_arm" |
| 51 | osArchLinuxMuslArm64 = "linux_musl_arm64" |
Colin Cross | 528d67e | 2021-07-23 22:23:07 +0000 | [diff] [blame] | 52 | osArchLinuxMuslX86 = "linux_musl_x86" |
| 53 | osArchLinuxMuslX86_64 = "linux_musl_x86_64" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 54 | osArchLinuxBionicArm64 = "linux_bionic_arm64" |
| 55 | osArchLinuxBionicX86_64 = "linux_bionic_x86_64" |
| 56 | osArchWindowsX86 = "windows_x86" |
| 57 | osArchWindowsX86_64 = "windows_x86_64" |
| 58 | |
| 59 | // This is the string representation of the default condition wherever a |
| 60 | // configurable attribute is used in a select statement, i.e. |
| 61 | // //conditions:default for Bazel. |
| 62 | // |
| 63 | // This is consistently named "conditions_default" to mirror the Soong |
| 64 | // config variable default key in an Android.bp file, although there's no |
| 65 | // integration with Soong config variables (yet). |
Chris Parsons | 51f8c39 | 2021-08-03 21:01:05 -0400 | [diff] [blame] | 66 | ConditionsDefaultConfigKey = "conditions_default" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 67 | |
| 68 | ConditionsDefaultSelectKey = "//conditions:default" |
| 69 | |
| 70 | productVariableBazelPackage = "//build/bazel/product_variables" |
Wei Li | 81852ca | 2022-07-27 00:22:06 -0700 | [diff] [blame] | 71 | |
| 72 | AndroidAndInApex = "android-in_apex" |
| 73 | AndroidAndNonApex = "android-non_apex" |
Vinh Tran | 85fb07c | 2022-09-16 16:17:48 -0400 | [diff] [blame] | 74 | |
| 75 | InApex = "in_apex" |
| 76 | NonApex = "non_apex" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 77 | ) |
| 78 | |
Cole Faust | c843b99 | 2022-08-02 18:06:50 -0700 | [diff] [blame] | 79 | func PowerSetWithoutEmptySet[T any](items []T) [][]T { |
| 80 | resultSize := int(math.Pow(2, float64(len(items)))) |
| 81 | powerSet := make([][]T, 0, resultSize-1) |
| 82 | for i := 1; i < resultSize; i++ { |
| 83 | combination := make([]T, 0) |
| 84 | for j := 0; j < len(items); j++ { |
| 85 | if (i>>j)%2 == 1 { |
| 86 | combination = append(combination, items[j]) |
| 87 | } |
| 88 | } |
| 89 | powerSet = append(powerSet, combination) |
| 90 | } |
| 91 | return powerSet |
| 92 | } |
| 93 | |
| 94 | func createPlatformArchMap() map[string]string { |
| 95 | // Copy of archFeatures from android/arch_list.go because the bazel |
| 96 | // package can't access the android package |
| 97 | archFeatures := map[string][]string{ |
| 98 | "arm": { |
| 99 | "neon", |
| 100 | }, |
| 101 | "arm64": { |
| 102 | "dotprod", |
| 103 | }, |
Colin Cross | f05b0d3 | 2022-07-14 18:10:34 -0700 | [diff] [blame] | 104 | "riscv64": {}, |
Cole Faust | c843b99 | 2022-08-02 18:06:50 -0700 | [diff] [blame] | 105 | "x86": { |
| 106 | "ssse3", |
| 107 | "sse4", |
| 108 | "sse4_1", |
| 109 | "sse4_2", |
| 110 | "aes_ni", |
| 111 | "avx", |
| 112 | "avx2", |
| 113 | "avx512", |
| 114 | "popcnt", |
| 115 | "movbe", |
| 116 | }, |
| 117 | "x86_64": { |
| 118 | "ssse3", |
| 119 | "sse4", |
| 120 | "sse4_1", |
| 121 | "sse4_2", |
| 122 | "aes_ni", |
| 123 | "avx", |
| 124 | "avx2", |
| 125 | "avx512", |
| 126 | "popcnt", |
| 127 | }, |
| 128 | } |
| 129 | result := make(map[string]string) |
| 130 | for arch, allFeatures := range archFeatures { |
| 131 | result[arch] = "//build/bazel/platforms/arch:" + arch |
| 132 | // Sometimes we want to select on multiple features being active, so |
| 133 | // add the power set of all possible features to the map. More details |
| 134 | // in android.ModuleBase.GetArchVariantProperties |
| 135 | for _, features := range PowerSetWithoutEmptySet(allFeatures) { |
| 136 | sort.Strings(features) |
| 137 | archFeaturesName := arch + "-" + strings.Join(features, "-") |
| 138 | result[archFeaturesName] = "//build/bazel/platforms/arch/variants:" + archFeaturesName |
| 139 | } |
| 140 | } |
| 141 | result[ConditionsDefaultConfigKey] = ConditionsDefaultSelectKey |
| 142 | return result |
| 143 | } |
| 144 | |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 145 | var ( |
| 146 | // These are the list of OSes and architectures with a Bazel config_setting |
| 147 | // and constraint value equivalent. These exist in arch.go, but the android |
| 148 | // package depends on the bazel package, so a cyclic dependency prevents |
| 149 | // using those variables here. |
| 150 | |
| 151 | // A map of architectures to the Bazel label of the constraint_value |
| 152 | // for the @platforms//cpu:cpu constraint_setting |
Cole Faust | c843b99 | 2022-08-02 18:06:50 -0700 | [diff] [blame] | 153 | platformArchMap = createPlatformArchMap() |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 154 | |
| 155 | // A map of target operating systems to the Bazel label of the |
| 156 | // constraint_value for the @platforms//os:os constraint_setting |
| 157 | platformOsMap = map[string]string{ |
Wei Li | 81852ca | 2022-07-27 00:22:06 -0700 | [diff] [blame] | 158 | OsAndroid: "//build/bazel/platforms/os:android", |
Chris Parsons | 51f8c39 | 2021-08-03 21:01:05 -0400 | [diff] [blame] | 159 | osDarwin: "//build/bazel/platforms/os:darwin", |
Colin Cross | 133782e | 2022-12-20 15:29:31 -0800 | [diff] [blame] | 160 | osLinux: "//build/bazel/platforms/os:linux_glibc", |
Chris Parsons | 51f8c39 | 2021-08-03 21:01:05 -0400 | [diff] [blame] | 161 | osLinuxMusl: "//build/bazel/platforms/os:linux_musl", |
| 162 | osLinuxBionic: "//build/bazel/platforms/os:linux_bionic", |
| 163 | osWindows: "//build/bazel/platforms/os:windows", |
| 164 | ConditionsDefaultConfigKey: ConditionsDefaultSelectKey, // The default condition of an os select map. |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | platformOsArchMap = map[string]string{ |
Chris Parsons | 51f8c39 | 2021-08-03 21:01:05 -0400 | [diff] [blame] | 168 | osArchAndroidArm: "//build/bazel/platforms/os_arch:android_arm", |
| 169 | osArchAndroidArm64: "//build/bazel/platforms/os_arch:android_arm64", |
Colin Cross | f05b0d3 | 2022-07-14 18:10:34 -0700 | [diff] [blame] | 170 | osArchAndroidRiscv64: "//build/bazel/platforms/os_arch:android_riscv64", |
Chris Parsons | 51f8c39 | 2021-08-03 21:01:05 -0400 | [diff] [blame] | 171 | osArchAndroidX86: "//build/bazel/platforms/os_arch:android_x86", |
| 172 | osArchAndroidX86_64: "//build/bazel/platforms/os_arch:android_x86_64", |
Dan Willemsen | 8528f4e | 2021-10-19 00:22:06 -0700 | [diff] [blame] | 173 | osArchDarwinArm64: "//build/bazel/platforms/os_arch:darwin_arm64", |
Chris Parsons | 51f8c39 | 2021-08-03 21:01:05 -0400 | [diff] [blame] | 174 | osArchDarwinX86_64: "//build/bazel/platforms/os_arch:darwin_x86_64", |
| 175 | osArchLinuxX86: "//build/bazel/platforms/os_arch:linux_glibc_x86", |
| 176 | osArchLinuxX86_64: "//build/bazel/platforms/os_arch:linux_glibc_x86_64", |
Colin Cross | a9b2aac | 2022-06-15 17:25:51 -0700 | [diff] [blame] | 177 | osArchLinuxMuslArm: "//build/bazel/platforms/os_arch:linux_musl_arm", |
| 178 | osArchLinuxMuslArm64: "//build/bazel/platforms/os_arch:linux_musl_arm64", |
Chris Parsons | 51f8c39 | 2021-08-03 21:01:05 -0400 | [diff] [blame] | 179 | osArchLinuxMuslX86: "//build/bazel/platforms/os_arch:linux_musl_x86", |
| 180 | osArchLinuxMuslX86_64: "//build/bazel/platforms/os_arch:linux_musl_x86_64", |
| 181 | osArchLinuxBionicArm64: "//build/bazel/platforms/os_arch:linux_bionic_arm64", |
| 182 | osArchLinuxBionicX86_64: "//build/bazel/platforms/os_arch:linux_bionic_x86_64", |
| 183 | osArchWindowsX86: "//build/bazel/platforms/os_arch:windows_x86", |
| 184 | osArchWindowsX86_64: "//build/bazel/platforms/os_arch:windows_x86_64", |
| 185 | ConditionsDefaultConfigKey: ConditionsDefaultSelectKey, // The default condition of an os select map. |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 186 | } |
Chris Parsons | 58852a0 | 2021-12-09 18:10:18 -0500 | [diff] [blame] | 187 | |
| 188 | // Map where keys are OsType names, and values are slices containing the archs |
| 189 | // that that OS supports. |
| 190 | // These definitions copied from arch.go. |
| 191 | // TODO(cparsons): Source from arch.go; this task is nontrivial, as it currently results |
| 192 | // in a cyclic dependency. |
| 193 | osToArchMap = map[string][]string{ |
Colin Cross | f05b0d3 | 2022-07-14 18:10:34 -0700 | [diff] [blame] | 194 | OsAndroid: {archArm, archArm64, archRiscv64, archX86, archX86_64}, |
Chris Parsons | 58852a0 | 2021-12-09 18:10:18 -0500 | [diff] [blame] | 195 | osLinux: {archX86, archX86_64}, |
| 196 | osLinuxMusl: {archX86, archX86_64}, |
| 197 | osDarwin: {archArm64, archX86_64}, |
| 198 | osLinuxBionic: {archArm64, archX86_64}, |
| 199 | // TODO(cparsons): According to arch.go, this should contain archArm, archArm64, as well. |
| 200 | osWindows: {archX86, archX86_64}, |
| 201 | } |
Wei Li | 81852ca | 2022-07-27 00:22:06 -0700 | [diff] [blame] | 202 | |
| 203 | osAndInApexMap = map[string]string{ |
| 204 | AndroidAndInApex: "//build/bazel/rules/apex:android-in_apex", |
| 205 | AndroidAndNonApex: "//build/bazel/rules/apex:android-non_apex", |
Liz Kammer | ffc17e4 | 2022-11-23 09:42:05 -0500 | [diff] [blame] | 206 | osDarwin: "//build/bazel/platforms/os:darwin", |
Colin Cross | 133782e | 2022-12-20 15:29:31 -0800 | [diff] [blame] | 207 | osLinux: "//build/bazel/platforms/os:linux_glibc", |
Liz Kammer | ffc17e4 | 2022-11-23 09:42:05 -0500 | [diff] [blame] | 208 | osLinuxMusl: "//build/bazel/platforms/os:linux_musl", |
| 209 | osLinuxBionic: "//build/bazel/platforms/os:linux_bionic", |
| 210 | osWindows: "//build/bazel/platforms/os:windows", |
Wei Li | 81852ca | 2022-07-27 00:22:06 -0700 | [diff] [blame] | 211 | ConditionsDefaultConfigKey: ConditionsDefaultSelectKey, |
| 212 | } |
Vinh Tran | 85fb07c | 2022-09-16 16:17:48 -0400 | [diff] [blame] | 213 | |
| 214 | inApexMap = map[string]string{ |
| 215 | InApex: "//build/bazel/rules/apex:in_apex", |
| 216 | NonApex: "//build/bazel/rules/apex:non_apex", |
| 217 | ConditionsDefaultConfigKey: ConditionsDefaultSelectKey, |
| 218 | } |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 219 | ) |
| 220 | |
| 221 | // basic configuration types |
| 222 | type configurationType int |
| 223 | |
| 224 | const ( |
| 225 | noConfig configurationType = iota |
| 226 | arch |
| 227 | os |
| 228 | osArch |
| 229 | productVariables |
Wei Li | 81852ca | 2022-07-27 00:22:06 -0700 | [diff] [blame] | 230 | osAndInApex |
Vinh Tran | 85fb07c | 2022-09-16 16:17:48 -0400 | [diff] [blame] | 231 | inApex |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 232 | ) |
| 233 | |
Chris Parsons | 58852a0 | 2021-12-09 18:10:18 -0500 | [diff] [blame] | 234 | func osArchString(os string, arch string) string { |
| 235 | return fmt.Sprintf("%s_%s", os, arch) |
| 236 | } |
| 237 | |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 238 | func (ct configurationType) String() string { |
| 239 | return map[configurationType]string{ |
| 240 | noConfig: "no_config", |
| 241 | arch: "arch", |
| 242 | os: "os", |
| 243 | osArch: "arch_os", |
| 244 | productVariables: "product_variables", |
Wei Li | 81852ca | 2022-07-27 00:22:06 -0700 | [diff] [blame] | 245 | osAndInApex: "os_in_apex", |
Vinh Tran | 85fb07c | 2022-09-16 16:17:48 -0400 | [diff] [blame] | 246 | inApex: "in_apex", |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 247 | }[ct] |
| 248 | } |
| 249 | |
| 250 | func (ct configurationType) validateConfig(config string) { |
| 251 | switch ct { |
| 252 | case noConfig: |
| 253 | if config != "" { |
| 254 | panic(fmt.Errorf("Cannot specify config with %s, but got %s", ct, config)) |
| 255 | } |
| 256 | case arch: |
| 257 | if _, ok := platformArchMap[config]; !ok { |
| 258 | panic(fmt.Errorf("Unknown arch: %s", config)) |
| 259 | } |
| 260 | case os: |
| 261 | if _, ok := platformOsMap[config]; !ok { |
| 262 | panic(fmt.Errorf("Unknown os: %s", config)) |
| 263 | } |
| 264 | case osArch: |
| 265 | if _, ok := platformOsArchMap[config]; !ok { |
| 266 | panic(fmt.Errorf("Unknown os+arch: %s", config)) |
| 267 | } |
| 268 | case productVariables: |
| 269 | // do nothing |
Wei Li | 81852ca | 2022-07-27 00:22:06 -0700 | [diff] [blame] | 270 | case osAndInApex: |
Spandan Das | 4242f10 | 2023-04-19 22:31:54 +0000 | [diff] [blame] | 271 | // do nothing |
| 272 | // this axis can contain additional per-apex keys |
Vinh Tran | 85fb07c | 2022-09-16 16:17:48 -0400 | [diff] [blame] | 273 | case inApex: |
| 274 | if _, ok := inApexMap[config]; !ok { |
| 275 | panic(fmt.Errorf("Unknown in_apex config: %s", config)) |
| 276 | } |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 277 | default: |
| 278 | panic(fmt.Errorf("Unrecognized ConfigurationType %d", ct)) |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | // SelectKey returns the Bazel select key for a given configurationType and config string. |
Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 283 | func (ca ConfigurationAxis) SelectKey(config string) string { |
| 284 | ca.validateConfig(config) |
| 285 | switch ca.configurationType { |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 286 | case noConfig: |
| 287 | panic(fmt.Errorf("SelectKey is unnecessary for noConfig ConfigurationType ")) |
| 288 | case arch: |
| 289 | return platformArchMap[config] |
| 290 | case os: |
| 291 | return platformOsMap[config] |
| 292 | case osArch: |
| 293 | return platformOsArchMap[config] |
| 294 | case productVariables: |
Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 295 | if strings.HasSuffix(config, ConditionsDefaultConfigKey) { |
| 296 | // e.g. "acme__feature1__conditions_default" or "android__board__conditions_default" |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 297 | return ConditionsDefaultSelectKey |
| 298 | } |
Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 299 | return fmt.Sprintf("%s:%s", productVariableBazelPackage, config) |
Wei Li | 81852ca | 2022-07-27 00:22:06 -0700 | [diff] [blame] | 300 | case osAndInApex: |
Spandan Das | 4242f10 | 2023-04-19 22:31:54 +0000 | [diff] [blame] | 301 | if ret, exists := osAndInApexMap[config]; exists { |
| 302 | return ret |
| 303 | } |
| 304 | return config |
Vinh Tran | 85fb07c | 2022-09-16 16:17:48 -0400 | [diff] [blame] | 305 | case inApex: |
| 306 | return inApexMap[config] |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 307 | default: |
Jingwen Chen | a47f28d | 2021-11-02 16:43:57 +0000 | [diff] [blame] | 308 | panic(fmt.Errorf("Unrecognized ConfigurationType %d", ca.configurationType)) |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 309 | } |
| 310 | } |
| 311 | |
| 312 | var ( |
| 313 | // Indicating there is no configuration axis |
| 314 | NoConfigAxis = ConfigurationAxis{configurationType: noConfig} |
| 315 | // An axis for architecture-specific configurations |
| 316 | ArchConfigurationAxis = ConfigurationAxis{configurationType: arch} |
| 317 | // An axis for os-specific configurations |
| 318 | OsConfigurationAxis = ConfigurationAxis{configurationType: os} |
| 319 | // An axis for arch+os-specific configurations |
| 320 | OsArchConfigurationAxis = ConfigurationAxis{configurationType: osArch} |
Wei Li | 81852ca | 2022-07-27 00:22:06 -0700 | [diff] [blame] | 321 | // An axis for os+in_apex-specific configurations |
| 322 | OsAndInApexAxis = ConfigurationAxis{configurationType: osAndInApex} |
Vinh Tran | 85fb07c | 2022-09-16 16:17:48 -0400 | [diff] [blame] | 323 | // An axis for in_apex-specific configurations |
| 324 | InApexAxis = ConfigurationAxis{configurationType: inApex} |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 325 | ) |
| 326 | |
| 327 | // ProductVariableConfigurationAxis returns an axis for the given product variable |
Alix | bbfd538 | 2022-06-09 18:52:05 +0000 | [diff] [blame] | 328 | func ProductVariableConfigurationAxis(variable string, outerAxis ConfigurationAxis) ConfigurationAxis { |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 329 | return ConfigurationAxis{ |
| 330 | configurationType: productVariables, |
| 331 | subType: variable, |
Alix | bbfd538 | 2022-06-09 18:52:05 +0000 | [diff] [blame] | 332 | outerAxisType: outerAxis.configurationType, |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 333 | } |
| 334 | } |
| 335 | |
| 336 | // ConfigurationAxis is an independent axis for configuration, there should be no overlap between |
| 337 | // elements within an axis. |
| 338 | type ConfigurationAxis struct { |
| 339 | configurationType |
| 340 | // some configuration types (e.g. productVariables) have multiple independent axes, subType helps |
| 341 | // distinguish between them without needing to list all 17 product variables. |
| 342 | subType string |
Alix | bbfd538 | 2022-06-09 18:52:05 +0000 | [diff] [blame] | 343 | // used to keep track of which product variables are arch variant |
| 344 | outerAxisType configurationType |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | func (ca *ConfigurationAxis) less(other ConfigurationAxis) bool { |
Chris Parsons | 7b3289b | 2023-01-26 17:30:44 -0500 | [diff] [blame] | 348 | if ca.configurationType == other.configurationType { |
| 349 | return ca.subType < other.subType |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 350 | } |
Chris Parsons | 7b3289b | 2023-01-26 17:30:44 -0500 | [diff] [blame] | 351 | return ca.configurationType < other.configurationType |
Liz Kammer | 9abd62d | 2021-05-21 08:37:59 -0400 | [diff] [blame] | 352 | } |