blob: df50afa0ca9e3e1ffab89c488ccc82f75619db76 [file] [log] [blame]
Colin Cross3f40fa42015-01-30 17:27:36 -08001// Copyright 2015 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
Colin Cross635c3b02016-05-18 15:37:25 -070015package android
Colin Cross3f40fa42015-01-30 17:27:36 -080016
17import (
Colin Cross3f40fa42015-01-30 17:27:36 -080018 "fmt"
19 "reflect"
20 "runtime"
21 "strings"
Colin Crossf6566ed2015-03-24 11:13:38 -070022
23 "github.com/google/blueprint"
24 "github.com/google/blueprint/proptools"
Colin Cross3f40fa42015-01-30 17:27:36 -080025)
26
27var (
Dan Willemsenb1957a52016-06-23 23:44:54 -070028 archTypeList []ArchType
29
Colin Crossec193632015-07-06 17:49:43 -070030 Arm = newArch("arm", "lib32")
31 Arm64 = newArch("arm64", "lib64")
32 Mips = newArch("mips", "lib32")
33 Mips64 = newArch("mips64", "lib64")
34 X86 = newArch("x86", "lib32")
35 X86_64 = newArch("x86_64", "lib64")
Colin Cross2fe66872015-03-30 17:20:39 -070036
37 Common = ArchType{
38 Name: "common",
39 }
Colin Cross3f40fa42015-01-30 17:27:36 -080040)
41
Colin Cross4225f652015-09-17 14:33:42 -070042var archTypeMap = map[string]ArchType{
43 "arm": Arm,
44 "arm64": Arm64,
45 "mips": Mips,
Colin Cross3b336c22015-11-23 16:28:31 -080046 "mips64": Mips64,
Colin Cross4225f652015-09-17 14:33:42 -070047 "x86": X86,
48 "x86_64": X86_64,
49}
50
Colin Cross3f40fa42015-01-30 17:27:36 -080051/*
52Example blueprints file containing all variant property groups, with comment listing what type
53of variants get properties in that group:
54
55module {
56 arch: {
57 arm: {
58 // Host or device variants with arm architecture
59 },
60 arm64: {
61 // Host or device variants with arm64 architecture
62 },
63 mips: {
64 // Host or device variants with mips architecture
65 },
66 mips64: {
67 // Host or device variants with mips64 architecture
68 },
69 x86: {
70 // Host or device variants with x86 architecture
71 },
72 x86_64: {
73 // Host or device variants with x86_64 architecture
74 },
75 },
76 multilib: {
77 lib32: {
78 // Host or device variants for 32-bit architectures
79 },
80 lib64: {
81 // Host or device variants for 64-bit architectures
82 },
83 },
84 target: {
85 android: {
86 // Device variants
87 },
88 host: {
89 // Host variants
90 },
91 linux: {
92 // Linux host variants
93 },
94 darwin: {
95 // Darwin host variants
96 },
97 windows: {
98 // Windows host variants
99 },
100 not_windows: {
101 // Non-windows host variants
102 },
103 },
104}
105*/
Colin Cross7d5136f2015-05-11 13:39:40 -0700106
Dan Willemsenb1957a52016-06-23 23:44:54 -0700107var archVariants = map[ArchType][]string{}
108var archFeatures = map[ArchType][]string{}
Colin Crossc5c24ad2015-11-20 15:35:00 -0800109var archFeatureMap = map[ArchType]map[string][]string{}
110
Dan Willemsenb1957a52016-06-23 23:44:54 -0700111func RegisterArchVariants(arch ArchType, variants ...string) {
112 checkCalledFromInit()
113 archVariants[arch] = append(archVariants[arch], variants...)
114}
115
116func RegisterArchFeatures(arch ArchType, features ...string) {
117 checkCalledFromInit()
118 archFeatures[arch] = append(archFeatures[arch], features...)
119}
120
121func RegisterArchVariantFeatures(arch ArchType, variant string, features ...string) {
122 checkCalledFromInit()
123 if variant != "" && !inList(variant, archVariants[arch]) {
124 panic(fmt.Errorf("Invalid variant %q for arch %q", variant, arch))
Colin Crossc5c24ad2015-11-20 15:35:00 -0800125 }
Dan Willemsenb1957a52016-06-23 23:44:54 -0700126
Colin Crossc5c24ad2015-11-20 15:35:00 -0800127 for _, feature := range features {
Dan Willemsenb1957a52016-06-23 23:44:54 -0700128 if !inList(feature, archFeatures[arch]) {
Colin Crossc5c24ad2015-11-20 15:35:00 -0800129 panic(fmt.Errorf("Invalid feature %q for arch %q variant %q", feature, arch, variant))
130 }
131 }
Dan Willemsenb1957a52016-06-23 23:44:54 -0700132
Colin Crossc5c24ad2015-11-20 15:35:00 -0800133 if archFeatureMap[arch] == nil {
134 archFeatureMap[arch] = make(map[string][]string)
135 }
136 archFeatureMap[arch][variant] = features
137}
138
Colin Cross3f40fa42015-01-30 17:27:36 -0800139// An Arch indicates a single CPU architecture.
140type Arch struct {
Colin Crossc5c24ad2015-11-20 15:35:00 -0800141 ArchType ArchType
142 ArchVariant string
143 CpuVariant string
144 Abi []string
145 ArchFeatures []string
Dan Willemsen17f05262016-05-31 16:27:00 -0700146 Native bool
Colin Cross3f40fa42015-01-30 17:27:36 -0800147}
148
149func (a Arch) String() string {
Colin Crossd3ba0392015-05-07 14:11:29 -0700150 s := a.ArchType.String()
Colin Cross3f40fa42015-01-30 17:27:36 -0800151 if a.ArchVariant != "" {
152 s += "_" + a.ArchVariant
153 }
154 if a.CpuVariant != "" {
155 s += "_" + a.CpuVariant
156 }
157 return s
158}
159
160type ArchType struct {
Colin Crossec193632015-07-06 17:49:43 -0700161 Name string
Dan Willemsenb1957a52016-06-23 23:44:54 -0700162 Field string
Colin Crossec193632015-07-06 17:49:43 -0700163 Multilib string
Colin Cross3f40fa42015-01-30 17:27:36 -0800164}
165
Colin Crossec193632015-07-06 17:49:43 -0700166func newArch(name, multilib string) ArchType {
Dan Willemsenb1957a52016-06-23 23:44:54 -0700167 archType := ArchType{
Colin Crossec193632015-07-06 17:49:43 -0700168 Name: name,
Dan Willemsenb1957a52016-06-23 23:44:54 -0700169 Field: proptools.FieldNameForProperty(name),
Colin Crossec193632015-07-06 17:49:43 -0700170 Multilib: multilib,
Colin Cross3f40fa42015-01-30 17:27:36 -0800171 }
Dan Willemsenb1957a52016-06-23 23:44:54 -0700172 archTypeList = append(archTypeList, archType)
173 return archType
Colin Cross3f40fa42015-01-30 17:27:36 -0800174}
175
176func (a ArchType) String() string {
177 return a.Name
178}
179
Colin Crossa1ad8d12016-06-01 17:09:44 -0700180var BuildOs = func() OsType {
Dan Willemsen490fd492015-11-24 17:53:15 -0800181 switch runtime.GOOS {
182 case "linux":
183 return Linux
184 case "darwin":
185 return Darwin
186 default:
187 panic(fmt.Sprintf("unsupported OS: %s", runtime.GOOS))
188 }
Colin Crossa1ad8d12016-06-01 17:09:44 -0700189}()
190
191var (
192 osTypeList []OsType
193
Dan Willemsen00fcbde2016-11-17 00:25:59 -0800194 NoOsType OsType
195 Linux = NewOsType("linux", Host, false)
196 Darwin = NewOsType("darwin", Host, false)
197 LinuxBionic = NewOsType("linux_bionic", Host, true)
198 Windows = NewOsType("windows", HostCross, true)
199 Android = NewOsType("android", Device, false)
Dan Willemsenb1957a52016-06-23 23:44:54 -0700200
201 osArchTypeMap = map[OsType][]ArchType{
Dan Willemsen00fcbde2016-11-17 00:25:59 -0800202 Linux: []ArchType{X86, X86_64},
203 LinuxBionic: []ArchType{X86_64},
204 Darwin: []ArchType{X86, X86_64},
205 Windows: []ArchType{X86, X86_64},
206 Android: []ArchType{Arm, Arm64, Mips, Mips64, X86, X86_64},
Dan Willemsenb1957a52016-06-23 23:44:54 -0700207 }
Colin Crossa1ad8d12016-06-01 17:09:44 -0700208)
209
210type OsType struct {
211 Name, Field string
212 Class OsClass
Dan Willemsen0a37a2a2016-11-13 10:16:05 -0800213
214 DefaultDisabled bool
Dan Willemsen490fd492015-11-24 17:53:15 -0800215}
216
Colin Crossa1ad8d12016-06-01 17:09:44 -0700217type OsClass int
218
219const (
220 Device OsClass = iota
221 Host
222 HostCross
223)
224
225func (os OsType) String() string {
226 return os.Name
Colin Cross54c71122016-06-01 17:09:44 -0700227}
228
Dan Willemsen0a37a2a2016-11-13 10:16:05 -0800229func NewOsType(name string, class OsClass, defDisabled bool) OsType {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700230 os := OsType{
231 Name: name,
232 Field: strings.Title(name),
233 Class: class,
Dan Willemsen0a37a2a2016-11-13 10:16:05 -0800234
235 DefaultDisabled: defDisabled,
Colin Cross54c71122016-06-01 17:09:44 -0700236 }
Colin Crossa1ad8d12016-06-01 17:09:44 -0700237 osTypeList = append(osTypeList, os)
238 return os
239}
240
241func osByName(name string) OsType {
242 for _, os := range osTypeList {
243 if os.Name == name {
244 return os
245 }
246 }
247
248 return NoOsType
Dan Willemsen490fd492015-11-24 17:53:15 -0800249}
250
Colin Cross3f40fa42015-01-30 17:27:36 -0800251var (
Colin Crossa1ad8d12016-06-01 17:09:44 -0700252 commonTarget = Target{
253 Os: Android,
254 Arch: Arch{
255 ArchType: Common,
256 },
Colin Cross2fe66872015-03-30 17:20:39 -0700257 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800258)
259
Colin Crossa1ad8d12016-06-01 17:09:44 -0700260type Target struct {
261 Os OsType
262 Arch Arch
Colin Crossd3ba0392015-05-07 14:11:29 -0700263}
264
Colin Crossa1ad8d12016-06-01 17:09:44 -0700265func (target Target) String() string {
266 return target.Os.String() + "_" + target.Arch.String()
Dan Willemsen490fd492015-11-24 17:53:15 -0800267}
268
Colin Cross1e676be2016-10-12 14:38:15 -0700269func archMutator(mctx BottomUpMutatorContext) {
Colin Cross635c3b02016-05-18 15:37:25 -0700270 var module Module
Colin Cross3f40fa42015-01-30 17:27:36 -0800271 var ok bool
Colin Cross635c3b02016-05-18 15:37:25 -0700272 if module, ok = mctx.Module().(Module); !ok {
Colin Cross3f40fa42015-01-30 17:27:36 -0800273 return
274 }
275
Dan Willemsen0b24c742016-10-04 15:13:37 -0700276 if !module.base().ArchSpecific() {
Colin Crossb9db4802016-06-03 01:50:47 +0000277 return
278 }
279
Dan Willemsen0b24c742016-10-04 15:13:37 -0700280 osClasses := module.base().OsClassSupported()
281
Colin Crossa1ad8d12016-06-01 17:09:44 -0700282 var moduleTargets []Target
Colin Cross8b74d172016-09-13 09:59:14 -0700283 primaryModules := make(map[int]bool)
Colin Crossa1ad8d12016-06-01 17:09:44 -0700284
285 for _, class := range osClasses {
286 targets := mctx.AConfig().Targets[class]
287 if len(targets) == 0 {
288 continue
289 }
Colin Cross69617d32016-09-06 10:39:07 -0700290 var multilib string
291 switch class {
292 case Device:
293 multilib = module.base().commonProperties.Target.Android.Compile_multilib
294 case Host, HostCross:
295 multilib = module.base().commonProperties.Target.Host.Compile_multilib
296 }
297 if multilib == "" {
298 multilib = module.base().commonProperties.Compile_multilib
299 }
300 if multilib == "" {
301 multilib = module.base().commonProperties.Default_multilib
302 }
Colin Cross628a88c2016-09-13 15:15:51 -0700303 var prefer32 bool
304 switch class {
305 case Device:
Colin Cross8b74d172016-09-13 09:59:14 -0700306 prefer32 = mctx.AConfig().DevicePrefer32BitExecutables()
Colin Cross628a88c2016-09-13 15:15:51 -0700307 case HostCross:
308 // Windows builds always prefer 32-bit
309 prefer32 = true
Colin Cross8b74d172016-09-13 09:59:14 -0700310 }
311 targets, err := decodeMultilib(multilib, targets, prefer32)
Colin Crossa1ad8d12016-06-01 17:09:44 -0700312 if err != nil {
313 mctx.ModuleErrorf("%s", err.Error())
314 }
Colin Cross8b74d172016-09-13 09:59:14 -0700315 if len(targets) > 0 {
316 primaryModules[len(moduleTargets)] = true
317 moduleTargets = append(moduleTargets, targets...)
318 }
Colin Crossb9db4802016-06-03 01:50:47 +0000319 }
320
Dan Willemsen3f32f032016-07-11 14:36:48 -0700321 if len(moduleTargets) == 0 {
322 module.base().commonProperties.Enabled = boolPtr(false)
323 return
324 }
325
Colin Crossa1ad8d12016-06-01 17:09:44 -0700326 targetNames := make([]string, len(moduleTargets))
Colin Crossb9db4802016-06-03 01:50:47 +0000327
Colin Crossa1ad8d12016-06-01 17:09:44 -0700328 for i, target := range moduleTargets {
329 targetNames[i] = target.String()
330 }
331
332 modules := mctx.CreateVariations(targetNames...)
Colin Cross3f40fa42015-01-30 17:27:36 -0800333 for i, m := range modules {
Colin Cross8b74d172016-09-13 09:59:14 -0700334 m.(Module).base().SetTarget(moduleTargets[i], primaryModules[i])
Colin Cross635c3b02016-05-18 15:37:25 -0700335 m.(Module).base().setArchProperties(mctx)
Colin Cross3f40fa42015-01-30 17:27:36 -0800336 }
337}
338
Dan Willemsenb1957a52016-06-23 23:44:54 -0700339func filterArchStruct(prop reflect.Type) (reflect.Type, bool) {
340 var fields []reflect.StructField
341
342 ptr := prop.Kind() == reflect.Ptr
343 if ptr {
344 prop = prop.Elem()
345 }
346
347 for i := 0; i < prop.NumField(); i++ {
348 field := prop.Field(i)
349 if !proptools.HasTag(field, "android", "arch_variant") {
350 continue
351 }
352
353 // The arch_variant field isn't necessary past this point
354 // Instead of wasting space, just remove it. Go also has a
355 // 16-bit limit on structure name length. The name is constructed
356 // based on the Go source representation of the structure, so
357 // the tag names count towards that length.
358 //
359 // TODO: handle the uncommon case of other tags being involved
360 if field.Tag == `android:"arch_variant"` {
361 field.Tag = ""
362 }
363
364 // Recurse into structs
365 switch field.Type.Kind() {
366 case reflect.Struct:
367 var ok bool
368 field.Type, ok = filterArchStruct(field.Type)
369 if !ok {
370 continue
371 }
372 case reflect.Ptr:
373 if field.Type.Elem().Kind() == reflect.Struct {
374 nestedType, ok := filterArchStruct(field.Type.Elem())
375 if !ok {
376 continue
377 }
378 field.Type = reflect.PtrTo(nestedType)
379 }
380 case reflect.Interface:
381 panic("Interfaces are not supported in arch_variant properties")
382 }
383
384 fields = append(fields, field)
385 }
386 if len(fields) == 0 {
387 return nil, false
388 }
389
390 ret := reflect.StructOf(fields)
391 if ptr {
392 ret = reflect.PtrTo(ret)
393 }
394 return ret, true
395}
396
397func createArchType(props reflect.Type) reflect.Type {
398 props, ok := filterArchStruct(props)
399 if !ok {
400 return nil
401 }
402
403 variantFields := func(names []string) []reflect.StructField {
404 ret := make([]reflect.StructField, len(names))
405
406 for i, name := range names {
407 ret[i].Name = name
408 ret[i].Type = props
409 }
410
411 return ret
412 }
413
414 archFields := make([]reflect.StructField, len(archTypeList))
415 for i, arch := range archTypeList {
416 variants := []string{}
417
418 for _, archVariant := range archVariants[arch] {
419 variants = append(variants, proptools.FieldNameForProperty(archVariant))
420 }
421 for _, feature := range archFeatures[arch] {
422 variants = append(variants, proptools.FieldNameForProperty(feature))
423 }
424
425 fields := variantFields(variants)
426
427 fields = append([]reflect.StructField{reflect.StructField{
428 Name: "BlueprintEmbed",
429 Type: props,
430 Anonymous: true,
431 }}, fields...)
432
433 archFields[i] = reflect.StructField{
434 Name: arch.Field,
435 Type: reflect.StructOf(fields),
436 }
437 }
438 archType := reflect.StructOf(archFields)
439
440 multilibType := reflect.StructOf(variantFields([]string{"Lib32", "Lib64"}))
441
442 targets := []string{
443 "Host",
444 "Android64",
445 "Android32",
446 "Not_windows",
Colin Crossbb2e2b72016-12-08 17:23:53 -0800447 "Arm_on_x86",
448 "Arm_on_x86_64",
Dan Willemsenb1957a52016-06-23 23:44:54 -0700449 }
450 for _, os := range osTypeList {
451 targets = append(targets, os.Field)
452
453 for _, archType := range osArchTypeMap[os] {
454 targets = append(targets, os.Field+"_"+archType.Name)
455 }
456 }
457
458 targetType := reflect.StructOf(variantFields(targets))
459 return reflect.StructOf([]reflect.StructField{
460 reflect.StructField{
461 Name: "Arch",
462 Type: archType,
463 },
464 reflect.StructField{
465 Name: "Multilib",
466 Type: multilibType,
467 },
468 reflect.StructField{
469 Name: "Target",
470 Type: targetType,
471 },
472 })
473}
474
475var archPropTypeMap OncePer
476
Colin Cross635c3b02016-05-18 15:37:25 -0700477func InitArchModule(m Module,
Colin Cross3f40fa42015-01-30 17:27:36 -0800478 propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
479
480 base := m.base()
481
Colin Cross3f40fa42015-01-30 17:27:36 -0800482 base.generalProperties = append(base.generalProperties,
Colin Cross3f40fa42015-01-30 17:27:36 -0800483 propertyStructs...)
484
485 for _, properties := range base.generalProperties {
486 propertiesValue := reflect.ValueOf(properties)
Colin Cross62496a02016-08-08 15:49:17 -0700487 t := propertiesValue.Type()
Colin Cross3f40fa42015-01-30 17:27:36 -0800488 if propertiesValue.Kind() != reflect.Ptr {
Colin Crossca860ac2016-01-04 14:34:37 -0800489 panic(fmt.Errorf("properties must be a pointer to a struct, got %T",
490 propertiesValue.Interface()))
Colin Cross3f40fa42015-01-30 17:27:36 -0800491 }
492
493 propertiesValue = propertiesValue.Elem()
494 if propertiesValue.Kind() != reflect.Struct {
Colin Crossca860ac2016-01-04 14:34:37 -0800495 panic(fmt.Errorf("properties must be a pointer to a struct, got %T",
496 propertiesValue.Interface()))
Colin Cross3f40fa42015-01-30 17:27:36 -0800497 }
498
Dan Willemsenb1957a52016-06-23 23:44:54 -0700499 archPropType := archPropTypeMap.Once(t, func() interface{} {
500 return createArchType(t)
Colin Cross3f40fa42015-01-30 17:27:36 -0800501 })
502
Dan Willemsenb1957a52016-06-23 23:44:54 -0700503 if archPropType != nil {
504 base.archProperties = append(base.archProperties, reflect.New(archPropType.(reflect.Type)).Interface())
505 } else {
506 base.archProperties = append(base.archProperties, nil)
507 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800508 }
509
510 var allProperties []interface{}
511 allProperties = append(allProperties, base.generalProperties...)
512 for _, asp := range base.archProperties {
Dan Willemsenb1957a52016-06-23 23:44:54 -0700513 if asp != nil {
514 allProperties = append(allProperties, asp)
515 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800516 }
517
Colin Crossa120ec12016-08-19 16:07:38 -0700518 base.customizableProperties = allProperties
519
Colin Cross3f40fa42015-01-30 17:27:36 -0800520 return m, allProperties
521}
522
Colin Crossa716add2015-12-16 11:07:39 -0800523var variantReplacer = strings.NewReplacer("-", "_", ".", "_")
Colin Crossec193632015-07-06 17:49:43 -0700524
Colin Cross635c3b02016-05-18 15:37:25 -0700525func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
Dan Willemsenb1957a52016-06-23 23:44:54 -0700526 dst interface{}, src reflect.Value, field, srcPrefix string) reflect.Value {
Colin Cross06a931b2015-10-28 17:23:31 -0700527
Dan Willemsenb1957a52016-06-23 23:44:54 -0700528 src = src.FieldByName(field)
529 if !src.IsValid() {
Colin Crosseeabb892015-11-20 13:07:51 -0800530 ctx.ModuleErrorf("field %q does not exist", srcPrefix)
Dan Willemsenb1957a52016-06-23 23:44:54 -0700531 return src
Colin Cross85a88972015-11-23 13:29:51 -0800532 }
533
Dan Willemsenb1957a52016-06-23 23:44:54 -0700534 ret := src
Colin Cross85a88972015-11-23 13:29:51 -0800535
Dan Willemsenb1957a52016-06-23 23:44:54 -0700536 if src.Kind() == reflect.Struct {
537 src = src.FieldByName("BlueprintEmbed")
Colin Cross06a931b2015-10-28 17:23:31 -0700538 }
539
Colin Cross6ee75b62016-05-05 15:57:15 -0700540 order := func(property string,
541 dstField, srcField reflect.StructField,
542 dstValue, srcValue interface{}) (proptools.Order, error) {
543 if proptools.HasTag(dstField, "android", "variant_prepend") {
544 return proptools.Prepend, nil
545 } else {
546 return proptools.Append, nil
547 }
548 }
549
Dan Willemsenb1957a52016-06-23 23:44:54 -0700550 err := proptools.ExtendMatchingProperties([]interface{}{dst}, src.Interface(), nil, order)
Colin Cross06a931b2015-10-28 17:23:31 -0700551 if err != nil {
552 if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
553 ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
554 } else {
555 panic(err)
556 }
557 }
Colin Cross85a88972015-11-23 13:29:51 -0800558
Dan Willemsenb1957a52016-06-23 23:44:54 -0700559 return ret
Colin Cross06a931b2015-10-28 17:23:31 -0700560}
561
Colin Cross3f40fa42015-01-30 17:27:36 -0800562// Rewrite the module's properties structs to contain arch-specific values.
Colin Cross635c3b02016-05-18 15:37:25 -0700563func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700564 arch := a.Arch()
565 os := a.Os()
Colin Crossd3ba0392015-05-07 14:11:29 -0700566
Colin Cross2fe66872015-03-30 17:20:39 -0700567 if arch.ArchType == Common {
568 return
569 }
570
Colin Cross3f40fa42015-01-30 17:27:36 -0800571 for i := range a.generalProperties {
Colin Cross06a931b2015-10-28 17:23:31 -0700572 genProps := a.generalProperties[i]
Dan Willemsenb1957a52016-06-23 23:44:54 -0700573 if a.archProperties[i] == nil {
574 continue
575 }
576 archProps := reflect.ValueOf(a.archProperties[i]).Elem()
577
578 archProp := archProps.FieldByName("Arch")
579 multilibProp := archProps.FieldByName("Multilib")
580 targetProp := archProps.FieldByName("Target")
581
Colin Cross3f40fa42015-01-30 17:27:36 -0800582 // Handle arch-specific properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700583 // arch: {
584 // arm64: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800585 // key: value,
586 // },
587 // },
588 t := arch.ArchType
Colin Cross06a931b2015-10-28 17:23:31 -0700589
Colin Crossec193632015-07-06 17:49:43 -0700590 field := proptools.FieldNameForProperty(t.Name)
Colin Cross06a931b2015-10-28 17:23:31 -0700591 prefix := "arch." + t.Name
Dan Willemsenb1957a52016-06-23 23:44:54 -0700592 archStruct := a.appendProperties(ctx, genProps, archProp, field, prefix)
Colin Crossec193632015-07-06 17:49:43 -0700593
594 // Handle arch-variant-specific properties in the form:
595 // arch: {
596 // variant: {
597 // key: value,
598 // },
599 // },
Colin Crossa716add2015-12-16 11:07:39 -0800600 v := variantReplacer.Replace(arch.ArchVariant)
Colin Crossec193632015-07-06 17:49:43 -0700601 if v != "" {
602 field := proptools.FieldNameForProperty(v)
Colin Cross85a88972015-11-23 13:29:51 -0800603 prefix := "arch." + t.Name + "." + v
604 a.appendProperties(ctx, genProps, archStruct, field, prefix)
Colin Crossec193632015-07-06 17:49:43 -0700605 }
606
607 // Handle cpu-variant-specific properties in the form:
608 // arch: {
609 // variant: {
610 // key: value,
611 // },
612 // },
Colin Cross08016332016-12-20 09:53:14 -0800613 if arch.CpuVariant != arch.ArchVariant {
614 c := variantReplacer.Replace(arch.CpuVariant)
615 if c != "" {
616 field := proptools.FieldNameForProperty(c)
617 prefix := "arch." + t.Name + "." + c
618 a.appendProperties(ctx, genProps, archStruct, field, prefix)
619 }
Colin Crossec193632015-07-06 17:49:43 -0700620 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800621
Colin Crossc5c24ad2015-11-20 15:35:00 -0800622 // Handle arch-feature-specific properties in the form:
623 // arch: {
624 // feature: {
625 // key: value,
626 // },
627 // },
628 for _, feature := range arch.ArchFeatures {
629 field := proptools.FieldNameForProperty(feature)
Colin Cross85a88972015-11-23 13:29:51 -0800630 prefix := "arch." + t.Name + "." + feature
631 a.appendProperties(ctx, genProps, archStruct, field, prefix)
Colin Crossc5c24ad2015-11-20 15:35:00 -0800632 }
633
Colin Cross3f40fa42015-01-30 17:27:36 -0800634 // Handle multilib-specific properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700635 // multilib: {
636 // lib32: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800637 // key: value,
638 // },
639 // },
Colin Cross06a931b2015-10-28 17:23:31 -0700640 field = proptools.FieldNameForProperty(t.Multilib)
641 prefix = "multilib." + t.Multilib
Dan Willemsenb1957a52016-06-23 23:44:54 -0700642 a.appendProperties(ctx, genProps, multilibProp, field, prefix)
Colin Cross3f40fa42015-01-30 17:27:36 -0800643
Colin Crossa1ad8d12016-06-01 17:09:44 -0700644 // Handle host-specific properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700645 // target: {
646 // host: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800647 // key: value,
648 // },
649 // },
Colin Crossa1ad8d12016-06-01 17:09:44 -0700650 if os.Class == Host || os.Class == HostCross {
651 field = "Host"
652 prefix = "target.host"
Dan Willemsenb1957a52016-06-23 23:44:54 -0700653 a.appendProperties(ctx, genProps, targetProp, field, prefix)
Colin Crossa1ad8d12016-06-01 17:09:44 -0700654 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800655
Colin Crossa1ad8d12016-06-01 17:09:44 -0700656 // Handle target OS properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700657 // target: {
658 // linux: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800659 // key: value,
660 // },
Colin Crossb05bff22015-04-30 15:08:04 -0700661 // not_windows: {
662 // key: value,
663 // },
664 // linux_x86: {
665 // key: value,
666 // },
667 // linux_arm: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800668 // key: value,
669 // },
Colin Crossa1ad8d12016-06-01 17:09:44 -0700670 // android {
671 // key: value,
672 // },
673 // android_arm {
674 // key: value,
675 // },
676 // android_x86 {
677 // key: value,
678 // },
Colin Cross3f40fa42015-01-30 17:27:36 -0800679 // },
Colin Crossa1ad8d12016-06-01 17:09:44 -0700680 // },
681 field = os.Field
682 prefix = "target." + os.Name
Dan Willemsenb1957a52016-06-23 23:44:54 -0700683 a.appendProperties(ctx, genProps, targetProp, field, prefix)
Colin Crossb9db4802016-06-03 01:50:47 +0000684
Colin Crossa1ad8d12016-06-01 17:09:44 -0700685 field = os.Field + "_" + t.Name
686 prefix = "target." + os.Name + "_" + t.Name
Dan Willemsenb1957a52016-06-23 23:44:54 -0700687 a.appendProperties(ctx, genProps, targetProp, field, prefix)
Colin Crossb9db4802016-06-03 01:50:47 +0000688
Colin Crossa1ad8d12016-06-01 17:09:44 -0700689 if (os.Class == Host || os.Class == HostCross) && os != Windows {
690 field := "Not_windows"
691 prefix := "target.not_windows"
Dan Willemsenb1957a52016-06-23 23:44:54 -0700692 a.appendProperties(ctx, genProps, targetProp, field, prefix)
Colin Cross3f40fa42015-01-30 17:27:36 -0800693 }
694
Colin Crossf8209412015-03-26 14:44:26 -0700695 // Handle 64-bit device properties in the form:
696 // target {
697 // android64 {
698 // key: value,
699 // },
700 // android32 {
701 // key: value,
702 // },
703 // },
704 // WARNING: this is probably not what you want to use in your blueprints file, it selects
705 // options for all targets on a device that supports 64-bit binaries, not just the targets
706 // that are being compiled for 64-bit. Its expected use case is binaries like linker and
707 // debuggerd that need to know when they are a 32-bit process running on a 64-bit device
Colin Crossa1ad8d12016-06-01 17:09:44 -0700708 if os.Class == Device {
709 if ctx.AConfig().Android64() {
Colin Cross06a931b2015-10-28 17:23:31 -0700710 field := "Android64"
711 prefix := "target.android64"
Dan Willemsenb1957a52016-06-23 23:44:54 -0700712 a.appendProperties(ctx, genProps, targetProp, field, prefix)
Colin Crossf8209412015-03-26 14:44:26 -0700713 } else {
Colin Cross06a931b2015-10-28 17:23:31 -0700714 field := "Android32"
715 prefix := "target.android32"
Dan Willemsenb1957a52016-06-23 23:44:54 -0700716 a.appendProperties(ctx, genProps, targetProp, field, prefix)
Colin Crossf8209412015-03-26 14:44:26 -0700717 }
718 }
Colin Crossbb2e2b72016-12-08 17:23:53 -0800719
720 if arch.ArchType == X86 && hasArmAbi(arch) {
721 field := "Arm_on_x86"
722 prefix := "target.arm_on_x86"
723 a.appendProperties(ctx, genProps, targetProp, field, prefix)
724 }
725 if arch.ArchType == X86_64 && hasArmAbi(arch) {
726 field := "Arm_on_x86_64"
727 prefix := "target.arm_on_x86_64"
728 a.appendProperties(ctx, genProps, targetProp, field, prefix)
729 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800730 }
731}
732
733func forEachInterface(v reflect.Value, f func(reflect.Value)) {
734 switch v.Kind() {
735 case reflect.Interface:
736 f(v)
737 case reflect.Struct:
738 for i := 0; i < v.NumField(); i++ {
739 forEachInterface(v.Field(i), f)
740 }
741 case reflect.Ptr:
742 forEachInterface(v.Elem(), f)
743 default:
744 panic(fmt.Errorf("Unsupported kind %s", v.Kind()))
745 }
746}
Colin Cross4225f652015-09-17 14:33:42 -0700747
Colin Crossa1ad8d12016-06-01 17:09:44 -0700748// Convert the arch product variables into a list of targets for each os class structs
Colin Cross9272ade2016-08-17 15:24:12 -0700749func decodeTargetProductVariables(config *config) (map[OsClass][]Target, error) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700750 variables := config.ProductVariables
Dan Willemsen490fd492015-11-24 17:53:15 -0800751
Colin Crossa1ad8d12016-06-01 17:09:44 -0700752 targets := make(map[OsClass][]Target)
753 var targetErr error
754
755 addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi *[]string) {
756 if targetErr != nil {
757 return
Dan Willemsen490fd492015-11-24 17:53:15 -0800758 }
Colin Crossa1ad8d12016-06-01 17:09:44 -0700759
760 arch, err := decodeArch(archName, archVariant, cpuVariant, abi)
761 if err != nil {
762 targetErr = err
763 return
764 }
765
766 targets[os.Class] = append(targets[os.Class],
767 Target{
768 Os: os,
769 Arch: arch,
770 })
Dan Willemsen490fd492015-11-24 17:53:15 -0800771 }
772
Colin Cross4225f652015-09-17 14:33:42 -0700773 if variables.HostArch == nil {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700774 return nil, fmt.Errorf("No host primary architecture set")
Colin Cross4225f652015-09-17 14:33:42 -0700775 }
776
Colin Crossa1ad8d12016-06-01 17:09:44 -0700777 addTarget(BuildOs, *variables.HostArch, nil, nil, nil)
Colin Cross4225f652015-09-17 14:33:42 -0700778
Colin Crosseeabb892015-11-20 13:07:51 -0800779 if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700780 addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil)
Dan Willemsen490fd492015-11-24 17:53:15 -0800781 }
782
783 if variables.CrossHost != nil && *variables.CrossHost != "" {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700784 crossHostOs := osByName(*variables.CrossHost)
785 if crossHostOs == NoOsType {
786 return nil, fmt.Errorf("Unknown cross host OS %q", *variables.CrossHost)
787 }
788
Dan Willemsen490fd492015-11-24 17:53:15 -0800789 if variables.CrossHostArch == nil || *variables.CrossHostArch == "" {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700790 return nil, fmt.Errorf("No cross-host primary architecture set")
Dan Willemsen490fd492015-11-24 17:53:15 -0800791 }
792
Colin Crossa1ad8d12016-06-01 17:09:44 -0700793 addTarget(crossHostOs, *variables.CrossHostArch, nil, nil, nil)
Dan Willemsen490fd492015-11-24 17:53:15 -0800794
795 if variables.CrossHostSecondaryArch != nil && *variables.CrossHostSecondaryArch != "" {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700796 addTarget(crossHostOs, *variables.CrossHostSecondaryArch, nil, nil, nil)
Dan Willemsen490fd492015-11-24 17:53:15 -0800797 }
798 }
799
Dan Willemsen3f32f032016-07-11 14:36:48 -0700800 if variables.DeviceArch != nil && *variables.DeviceArch != "" {
801 addTarget(Android, *variables.DeviceArch, variables.DeviceArchVariant,
802 variables.DeviceCpuVariant, variables.DeviceAbi)
Colin Cross4225f652015-09-17 14:33:42 -0700803
Dan Willemsen3f32f032016-07-11 14:36:48 -0700804 if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" {
805 addTarget(Android, *variables.DeviceSecondaryArch,
806 variables.DeviceSecondaryArchVariant, variables.DeviceSecondaryCpuVariant,
807 variables.DeviceSecondaryAbi)
Colin Cross4225f652015-09-17 14:33:42 -0700808
Dan Willemsen3f32f032016-07-11 14:36:48 -0700809 deviceArches := targets[Device]
810 if deviceArches[0].Arch.ArchType.Multilib == deviceArches[1].Arch.ArchType.Multilib {
811 deviceArches[1].Arch.Native = false
812 }
Colin Cross4225f652015-09-17 14:33:42 -0700813 }
Colin Cross4225f652015-09-17 14:33:42 -0700814 }
815
Colin Crossa1ad8d12016-06-01 17:09:44 -0700816 if targetErr != nil {
817 return nil, targetErr
818 }
819
820 return targets, nil
Colin Cross4225f652015-09-17 14:33:42 -0700821}
822
Colin Crossbb2e2b72016-12-08 17:23:53 -0800823// hasArmAbi returns true if arch has at least one arm ABI
824func hasArmAbi(arch Arch) bool {
825 for _, abi := range arch.Abi {
826 if strings.HasPrefix(abi, "arm") {
827 return true
828 }
829 }
830 return false
831}
832
Dan Albert4098deb2016-10-19 14:04:41 -0700833type archConfig struct {
834 arch string
835 archVariant string
836 cpuVariant string
837 abi []string
838}
839
840func getMegaDeviceConfig() []archConfig {
841 return []archConfig{
Dan Willemsen110a89d2016-01-14 15:17:19 -0800842 // armv5 is only used for unbundled apps
843 //{"arm", "armv5te", "", []string{"armeabi"}},
844 {"arm", "armv7-a", "generic", []string{"armeabi-v7a"}},
845 {"arm", "armv7-a-neon", "generic", []string{"armeabi-v7a"}},
Dan Willemsen322acaf2016-01-12 23:07:05 -0800846 {"arm", "armv7-a-neon", "cortex-a7", []string{"armeabi-v7a"}},
847 {"arm", "armv7-a-neon", "cortex-a8", []string{"armeabi-v7a"}},
Dan Willemsen110a89d2016-01-14 15:17:19 -0800848 {"arm", "armv7-a-neon", "cortex-a9", []string{"armeabi-v7a"}},
Dan Willemsen322acaf2016-01-12 23:07:05 -0800849 {"arm", "armv7-a-neon", "cortex-a15", []string{"armeabi-v7a"}},
850 {"arm", "armv7-a-neon", "cortex-a53", []string{"armeabi-v7a"}},
851 {"arm", "armv7-a-neon", "cortex-a53.a57", []string{"armeabi-v7a"}},
852 {"arm", "armv7-a-neon", "denver", []string{"armeabi-v7a"}},
853 {"arm", "armv7-a-neon", "krait", []string{"armeabi-v7a"}},
Dan Willemsen110a89d2016-01-14 15:17:19 -0800854 {"arm64", "armv8-a", "cortex-a53", []string{"arm64-v8a"}},
855 {"arm64", "armv8-a", "denver64", []string{"arm64-v8a"}},
Dan Willemsen468cc312016-01-13 23:25:19 -0800856 {"mips", "mips32-fp", "", []string{"mips"}},
857 {"mips", "mips32r2-fp", "", []string{"mips"}},
858 {"mips", "mips32r2-fp-xburst", "", []string{"mips"}},
Dan Willemsen65fb9812016-07-19 21:37:28 -0700859 //{"mips", "mips32r6", "", []string{"mips"}},
Dan Willemsen468cc312016-01-13 23:25:19 -0800860 // mips32r2dsp[r2]-fp fails in the assembler for divdf3.c in compiler-rt:
861 // (same errors in make and soong)
862 // Error: invalid operands `mtlo $ac0,$11'
863 // Error: invalid operands `mthi $ac0,$12'
Dan Willemsen322acaf2016-01-12 23:07:05 -0800864 //{"mips", "mips32r2dsp-fp", "", []string{"mips"}},
865 //{"mips", "mips32r2dspr2-fp", "", []string{"mips"}},
866 // mips64r2 is mismatching 64r2 and 64r6 libraries during linking to libgcc
867 //{"mips64", "mips64r2", "", []string{"mips64"}},
868 {"mips64", "mips64r6", "", []string{"mips64"}},
869 {"x86", "", "", []string{"x86"}},
870 {"x86", "atom", "", []string{"x86"}},
871 {"x86", "haswell", "", []string{"x86"}},
872 {"x86", "ivybridge", "", []string{"x86"}},
873 {"x86", "sandybridge", "", []string{"x86"}},
874 {"x86", "silvermont", "", []string{"x86"}},
Dan Willemsen8a354052016-05-10 14:30:51 -0700875 {"x86", "x86_64", "", []string{"x86"}},
Dan Willemsen322acaf2016-01-12 23:07:05 -0800876 {"x86_64", "", "", []string{"x86_64"}},
877 {"x86_64", "haswell", "", []string{"x86_64"}},
878 {"x86_64", "ivybridge", "", []string{"x86_64"}},
879 {"x86_64", "sandybridge", "", []string{"x86_64"}},
880 {"x86_64", "silvermont", "", []string{"x86_64"}},
881 }
Dan Albert4098deb2016-10-19 14:04:41 -0700882}
Dan Willemsen322acaf2016-01-12 23:07:05 -0800883
Dan Albert4098deb2016-10-19 14:04:41 -0700884func getNdkAbisConfig() []archConfig {
885 return []archConfig{
886 {"arm", "armv5te", "", []string{"armeabi"}},
887 {"arm64", "armv8-a", "", []string{"arm64-v8a"}},
888 {"mips", "mips32-fp", "", []string{"mips"}},
889 {"mips64", "mips64r6", "", []string{"mips64"}},
890 {"x86", "", "", []string{"x86"}},
891 {"x86_64", "", "", []string{"x86_64"}},
892 }
893}
894
895func decodeArchSettings(archConfigs []archConfig) ([]Target, error) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700896 var ret []Target
Dan Willemsen322acaf2016-01-12 23:07:05 -0800897
Dan Albert4098deb2016-10-19 14:04:41 -0700898 for _, config := range archConfigs {
Dan Willemsen322acaf2016-01-12 23:07:05 -0800899 arch, err := decodeArch(config.arch, &config.archVariant,
900 &config.cpuVariant, &config.abi)
901 if err != nil {
902 return nil, err
903 }
Dan Willemsen17f05262016-05-31 16:27:00 -0700904 arch.Native = false
Colin Crossa1ad8d12016-06-01 17:09:44 -0700905 ret = append(ret, Target{
906 Os: Android,
907 Arch: arch,
908 })
Dan Willemsen322acaf2016-01-12 23:07:05 -0800909 }
910
911 return ret, nil
912}
913
Colin Cross4225f652015-09-17 14:33:42 -0700914// Convert a set of strings from product variables into a single Arch struct
915func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Arch, error) {
916 stringPtr := func(p *string) string {
917 if p != nil {
918 return *p
919 }
920 return ""
921 }
922
923 slicePtr := func(p *[]string) []string {
924 if p != nil {
925 return *p
926 }
927 return nil
928 }
929
Colin Crosseeabb892015-11-20 13:07:51 -0800930 archType, ok := archTypeMap[arch]
931 if !ok {
932 return Arch{}, fmt.Errorf("unknown arch %q", arch)
933 }
Colin Cross4225f652015-09-17 14:33:42 -0700934
Colin Crosseeabb892015-11-20 13:07:51 -0800935 a := Arch{
Colin Cross4225f652015-09-17 14:33:42 -0700936 ArchType: archType,
937 ArchVariant: stringPtr(archVariant),
938 CpuVariant: stringPtr(cpuVariant),
939 Abi: slicePtr(abi),
Dan Willemsen17f05262016-05-31 16:27:00 -0700940 Native: true,
Colin Crosseeabb892015-11-20 13:07:51 -0800941 }
942
943 if a.ArchVariant == a.ArchType.Name || a.ArchVariant == "generic" {
944 a.ArchVariant = ""
945 }
946
947 if a.CpuVariant == a.ArchType.Name || a.CpuVariant == "generic" {
948 a.CpuVariant = ""
949 }
950
951 for i := 0; i < len(a.Abi); i++ {
952 if a.Abi[i] == "" {
953 a.Abi = append(a.Abi[:i], a.Abi[i+1:]...)
954 i--
955 }
956 }
957
Colin Crossc5c24ad2015-11-20 15:35:00 -0800958 if featureMap, ok := archFeatureMap[archType]; ok {
Dan Willemsenb4850992016-05-06 17:21:20 -0700959 a.ArchFeatures = featureMap[a.ArchVariant]
Colin Crossc5c24ad2015-11-20 15:35:00 -0800960 }
961
Colin Crosseeabb892015-11-20 13:07:51 -0800962 return a, nil
Colin Cross4225f652015-09-17 14:33:42 -0700963}
964
Colin Cross69617d32016-09-06 10:39:07 -0700965func filterMultilibTargets(targets []Target, multilib string) []Target {
966 var ret []Target
967 for _, t := range targets {
968 if t.Arch.ArchType.Multilib == multilib {
969 ret = append(ret, t)
970 }
971 }
972 return ret
973}
974
Colin Crossa1ad8d12016-06-01 17:09:44 -0700975// Use the module multilib setting to select one or more targets from a target list
Colin Cross8b74d172016-09-13 09:59:14 -0700976func decodeMultilib(multilib string, targets []Target, prefer32 bool) ([]Target, error) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700977 buildTargets := []Target{}
Colin Cross8b74d172016-09-13 09:59:14 -0700978 if multilib == "first" {
979 if prefer32 {
980 multilib = "prefer32"
981 } else {
982 multilib = "prefer64"
983 }
984 }
Colin Cross4225f652015-09-17 14:33:42 -0700985 switch multilib {
986 case "common":
Colin Crossa1ad8d12016-06-01 17:09:44 -0700987 buildTargets = append(buildTargets, commonTarget)
Colin Cross4225f652015-09-17 14:33:42 -0700988 case "both":
Colin Cross8b74d172016-09-13 09:59:14 -0700989 if prefer32 {
990 buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib32")...)
991 buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib64")...)
992 } else {
993 buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib64")...)
994 buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib32")...)
995 }
Colin Cross4225f652015-09-17 14:33:42 -0700996 case "32":
Colin Cross69617d32016-09-06 10:39:07 -0700997 buildTargets = filterMultilibTargets(targets, "lib32")
Colin Cross4225f652015-09-17 14:33:42 -0700998 case "64":
Colin Cross69617d32016-09-06 10:39:07 -0700999 buildTargets = filterMultilibTargets(targets, "lib64")
1000 case "prefer32":
1001 buildTargets = filterMultilibTargets(targets, "lib32")
1002 if len(buildTargets) == 0 {
1003 buildTargets = filterMultilibTargets(targets, "lib64")
Colin Cross4225f652015-09-17 14:33:42 -07001004 }
Colin Cross8b74d172016-09-13 09:59:14 -07001005 case "prefer64":
1006 buildTargets = filterMultilibTargets(targets, "lib64")
1007 if len(buildTargets) == 0 {
1008 buildTargets = filterMultilibTargets(targets, "lib32")
1009 }
Colin Cross4225f652015-09-17 14:33:42 -07001010 default:
Colin Cross69617d32016-09-06 10:39:07 -07001011 return nil, fmt.Errorf(`compile_multilib must be "both", "first", "32", "64", or "prefer32" found %q`,
Colin Cross4225f652015-09-17 14:33:42 -07001012 multilib)
Colin Cross4225f652015-09-17 14:33:42 -07001013 }
1014
Colin Crossa1ad8d12016-06-01 17:09:44 -07001015 return buildTargets, nil
Colin Cross4225f652015-09-17 14:33:42 -07001016}