blob: 184b1629e951ee84915666995e1240c1d9b6cf00 [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
Colin Cross463a90e2015-06-17 14:20:06 -070027func init() {
Colin Crosscfad1192015-11-02 16:43:11 -080028 RegisterBottomUpMutator("defaults_deps", defaultsDepsMutator)
29 RegisterTopDownMutator("defaults", defaultsMutator)
30
Colin Cross6362e272015-10-29 15:25:03 -070031 RegisterBottomUpMutator("arch", ArchMutator)
Colin Cross463a90e2015-06-17 14:20:06 -070032}
33
Colin Cross3f40fa42015-01-30 17:27:36 -080034var (
Colin Crossec193632015-07-06 17:49:43 -070035 Arm = newArch("arm", "lib32")
36 Arm64 = newArch("arm64", "lib64")
37 Mips = newArch("mips", "lib32")
38 Mips64 = newArch("mips64", "lib64")
39 X86 = newArch("x86", "lib32")
40 X86_64 = newArch("x86_64", "lib64")
Colin Cross2fe66872015-03-30 17:20:39 -070041
42 Common = ArchType{
43 Name: "common",
44 }
Colin Cross3f40fa42015-01-30 17:27:36 -080045)
46
Colin Cross4225f652015-09-17 14:33:42 -070047var archTypeMap = map[string]ArchType{
48 "arm": Arm,
49 "arm64": Arm64,
50 "mips": Mips,
Colin Cross3b336c22015-11-23 16:28:31 -080051 "mips64": Mips64,
Colin Cross4225f652015-09-17 14:33:42 -070052 "x86": X86,
53 "x86_64": X86_64,
54}
55
Colin Cross3f40fa42015-01-30 17:27:36 -080056/*
57Example blueprints file containing all variant property groups, with comment listing what type
58of variants get properties in that group:
59
60module {
61 arch: {
62 arm: {
63 // Host or device variants with arm architecture
64 },
65 arm64: {
66 // Host or device variants with arm64 architecture
67 },
68 mips: {
69 // Host or device variants with mips architecture
70 },
71 mips64: {
72 // Host or device variants with mips64 architecture
73 },
74 x86: {
75 // Host or device variants with x86 architecture
76 },
77 x86_64: {
78 // Host or device variants with x86_64 architecture
79 },
80 },
81 multilib: {
82 lib32: {
83 // Host or device variants for 32-bit architectures
84 },
85 lib64: {
86 // Host or device variants for 64-bit architectures
87 },
88 },
89 target: {
90 android: {
91 // Device variants
92 },
93 host: {
94 // Host variants
95 },
96 linux: {
97 // Linux host variants
98 },
99 darwin: {
100 // Darwin host variants
101 },
102 windows: {
103 // Windows host variants
104 },
105 not_windows: {
106 // Non-windows host variants
107 },
108 },
109}
110*/
Colin Cross7d5136f2015-05-11 13:39:40 -0700111
Colin Cross85a88972015-11-23 13:29:51 -0800112type Embed interface{}
113
Colin Cross3f40fa42015-01-30 17:27:36 -0800114type archProperties struct {
Colin Cross7d5136f2015-05-11 13:39:40 -0700115 // Properties to vary by target architecture
Colin Cross3f40fa42015-01-30 17:27:36 -0800116 Arch struct {
Colin Cross7d5136f2015-05-11 13:39:40 -0700117 // Properties for module variants being built to run on arm (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800118 Arm struct {
119 Embed `blueprint:"filter(android:\"arch_variant\")"`
120
121 // Arm arch variants
122 Armv5te interface{} `blueprint:"filter(android:\"arch_variant\")"`
123 Armv7_a interface{} `blueprint:"filter(android:\"arch_variant\")"`
124 Armv7_a_neon interface{} `blueprint:"filter(android:\"arch_variant\")"`
125
126 // Arm cpu variants
127 Cortex_a7 interface{} `blueprint:"filter(android:\"arch_variant\")"`
128 Cortex_a8 interface{} `blueprint:"filter(android:\"arch_variant\")"`
129 Cortex_a9 interface{} `blueprint:"filter(android:\"arch_variant\")"`
130 Cortex_a15 interface{} `blueprint:"filter(android:\"arch_variant\")"`
131 Cortex_a53 interface{} `blueprint:"filter(android:\"arch_variant\")"`
132 Cortex_a53_a57 interface{} `blueprint:"filter(android:\"arch_variant\")"`
133 Krait interface{} `blueprint:"filter(android:\"arch_variant\")"`
134 Denver interface{} `blueprint:"filter(android:\"arch_variant\")"`
135 }
136
Colin Cross7d5136f2015-05-11 13:39:40 -0700137 // Properties for module variants being built to run on arm64 (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800138 Arm64 struct {
139 Embed `blueprint:"filter(android:\"arch_variant\")"`
140
141 // Arm64 arch variants
142 Armv8_a interface{} `blueprint:"filter(android:\"arch_variant\")"`
143
144 // Arm64 cpu variants
145 Cortex_a53 interface{} `blueprint:"filter(android:\"arch_variant\")"`
146 Denver64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
147 }
148
Colin Cross7d5136f2015-05-11 13:39:40 -0700149 // Properties for module variants being built to run on mips (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800150 Mips struct {
151 Embed `blueprint:"filter(android:\"arch_variant\")"`
152
153 // Mips arch variants
Colin Cross023f1e82015-11-23 16:15:10 -0800154 Mips32_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
155 Mips32r2_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
156 Mips32r2_fp_xburst interface{} `blueprint:"filter(android:\"arch_variant\")"`
157 Mips32r2dsp_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
158 Mips32r2dspr2_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
159 Mips32r6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
160
161 // Mips arch features
Colin Cross85a88972015-11-23 13:29:51 -0800162 Rev6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
163 }
164
Colin Cross7d5136f2015-05-11 13:39:40 -0700165 // Properties for module variants being built to run on mips64 (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800166 Mips64 struct {
167 Embed `blueprint:"filter(android:\"arch_variant\")"`
168
169 // Mips64 arch variants
Colin Cross3b336c22015-11-23 16:28:31 -0800170 Mips64r2 interface{} `blueprint:"filter(android:\"arch_variant\")"`
171 Mips64r6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
172
173 // Mips64 arch features
Colin Cross85a88972015-11-23 13:29:51 -0800174 Rev6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
175 }
176
Colin Cross7d5136f2015-05-11 13:39:40 -0700177 // Properties for module variants being built to run on x86 (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800178 X86 struct {
179 Embed `blueprint:"filter(android:\"arch_variant\")"`
180
181 // X86 arch variants
Colin Crossb0cba6a2015-11-20 15:35:26 -0800182 Atom interface{} `blueprint:"filter(android:\"arch_variant\")"`
183 Haswell interface{} `blueprint:"filter(android:\"arch_variant\")"`
184 Ivybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
185 Sandybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
186 Silvermont interface{} `blueprint:"filter(android:\"arch_variant\")"`
Dan Willemsen8a354052016-05-10 14:30:51 -0700187 // Generic variant for X86 on X86_64
Colin Cross635c3b02016-05-18 15:37:25 -0700188 X86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross85a88972015-11-23 13:29:51 -0800189
190 // X86 arch features
Colin Crossb0cba6a2015-11-20 15:35:26 -0800191 Ssse3 interface{} `blueprint:"filter(android:\"arch_variant\")"`
192 Sse4 interface{} `blueprint:"filter(android:\"arch_variant\")"`
193 Sse4_1 interface{} `blueprint:"filter(android:\"arch_variant\")"`
194 Sse4_2 interface{} `blueprint:"filter(android:\"arch_variant\")"`
195 Aes_ni interface{} `blueprint:"filter(android:\"arch_variant\")"`
196 Avx interface{} `blueprint:"filter(android:\"arch_variant\")"`
197 Popcnt interface{} `blueprint:"filter(android:\"arch_variant\")"`
198 Movbe interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross85a88972015-11-23 13:29:51 -0800199 }
200
Colin Cross7d5136f2015-05-11 13:39:40 -0700201 // Properties for module variants being built to run on x86_64 (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800202 X86_64 struct {
203 Embed `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross6371b382015-11-23 14:53:57 -0800204
205 // X86 arch variants
206 Haswell interface{} `blueprint:"filter(android:\"arch_variant\")"`
207 Ivybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
208 Sandybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
209 Silvermont interface{} `blueprint:"filter(android:\"arch_variant\")"`
210
211 // X86 arch features
212 Ssse3 interface{} `blueprint:"filter(android:\"arch_variant\")"`
213 Sse4 interface{} `blueprint:"filter(android:\"arch_variant\")"`
214 Sse4_1 interface{} `blueprint:"filter(android:\"arch_variant\")"`
215 Sse4_2 interface{} `blueprint:"filter(android:\"arch_variant\")"`
216 Aes_ni interface{} `blueprint:"filter(android:\"arch_variant\")"`
217 Avx interface{} `blueprint:"filter(android:\"arch_variant\")"`
218 Popcnt interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross85a88972015-11-23 13:29:51 -0800219 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800220 }
Colin Crossec193632015-07-06 17:49:43 -0700221
Colin Cross7d5136f2015-05-11 13:39:40 -0700222 // Properties to vary by 32-bit or 64-bit
Colin Cross3f40fa42015-01-30 17:27:36 -0800223 Multilib struct {
Colin Cross7d5136f2015-05-11 13:39:40 -0700224 // Properties for module variants being built to run on 32-bit devices
225 Lib32 interface{} `blueprint:"filter(android:\"arch_variant\")"`
226 // Properties for module variants being built to run on 64-bit devices
227 Lib64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800228 }
Colin Cross7d5136f2015-05-11 13:39:40 -0700229 // Properties to vary by build target (host or device, os, os+archictecture)
Colin Cross3f40fa42015-01-30 17:27:36 -0800230 Target struct {
Colin Cross7d5136f2015-05-11 13:39:40 -0700231 // Properties for module variants being built to run on the host
232 Host interface{} `blueprint:"filter(android:\"arch_variant\")"`
233 // Properties for module variants being built to run on the device
234 Android interface{} `blueprint:"filter(android:\"arch_variant\")"`
235 // Properties for module variants being built to run on arm devices
236 Android_arm interface{} `blueprint:"filter(android:\"arch_variant\")"`
237 // Properties for module variants being built to run on arm64 devices
238 Android_arm64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
239 // Properties for module variants being built to run on mips devices
240 Android_mips interface{} `blueprint:"filter(android:\"arch_variant\")"`
241 // Properties for module variants being built to run on mips64 devices
242 Android_mips64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
243 // Properties for module variants being built to run on x86 devices
244 Android_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
245 // Properties for module variants being built to run on x86_64 devices
246 Android_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
247 // Properties for module variants being built to run on devices that support 64-bit
248 Android64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
249 // Properties for module variants being built to run on devices that do not support 64-bit
250 Android32 interface{} `blueprint:"filter(android:\"arch_variant\")"`
251 // Properties for module variants being built to run on linux hosts
252 Linux interface{} `blueprint:"filter(android:\"arch_variant\")"`
253 // Properties for module variants being built to run on linux x86 hosts
254 Linux_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
255 // Properties for module variants being built to run on linux x86_64 hosts
256 Linux_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
257 // Properties for module variants being built to run on darwin hosts
258 Darwin interface{} `blueprint:"filter(android:\"arch_variant\")"`
259 // Properties for module variants being built to run on darwin x86 hosts
260 Darwin_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
261 // Properties for module variants being built to run on darwin x86_64 hosts
262 Darwin_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
263 // Properties for module variants being built to run on windows hosts
264 Windows interface{} `blueprint:"filter(android:\"arch_variant\")"`
Dan Willemsen490fd492015-11-24 17:53:15 -0800265 // Properties for module variants being built to run on windows x86 hosts
266 Windows_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
Dan Willemsen07cd0512016-02-03 23:16:33 -0800267 // Properties for module variants being built to run on windows x86_64 hosts
268 Windows_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross7d5136f2015-05-11 13:39:40 -0700269 // Properties for module variants being built to run on linux or darwin hosts
270 Not_windows interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800271 }
272}
273
Colin Crossc5c24ad2015-11-20 15:35:00 -0800274var archFeatureMap = map[ArchType]map[string][]string{}
275
276func RegisterArchFeatures(arch ArchType, variant string, features ...string) {
Colin Cross85a88972015-11-23 13:29:51 -0800277 archField := proptools.FieldNameForProperty(arch.Name)
278 variantField := proptools.FieldNameForProperty(variant)
279 archStruct := reflect.ValueOf(archProperties{}.Arch).FieldByName(archField)
Colin Crossc5c24ad2015-11-20 15:35:00 -0800280 if variant != "" {
Colin Cross85a88972015-11-23 13:29:51 -0800281 if !archStruct.FieldByName(variantField).IsValid() {
Colin Crossc5c24ad2015-11-20 15:35:00 -0800282 panic(fmt.Errorf("Invalid variant %q for arch %q", variant, arch))
283 }
284 }
285 for _, feature := range features {
286 field := proptools.FieldNameForProperty(feature)
Colin Cross85a88972015-11-23 13:29:51 -0800287 if !archStruct.FieldByName(field).IsValid() {
Colin Crossc5c24ad2015-11-20 15:35:00 -0800288 panic(fmt.Errorf("Invalid feature %q for arch %q variant %q", feature, arch, variant))
289 }
290 }
291 if archFeatureMap[arch] == nil {
292 archFeatureMap[arch] = make(map[string][]string)
293 }
294 archFeatureMap[arch][variant] = features
295}
296
Colin Cross3f40fa42015-01-30 17:27:36 -0800297// An Arch indicates a single CPU architecture.
298type Arch struct {
Colin Crossc5c24ad2015-11-20 15:35:00 -0800299 ArchType ArchType
300 ArchVariant string
301 CpuVariant string
302 Abi []string
303 ArchFeatures []string
Dan Willemsen17f05262016-05-31 16:27:00 -0700304 Native bool
Colin Cross3f40fa42015-01-30 17:27:36 -0800305}
306
307func (a Arch) String() string {
Colin Crossd3ba0392015-05-07 14:11:29 -0700308 s := a.ArchType.String()
Colin Cross3f40fa42015-01-30 17:27:36 -0800309 if a.ArchVariant != "" {
310 s += "_" + a.ArchVariant
311 }
312 if a.CpuVariant != "" {
313 s += "_" + a.CpuVariant
314 }
315 return s
316}
317
318type ArchType struct {
Colin Crossec193632015-07-06 17:49:43 -0700319 Name string
320 Multilib string
Colin Cross3f40fa42015-01-30 17:27:36 -0800321}
322
Colin Crossec193632015-07-06 17:49:43 -0700323func newArch(name, multilib string) ArchType {
Colin Cross3f40fa42015-01-30 17:27:36 -0800324 return ArchType{
Colin Crossec193632015-07-06 17:49:43 -0700325 Name: name,
326 Multilib: multilib,
Colin Cross3f40fa42015-01-30 17:27:36 -0800327 }
328}
329
330func (a ArchType) String() string {
331 return a.Name
332}
333
Colin Cross54c71122016-06-01 17:09:44 -0700334var BuildOs = func() OsType {
Dan Willemsen490fd492015-11-24 17:53:15 -0800335 switch runtime.GOOS {
336 case "linux":
337 return Linux
338 case "darwin":
339 return Darwin
340 default:
341 panic(fmt.Sprintf("unsupported OS: %s", runtime.GOOS))
342 }
Colin Cross54c71122016-06-01 17:09:44 -0700343}()
344
345var (
346 osTypeList []OsType
347
348 NoOsType OsType
349 Linux = NewOsType("linux", Host)
350 Darwin = NewOsType("darwin", Host)
351 Windows = NewOsType("windows", HostCross)
352 Android = NewOsType("android", Device)
353)
354
355type OsType struct {
356 Name, Field string
357 Class OsClass
Dan Willemsen490fd492015-11-24 17:53:15 -0800358}
359
Colin Cross54c71122016-06-01 17:09:44 -0700360type OsClass int
361
362const (
363 Device OsClass = iota
364 Host
365 HostCross
366)
367
368func (os OsType) String() string {
369 return os.Name
Dan Willemsen490fd492015-11-24 17:53:15 -0800370}
371
Colin Cross54c71122016-06-01 17:09:44 -0700372func NewOsType(name string, class OsClass) OsType {
373 os := OsType{
374 Name: name,
375 Field: strings.Title(name),
376 Class: class,
Dan Willemsen490fd492015-11-24 17:53:15 -0800377 }
Colin Cross54c71122016-06-01 17:09:44 -0700378 osTypeList = append(osTypeList, os)
379 return os
380}
381
382func osByName(name string) OsType {
383 for _, os := range osTypeList {
384 if os.Name == name {
385 return os
386 }
387 }
388
389 return NoOsType
Dan Willemsen490fd492015-11-24 17:53:15 -0800390}
391
Colin Cross3f40fa42015-01-30 17:27:36 -0800392var (
Colin Cross54c71122016-06-01 17:09:44 -0700393 commonTarget = Target{
394 Os: Android,
395 Arch: Arch{
396 ArchType: Common,
397 },
Colin Cross2fe66872015-03-30 17:20:39 -0700398 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800399)
400
Colin Cross54c71122016-06-01 17:09:44 -0700401type Target struct {
402 Os OsType
403 Arch Arch
Colin Crossd3ba0392015-05-07 14:11:29 -0700404}
405
Colin Cross54c71122016-06-01 17:09:44 -0700406func (target Target) String() string {
407 return target.Os.String() + "_" + target.Arch.String()
Dan Willemsen490fd492015-11-24 17:53:15 -0800408}
409
Colin Cross635c3b02016-05-18 15:37:25 -0700410func ArchMutator(mctx BottomUpMutatorContext) {
411 var module Module
Colin Cross3f40fa42015-01-30 17:27:36 -0800412 var ok bool
Colin Cross635c3b02016-05-18 15:37:25 -0700413 if module, ok = mctx.Module().(Module); !ok {
Colin Cross3f40fa42015-01-30 17:27:36 -0800414 return
415 }
416
Colin Cross54c71122016-06-01 17:09:44 -0700417 osClasses := module.base().OsClassSupported()
Colin Cross3f40fa42015-01-30 17:27:36 -0800418
Colin Cross54c71122016-06-01 17:09:44 -0700419 if len(osClasses) == 0 {
Colin Cross5049f022015-03-18 13:28:46 -0700420 return
421 }
422
Colin Cross54c71122016-06-01 17:09:44 -0700423 var moduleTargets []Target
424
425 for _, class := range osClasses {
426 multilib := module.base().commonProperties.Compile_multilib
427 targets, err := decodeMultilib(multilib, mctx.AConfig().Targets[class])
428 if err != nil {
429 mctx.ModuleErrorf("%s", err.Error())
430 }
431 moduleTargets = append(moduleTargets, targets...)
Colin Cross3f40fa42015-01-30 17:27:36 -0800432 }
433
Colin Cross54c71122016-06-01 17:09:44 -0700434 targetNames := make([]string, len(moduleTargets))
Colin Cross3f40fa42015-01-30 17:27:36 -0800435
Colin Cross54c71122016-06-01 17:09:44 -0700436 for i, target := range moduleTargets {
437 targetNames[i] = target.String()
438 }
439
440 modules := mctx.CreateVariations(targetNames...)
Colin Cross3f40fa42015-01-30 17:27:36 -0800441 for i, m := range modules {
Colin Cross54c71122016-06-01 17:09:44 -0700442 m.(Module).base().SetTarget(moduleTargets[i])
Colin Cross635c3b02016-05-18 15:37:25 -0700443 m.(Module).base().setArchProperties(mctx)
Colin Cross3f40fa42015-01-30 17:27:36 -0800444 }
445}
446
Colin Cross635c3b02016-05-18 15:37:25 -0700447func InitArchModule(m Module,
Colin Cross3f40fa42015-01-30 17:27:36 -0800448 propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
449
450 base := m.base()
451
Colin Cross3f40fa42015-01-30 17:27:36 -0800452 base.generalProperties = append(base.generalProperties,
Colin Cross3f40fa42015-01-30 17:27:36 -0800453 propertyStructs...)
454
455 for _, properties := range base.generalProperties {
456 propertiesValue := reflect.ValueOf(properties)
457 if propertiesValue.Kind() != reflect.Ptr {
Colin Crossca860ac2016-01-04 14:34:37 -0800458 panic(fmt.Errorf("properties must be a pointer to a struct, got %T",
459 propertiesValue.Interface()))
Colin Cross3f40fa42015-01-30 17:27:36 -0800460 }
461
462 propertiesValue = propertiesValue.Elem()
463 if propertiesValue.Kind() != reflect.Struct {
Colin Crossca860ac2016-01-04 14:34:37 -0800464 panic(fmt.Errorf("properties must be a pointer to a struct, got %T",
465 propertiesValue.Interface()))
Colin Cross3f40fa42015-01-30 17:27:36 -0800466 }
467
468 archProperties := &archProperties{}
469 forEachInterface(reflect.ValueOf(archProperties), func(v reflect.Value) {
Colin Cross3ab7d882015-05-19 13:03:01 -0700470 newValue := proptools.CloneEmptyProperties(propertiesValue)
Colin Cross3f40fa42015-01-30 17:27:36 -0800471 v.Set(newValue)
472 })
473
474 base.archProperties = append(base.archProperties, archProperties)
475 }
476
477 var allProperties []interface{}
478 allProperties = append(allProperties, base.generalProperties...)
479 for _, asp := range base.archProperties {
480 allProperties = append(allProperties, asp)
481 }
482
483 return m, allProperties
484}
485
Colin Crossa716add2015-12-16 11:07:39 -0800486var variantReplacer = strings.NewReplacer("-", "_", ".", "_")
Colin Crossec193632015-07-06 17:49:43 -0700487
Colin Cross635c3b02016-05-18 15:37:25 -0700488func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
Colin Cross85a88972015-11-23 13:29:51 -0800489 dst, src interface{}, field, srcPrefix string) interface{} {
Colin Cross06a931b2015-10-28 17:23:31 -0700490
Colin Crosseeabb892015-11-20 13:07:51 -0800491 srcField := reflect.ValueOf(src).FieldByName(field)
492 if !srcField.IsValid() {
493 ctx.ModuleErrorf("field %q does not exist", srcPrefix)
Colin Cross85a88972015-11-23 13:29:51 -0800494 return nil
495 }
496
497 ret := srcField
498
499 if srcField.Kind() == reflect.Struct {
500 srcField = srcField.FieldByName("Embed")
Colin Crosseeabb892015-11-20 13:07:51 -0800501 }
502
503 src = srcField.Elem().Interface()
Colin Cross06a931b2015-10-28 17:23:31 -0700504
505 filter := func(property string,
506 dstField, srcField reflect.StructField,
507 dstValue, srcValue interface{}) (bool, error) {
508
509 srcProperty := srcPrefix + "." + property
510
511 if !proptools.HasTag(dstField, "android", "arch_variant") {
512 if ctx.ContainsProperty(srcProperty) {
513 return false, fmt.Errorf("can't be specific to a build variant")
514 } else {
515 return false, nil
516 }
517 }
518
519 return true, nil
520 }
521
Colin Cross6ee75b62016-05-05 15:57:15 -0700522 order := func(property string,
523 dstField, srcField reflect.StructField,
524 dstValue, srcValue interface{}) (proptools.Order, error) {
525 if proptools.HasTag(dstField, "android", "variant_prepend") {
526 return proptools.Prepend, nil
527 } else {
528 return proptools.Append, nil
529 }
530 }
531
532 err := proptools.ExtendProperties(dst, src, filter, order)
Colin Cross06a931b2015-10-28 17:23:31 -0700533 if err != nil {
534 if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
535 ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
536 } else {
537 panic(err)
538 }
539 }
Colin Cross85a88972015-11-23 13:29:51 -0800540
541 return ret.Interface()
Colin Cross06a931b2015-10-28 17:23:31 -0700542}
543
Colin Cross3f40fa42015-01-30 17:27:36 -0800544// Rewrite the module's properties structs to contain arch-specific values.
Colin Cross635c3b02016-05-18 15:37:25 -0700545func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
Colin Cross54c71122016-06-01 17:09:44 -0700546 arch := a.Arch()
547 os := a.Os()
Colin Crossd3ba0392015-05-07 14:11:29 -0700548
Colin Cross2fe66872015-03-30 17:20:39 -0700549 if arch.ArchType == Common {
550 return
551 }
552
Colin Cross3f40fa42015-01-30 17:27:36 -0800553 for i := range a.generalProperties {
Colin Cross06a931b2015-10-28 17:23:31 -0700554 genProps := a.generalProperties[i]
555 archProps := a.archProperties[i]
Colin Cross3f40fa42015-01-30 17:27:36 -0800556 // Handle arch-specific properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700557 // arch: {
558 // arm64: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800559 // key: value,
560 // },
561 // },
562 t := arch.ArchType
Colin Cross06a931b2015-10-28 17:23:31 -0700563
Colin Crossec193632015-07-06 17:49:43 -0700564 field := proptools.FieldNameForProperty(t.Name)
Colin Cross06a931b2015-10-28 17:23:31 -0700565 prefix := "arch." + t.Name
Colin Cross85a88972015-11-23 13:29:51 -0800566 archStruct := a.appendProperties(ctx, genProps, archProps.Arch, field, prefix)
Colin Crossec193632015-07-06 17:49:43 -0700567
568 // Handle arch-variant-specific properties in the form:
569 // arch: {
570 // variant: {
571 // key: value,
572 // },
573 // },
Colin Crossa716add2015-12-16 11:07:39 -0800574 v := variantReplacer.Replace(arch.ArchVariant)
Colin Crossec193632015-07-06 17:49:43 -0700575 if v != "" {
576 field := proptools.FieldNameForProperty(v)
Colin Cross85a88972015-11-23 13:29:51 -0800577 prefix := "arch." + t.Name + "." + v
578 a.appendProperties(ctx, genProps, archStruct, field, prefix)
Colin Crossec193632015-07-06 17:49:43 -0700579 }
580
581 // Handle cpu-variant-specific properties in the form:
582 // arch: {
583 // variant: {
584 // key: value,
585 // },
586 // },
Colin Crossa716add2015-12-16 11:07:39 -0800587 c := variantReplacer.Replace(arch.CpuVariant)
Colin Crossec193632015-07-06 17:49:43 -0700588 if c != "" {
589 field := proptools.FieldNameForProperty(c)
Colin Cross85a88972015-11-23 13:29:51 -0800590 prefix := "arch." + t.Name + "." + c
591 a.appendProperties(ctx, genProps, archStruct, field, prefix)
Colin Crossec193632015-07-06 17:49:43 -0700592 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800593
Colin Crossc5c24ad2015-11-20 15:35:00 -0800594 // Handle arch-feature-specific properties in the form:
595 // arch: {
596 // feature: {
597 // key: value,
598 // },
599 // },
600 for _, feature := range arch.ArchFeatures {
601 field := proptools.FieldNameForProperty(feature)
Colin Cross85a88972015-11-23 13:29:51 -0800602 prefix := "arch." + t.Name + "." + feature
603 a.appendProperties(ctx, genProps, archStruct, field, prefix)
Colin Crossc5c24ad2015-11-20 15:35:00 -0800604 }
605
Colin Cross3f40fa42015-01-30 17:27:36 -0800606 // Handle multilib-specific properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700607 // multilib: {
608 // lib32: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800609 // key: value,
610 // },
611 // },
Colin Cross06a931b2015-10-28 17:23:31 -0700612 field = proptools.FieldNameForProperty(t.Multilib)
613 prefix = "multilib." + t.Multilib
614 a.appendProperties(ctx, genProps, archProps.Multilib, field, prefix)
Colin Cross3f40fa42015-01-30 17:27:36 -0800615
Colin Cross54c71122016-06-01 17:09:44 -0700616 // Handle host-specific properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700617 // target: {
618 // host: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800619 // key: value,
620 // },
621 // },
Colin Cross54c71122016-06-01 17:09:44 -0700622 if os.Class == Host || os.Class == HostCross {
623 field = "Host"
624 prefix = "target.host"
625 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
626 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800627
Colin Cross54c71122016-06-01 17:09:44 -0700628 // Handle target OS properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700629 // target: {
630 // linux: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800631 // key: value,
632 // },
Colin Crossb05bff22015-04-30 15:08:04 -0700633 // not_windows: {
634 // key: value,
635 // },
636 // linux_x86: {
637 // key: value,
638 // },
639 // linux_arm: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800640 // key: value,
641 // },
Colin Cross54c71122016-06-01 17:09:44 -0700642 // android {
643 // key: value,
644 // },
645 // android_arm {
646 // key: value,
647 // },
648 // android_x86 {
649 // key: value,
650 // },
Colin Cross3f40fa42015-01-30 17:27:36 -0800651 // },
Colin Cross54c71122016-06-01 17:09:44 -0700652 // },
653 field = os.Field
654 prefix = "target." + os.Name
655 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
Dan Willemsen490fd492015-11-24 17:53:15 -0800656
Colin Cross54c71122016-06-01 17:09:44 -0700657 field = os.Field + "_" + t.Name
658 prefix = "target." + os.Name + "_" + t.Name
659 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
Dan Willemsen490fd492015-11-24 17:53:15 -0800660
Colin Cross54c71122016-06-01 17:09:44 -0700661 if (os.Class == Host || os.Class == HostCross) && os != Windows {
662 field := "Not_windows"
663 prefix := "target.not_windows"
664 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
Colin Cross3f40fa42015-01-30 17:27:36 -0800665 }
666
Colin Crossf8209412015-03-26 14:44:26 -0700667 // Handle 64-bit device properties in the form:
668 // target {
669 // android64 {
670 // key: value,
671 // },
672 // android32 {
673 // key: value,
674 // },
675 // },
676 // WARNING: this is probably not what you want to use in your blueprints file, it selects
677 // options for all targets on a device that supports 64-bit binaries, not just the targets
678 // that are being compiled for 64-bit. Its expected use case is binaries like linker and
679 // debuggerd that need to know when they are a 32-bit process running on a 64-bit device
Colin Cross54c71122016-06-01 17:09:44 -0700680 if os.Class == Device {
681 if ctx.AConfig().Android64() {
Colin Cross06a931b2015-10-28 17:23:31 -0700682 field := "Android64"
683 prefix := "target.android64"
684 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
Colin Crossf8209412015-03-26 14:44:26 -0700685 } else {
Colin Cross06a931b2015-10-28 17:23:31 -0700686 field := "Android32"
687 prefix := "target.android32"
688 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
Colin Crossf8209412015-03-26 14:44:26 -0700689 }
690 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800691 }
692}
693
694func forEachInterface(v reflect.Value, f func(reflect.Value)) {
695 switch v.Kind() {
696 case reflect.Interface:
697 f(v)
698 case reflect.Struct:
699 for i := 0; i < v.NumField(); i++ {
700 forEachInterface(v.Field(i), f)
701 }
702 case reflect.Ptr:
703 forEachInterface(v.Elem(), f)
704 default:
705 panic(fmt.Errorf("Unsupported kind %s", v.Kind()))
706 }
707}
Colin Cross4225f652015-09-17 14:33:42 -0700708
Colin Cross54c71122016-06-01 17:09:44 -0700709// Convert the arch product variables into a list of targets for each os class structs
710func decodeTargetProductVariables(config Config) (map[OsClass][]Target, error) {
711 variables := config.ProductVariables
Dan Willemsen490fd492015-11-24 17:53:15 -0800712
Colin Cross54c71122016-06-01 17:09:44 -0700713 targets := make(map[OsClass][]Target)
714 var targetErr error
715
716 addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi *[]string) {
717 if targetErr != nil {
718 return
Dan Willemsen490fd492015-11-24 17:53:15 -0800719 }
Colin Cross54c71122016-06-01 17:09:44 -0700720
721 arch, err := decodeArch(archName, archVariant, cpuVariant, abi)
722 if err != nil {
723 targetErr = err
724 return
725 }
726
727 targets[os.Class] = append(targets[os.Class],
728 Target{
729 Os: os,
730 Arch: arch,
731 })
Dan Willemsen490fd492015-11-24 17:53:15 -0800732 }
733
Colin Cross4225f652015-09-17 14:33:42 -0700734 if variables.HostArch == nil {
Colin Cross54c71122016-06-01 17:09:44 -0700735 return nil, fmt.Errorf("No host primary architecture set")
Colin Cross4225f652015-09-17 14:33:42 -0700736 }
737
Colin Cross54c71122016-06-01 17:09:44 -0700738 addTarget(BuildOs, *variables.HostArch, nil, nil, nil)
Colin Cross4225f652015-09-17 14:33:42 -0700739
Colin Crosseeabb892015-11-20 13:07:51 -0800740 if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
Colin Cross54c71122016-06-01 17:09:44 -0700741 addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil)
Dan Willemsen490fd492015-11-24 17:53:15 -0800742 }
743
744 if variables.CrossHost != nil && *variables.CrossHost != "" {
Colin Cross54c71122016-06-01 17:09:44 -0700745 crossHostOs := osByName(*variables.CrossHost)
746 if crossHostOs == NoOsType {
747 return nil, fmt.Errorf("Unknown cross host OS %q", *variables.CrossHost)
748 }
749
Dan Willemsen490fd492015-11-24 17:53:15 -0800750 if variables.CrossHostArch == nil || *variables.CrossHostArch == "" {
Colin Cross54c71122016-06-01 17:09:44 -0700751 return nil, fmt.Errorf("No cross-host primary architecture set")
Dan Willemsen490fd492015-11-24 17:53:15 -0800752 }
753
Colin Cross54c71122016-06-01 17:09:44 -0700754 addTarget(crossHostOs, *variables.CrossHostArch, nil, nil, nil)
Dan Willemsen490fd492015-11-24 17:53:15 -0800755
756 if variables.CrossHostSecondaryArch != nil && *variables.CrossHostSecondaryArch != "" {
Colin Cross54c71122016-06-01 17:09:44 -0700757 addTarget(crossHostOs, *variables.CrossHostSecondaryArch, nil, nil, nil)
Dan Willemsen490fd492015-11-24 17:53:15 -0800758 }
759 }
760
Colin Cross4225f652015-09-17 14:33:42 -0700761 if variables.DeviceArch == nil {
Colin Cross54c71122016-06-01 17:09:44 -0700762 return nil, fmt.Errorf("No device primary architecture set")
Colin Cross4225f652015-09-17 14:33:42 -0700763 }
764
Colin Cross54c71122016-06-01 17:09:44 -0700765 addTarget(Android, *variables.DeviceArch, variables.DeviceArchVariant,
Colin Cross4225f652015-09-17 14:33:42 -0700766 variables.DeviceCpuVariant, variables.DeviceAbi)
Colin Cross4225f652015-09-17 14:33:42 -0700767
Colin Crosseeabb892015-11-20 13:07:51 -0800768 if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" {
Colin Cross54c71122016-06-01 17:09:44 -0700769 addTarget(Android, *variables.DeviceSecondaryArch,
Colin Cross4225f652015-09-17 14:33:42 -0700770 variables.DeviceSecondaryArchVariant, variables.DeviceSecondaryCpuVariant,
771 variables.DeviceSecondaryAbi)
Colin Cross54c71122016-06-01 17:09:44 -0700772
773 deviceArches := targets[Device]
774 if deviceArches[0].Arch.ArchType.Multilib == deviceArches[1].Arch.ArchType.Multilib {
775 deviceArches[1].Arch.Native = false
Colin Cross4225f652015-09-17 14:33:42 -0700776 }
Colin Cross4225f652015-09-17 14:33:42 -0700777 }
778
Colin Cross54c71122016-06-01 17:09:44 -0700779 if targetErr != nil {
780 return nil, targetErr
781 }
782
783 return targets, nil
Colin Cross4225f652015-09-17 14:33:42 -0700784}
785
Colin Cross54c71122016-06-01 17:09:44 -0700786func decodeMegaDevice() ([]Target, error) {
Dan Willemsen322acaf2016-01-12 23:07:05 -0800787 archSettings := []struct {
788 arch string
789 archVariant string
790 cpuVariant string
791 abi []string
792 }{
Dan Willemsen110a89d2016-01-14 15:17:19 -0800793 // armv5 is only used for unbundled apps
794 //{"arm", "armv5te", "", []string{"armeabi"}},
795 {"arm", "armv7-a", "generic", []string{"armeabi-v7a"}},
796 {"arm", "armv7-a-neon", "generic", []string{"armeabi-v7a"}},
Dan Willemsen322acaf2016-01-12 23:07:05 -0800797 {"arm", "armv7-a-neon", "cortex-a7", []string{"armeabi-v7a"}},
798 {"arm", "armv7-a-neon", "cortex-a8", []string{"armeabi-v7a"}},
Dan Willemsen110a89d2016-01-14 15:17:19 -0800799 {"arm", "armv7-a-neon", "cortex-a9", []string{"armeabi-v7a"}},
Dan Willemsen322acaf2016-01-12 23:07:05 -0800800 {"arm", "armv7-a-neon", "cortex-a15", []string{"armeabi-v7a"}},
801 {"arm", "armv7-a-neon", "cortex-a53", []string{"armeabi-v7a"}},
802 {"arm", "armv7-a-neon", "cortex-a53.a57", []string{"armeabi-v7a"}},
803 {"arm", "armv7-a-neon", "denver", []string{"armeabi-v7a"}},
804 {"arm", "armv7-a-neon", "krait", []string{"armeabi-v7a"}},
Dan Willemsen110a89d2016-01-14 15:17:19 -0800805 {"arm64", "armv8-a", "cortex-a53", []string{"arm64-v8a"}},
806 {"arm64", "armv8-a", "denver64", []string{"arm64-v8a"}},
Dan Willemsen468cc312016-01-13 23:25:19 -0800807 {"mips", "mips32-fp", "", []string{"mips"}},
808 {"mips", "mips32r2-fp", "", []string{"mips"}},
809 {"mips", "mips32r2-fp-xburst", "", []string{"mips"}},
Dan Willemsen66187d92016-05-05 13:15:00 -0700810 {"mips", "mips32r6", "", []string{"mips"}},
Dan Willemsen468cc312016-01-13 23:25:19 -0800811 // mips32r2dsp[r2]-fp fails in the assembler for divdf3.c in compiler-rt:
812 // (same errors in make and soong)
813 // Error: invalid operands `mtlo $ac0,$11'
814 // Error: invalid operands `mthi $ac0,$12'
Dan Willemsen322acaf2016-01-12 23:07:05 -0800815 //{"mips", "mips32r2dsp-fp", "", []string{"mips"}},
816 //{"mips", "mips32r2dspr2-fp", "", []string{"mips"}},
817 // mips64r2 is mismatching 64r2 and 64r6 libraries during linking to libgcc
818 //{"mips64", "mips64r2", "", []string{"mips64"}},
819 {"mips64", "mips64r6", "", []string{"mips64"}},
820 {"x86", "", "", []string{"x86"}},
821 {"x86", "atom", "", []string{"x86"}},
822 {"x86", "haswell", "", []string{"x86"}},
823 {"x86", "ivybridge", "", []string{"x86"}},
824 {"x86", "sandybridge", "", []string{"x86"}},
825 {"x86", "silvermont", "", []string{"x86"}},
Dan Willemsen8a354052016-05-10 14:30:51 -0700826 {"x86", "x86_64", "", []string{"x86"}},
Dan Willemsen322acaf2016-01-12 23:07:05 -0800827 {"x86_64", "", "", []string{"x86_64"}},
828 {"x86_64", "haswell", "", []string{"x86_64"}},
829 {"x86_64", "ivybridge", "", []string{"x86_64"}},
830 {"x86_64", "sandybridge", "", []string{"x86_64"}},
831 {"x86_64", "silvermont", "", []string{"x86_64"}},
832 }
833
Colin Cross54c71122016-06-01 17:09:44 -0700834 var ret []Target
Dan Willemsen322acaf2016-01-12 23:07:05 -0800835
836 for _, config := range archSettings {
837 arch, err := decodeArch(config.arch, &config.archVariant,
838 &config.cpuVariant, &config.abi)
839 if err != nil {
840 return nil, err
841 }
Dan Willemsen17f05262016-05-31 16:27:00 -0700842 arch.Native = false
Colin Cross54c71122016-06-01 17:09:44 -0700843 ret = append(ret, Target{
844 Os: Android,
845 Arch: arch,
846 })
Dan Willemsen322acaf2016-01-12 23:07:05 -0800847 }
848
849 return ret, nil
850}
851
Colin Cross4225f652015-09-17 14:33:42 -0700852// Convert a set of strings from product variables into a single Arch struct
853func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Arch, error) {
854 stringPtr := func(p *string) string {
855 if p != nil {
856 return *p
857 }
858 return ""
859 }
860
861 slicePtr := func(p *[]string) []string {
862 if p != nil {
863 return *p
864 }
865 return nil
866 }
867
Colin Crosseeabb892015-11-20 13:07:51 -0800868 archType, ok := archTypeMap[arch]
869 if !ok {
870 return Arch{}, fmt.Errorf("unknown arch %q", arch)
871 }
Colin Cross4225f652015-09-17 14:33:42 -0700872
Colin Crosseeabb892015-11-20 13:07:51 -0800873 a := Arch{
Colin Cross4225f652015-09-17 14:33:42 -0700874 ArchType: archType,
875 ArchVariant: stringPtr(archVariant),
876 CpuVariant: stringPtr(cpuVariant),
877 Abi: slicePtr(abi),
Dan Willemsen17f05262016-05-31 16:27:00 -0700878 Native: true,
Colin Crosseeabb892015-11-20 13:07:51 -0800879 }
880
881 if a.ArchVariant == a.ArchType.Name || a.ArchVariant == "generic" {
882 a.ArchVariant = ""
883 }
884
885 if a.CpuVariant == a.ArchType.Name || a.CpuVariant == "generic" {
886 a.CpuVariant = ""
887 }
888
889 for i := 0; i < len(a.Abi); i++ {
890 if a.Abi[i] == "" {
891 a.Abi = append(a.Abi[:i], a.Abi[i+1:]...)
892 i--
893 }
894 }
895
Colin Crossc5c24ad2015-11-20 15:35:00 -0800896 if featureMap, ok := archFeatureMap[archType]; ok {
Dan Willemsenb4850992016-05-06 17:21:20 -0700897 a.ArchFeatures = featureMap[a.ArchVariant]
Colin Crossc5c24ad2015-11-20 15:35:00 -0800898 }
899
Colin Crosseeabb892015-11-20 13:07:51 -0800900 return a, nil
Colin Cross4225f652015-09-17 14:33:42 -0700901}
902
Colin Cross54c71122016-06-01 17:09:44 -0700903// Use the module multilib setting to select one or more targets from a target list
904func decodeMultilib(multilib string, targets []Target) ([]Target, error) {
905 buildTargets := []Target{}
Colin Cross4225f652015-09-17 14:33:42 -0700906 switch multilib {
907 case "common":
Colin Cross54c71122016-06-01 17:09:44 -0700908 buildTargets = append(buildTargets, commonTarget)
Colin Cross4225f652015-09-17 14:33:42 -0700909 case "both":
Colin Cross54c71122016-06-01 17:09:44 -0700910 buildTargets = append(buildTargets, targets...)
Colin Cross4225f652015-09-17 14:33:42 -0700911 case "first":
Colin Cross54c71122016-06-01 17:09:44 -0700912 buildTargets = append(buildTargets, targets[0])
Colin Cross4225f652015-09-17 14:33:42 -0700913 case "32":
Colin Cross54c71122016-06-01 17:09:44 -0700914 for _, t := range targets {
915 if t.Arch.ArchType.Multilib == "lib32" {
916 buildTargets = append(buildTargets, t)
Colin Cross4225f652015-09-17 14:33:42 -0700917 }
918 }
919 case "64":
Colin Cross54c71122016-06-01 17:09:44 -0700920 for _, t := range targets {
921 if t.Arch.ArchType.Multilib == "lib64" {
922 buildTargets = append(buildTargets, t)
Colin Cross4225f652015-09-17 14:33:42 -0700923 }
924 }
925 default:
926 return nil, fmt.Errorf(`compile_multilib must be "both", "first", "32", or "64", found %q`,
927 multilib)
Colin Cross4225f652015-09-17 14:33:42 -0700928 }
929
Colin Cross54c71122016-06-01 17:09:44 -0700930 return buildTargets, nil
Colin Cross4225f652015-09-17 14:33:42 -0700931}