blob: 62acb09d80b5d17b9f515d9a4c2e2a5c3d8d516b [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 (
Colin Crossec193632015-07-06 17:49:43 -070028 Arm = newArch("arm", "lib32")
29 Arm64 = newArch("arm64", "lib64")
30 Mips = newArch("mips", "lib32")
31 Mips64 = newArch("mips64", "lib64")
32 X86 = newArch("x86", "lib32")
33 X86_64 = newArch("x86_64", "lib64")
Colin Cross2fe66872015-03-30 17:20:39 -070034
35 Common = ArchType{
36 Name: "common",
37 }
Colin Cross3f40fa42015-01-30 17:27:36 -080038)
39
Colin Cross4225f652015-09-17 14:33:42 -070040var archTypeMap = map[string]ArchType{
41 "arm": Arm,
42 "arm64": Arm64,
43 "mips": Mips,
Colin Cross3b336c22015-11-23 16:28:31 -080044 "mips64": Mips64,
Colin Cross4225f652015-09-17 14:33:42 -070045 "x86": X86,
46 "x86_64": X86_64,
47}
48
Colin Cross3f40fa42015-01-30 17:27:36 -080049/*
50Example blueprints file containing all variant property groups, with comment listing what type
51of variants get properties in that group:
52
53module {
54 arch: {
55 arm: {
56 // Host or device variants with arm architecture
57 },
58 arm64: {
59 // Host or device variants with arm64 architecture
60 },
61 mips: {
62 // Host or device variants with mips architecture
63 },
64 mips64: {
65 // Host or device variants with mips64 architecture
66 },
67 x86: {
68 // Host or device variants with x86 architecture
69 },
70 x86_64: {
71 // Host or device variants with x86_64 architecture
72 },
73 },
74 multilib: {
75 lib32: {
76 // Host or device variants for 32-bit architectures
77 },
78 lib64: {
79 // Host or device variants for 64-bit architectures
80 },
81 },
82 target: {
83 android: {
84 // Device variants
85 },
86 host: {
87 // Host variants
88 },
89 linux: {
90 // Linux host variants
91 },
92 darwin: {
93 // Darwin host variants
94 },
95 windows: {
96 // Windows host variants
97 },
98 not_windows: {
99 // Non-windows host variants
100 },
101 },
102}
103*/
Colin Cross7d5136f2015-05-11 13:39:40 -0700104
Colin Cross85a88972015-11-23 13:29:51 -0800105type Embed interface{}
106
Colin Cross3f40fa42015-01-30 17:27:36 -0800107type archProperties struct {
Colin Cross7d5136f2015-05-11 13:39:40 -0700108 // Properties to vary by target architecture
Colin Cross3f40fa42015-01-30 17:27:36 -0800109 Arch struct {
Colin Cross7d5136f2015-05-11 13:39:40 -0700110 // Properties for module variants being built to run on arm (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800111 Arm struct {
112 Embed `blueprint:"filter(android:\"arch_variant\")"`
113
114 // Arm arch variants
115 Armv5te interface{} `blueprint:"filter(android:\"arch_variant\")"`
116 Armv7_a interface{} `blueprint:"filter(android:\"arch_variant\")"`
117 Armv7_a_neon interface{} `blueprint:"filter(android:\"arch_variant\")"`
118
119 // Arm cpu variants
120 Cortex_a7 interface{} `blueprint:"filter(android:\"arch_variant\")"`
121 Cortex_a8 interface{} `blueprint:"filter(android:\"arch_variant\")"`
122 Cortex_a9 interface{} `blueprint:"filter(android:\"arch_variant\")"`
123 Cortex_a15 interface{} `blueprint:"filter(android:\"arch_variant\")"`
124 Cortex_a53 interface{} `blueprint:"filter(android:\"arch_variant\")"`
125 Cortex_a53_a57 interface{} `blueprint:"filter(android:\"arch_variant\")"`
126 Krait interface{} `blueprint:"filter(android:\"arch_variant\")"`
127 Denver interface{} `blueprint:"filter(android:\"arch_variant\")"`
128 }
129
Colin Cross7d5136f2015-05-11 13:39:40 -0700130 // Properties for module variants being built to run on arm64 (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800131 Arm64 struct {
132 Embed `blueprint:"filter(android:\"arch_variant\")"`
133
134 // Arm64 arch variants
135 Armv8_a interface{} `blueprint:"filter(android:\"arch_variant\")"`
136
137 // Arm64 cpu variants
138 Cortex_a53 interface{} `blueprint:"filter(android:\"arch_variant\")"`
139 Denver64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
140 }
141
Colin Cross7d5136f2015-05-11 13:39:40 -0700142 // Properties for module variants being built to run on mips (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800143 Mips struct {
144 Embed `blueprint:"filter(android:\"arch_variant\")"`
145
146 // Mips arch variants
Colin Cross023f1e82015-11-23 16:15:10 -0800147 Mips32_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
148 Mips32r2_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
149 Mips32r2_fp_xburst interface{} `blueprint:"filter(android:\"arch_variant\")"`
150 Mips32r2dsp_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
151 Mips32r2dspr2_fp interface{} `blueprint:"filter(android:\"arch_variant\")"`
152 Mips32r6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
153
154 // Mips arch features
Colin Cross85a88972015-11-23 13:29:51 -0800155 Rev6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
156 }
157
Colin Cross7d5136f2015-05-11 13:39:40 -0700158 // Properties for module variants being built to run on mips64 (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800159 Mips64 struct {
160 Embed `blueprint:"filter(android:\"arch_variant\")"`
161
162 // Mips64 arch variants
Colin Cross3b336c22015-11-23 16:28:31 -0800163 Mips64r2 interface{} `blueprint:"filter(android:\"arch_variant\")"`
164 Mips64r6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
165
166 // Mips64 arch features
Colin Cross85a88972015-11-23 13:29:51 -0800167 Rev6 interface{} `blueprint:"filter(android:\"arch_variant\")"`
168 }
169
Colin Cross7d5136f2015-05-11 13:39:40 -0700170 // Properties for module variants being built to run on x86 (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800171 X86 struct {
172 Embed `blueprint:"filter(android:\"arch_variant\")"`
173
174 // X86 arch variants
Colin Crossb0cba6a2015-11-20 15:35:26 -0800175 Atom interface{} `blueprint:"filter(android:\"arch_variant\")"`
176 Haswell interface{} `blueprint:"filter(android:\"arch_variant\")"`
177 Ivybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
178 Sandybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
179 Silvermont interface{} `blueprint:"filter(android:\"arch_variant\")"`
Dan Willemsen8a354052016-05-10 14:30:51 -0700180 // Generic variant for X86 on X86_64
Colin Cross635c3b02016-05-18 15:37:25 -0700181 X86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross85a88972015-11-23 13:29:51 -0800182
183 // X86 arch features
Colin Crossb0cba6a2015-11-20 15:35:26 -0800184 Ssse3 interface{} `blueprint:"filter(android:\"arch_variant\")"`
185 Sse4 interface{} `blueprint:"filter(android:\"arch_variant\")"`
186 Sse4_1 interface{} `blueprint:"filter(android:\"arch_variant\")"`
187 Sse4_2 interface{} `blueprint:"filter(android:\"arch_variant\")"`
188 Aes_ni interface{} `blueprint:"filter(android:\"arch_variant\")"`
189 Avx interface{} `blueprint:"filter(android:\"arch_variant\")"`
190 Popcnt interface{} `blueprint:"filter(android:\"arch_variant\")"`
191 Movbe interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross85a88972015-11-23 13:29:51 -0800192 }
193
Colin Cross7d5136f2015-05-11 13:39:40 -0700194 // Properties for module variants being built to run on x86_64 (host or device)
Colin Cross85a88972015-11-23 13:29:51 -0800195 X86_64 struct {
196 Embed `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross6371b382015-11-23 14:53:57 -0800197
198 // X86 arch variants
199 Haswell interface{} `blueprint:"filter(android:\"arch_variant\")"`
200 Ivybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
201 Sandybridge interface{} `blueprint:"filter(android:\"arch_variant\")"`
202 Silvermont interface{} `blueprint:"filter(android:\"arch_variant\")"`
203
204 // X86 arch features
205 Ssse3 interface{} `blueprint:"filter(android:\"arch_variant\")"`
206 Sse4 interface{} `blueprint:"filter(android:\"arch_variant\")"`
207 Sse4_1 interface{} `blueprint:"filter(android:\"arch_variant\")"`
208 Sse4_2 interface{} `blueprint:"filter(android:\"arch_variant\")"`
209 Aes_ni interface{} `blueprint:"filter(android:\"arch_variant\")"`
210 Avx interface{} `blueprint:"filter(android:\"arch_variant\")"`
211 Popcnt interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross85a88972015-11-23 13:29:51 -0800212 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800213 }
Colin Crossec193632015-07-06 17:49:43 -0700214
Colin Cross7d5136f2015-05-11 13:39:40 -0700215 // Properties to vary by 32-bit or 64-bit
Colin Cross3f40fa42015-01-30 17:27:36 -0800216 Multilib struct {
Colin Cross7d5136f2015-05-11 13:39:40 -0700217 // Properties for module variants being built to run on 32-bit devices
218 Lib32 interface{} `blueprint:"filter(android:\"arch_variant\")"`
219 // Properties for module variants being built to run on 64-bit devices
220 Lib64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800221 }
Colin Cross7d5136f2015-05-11 13:39:40 -0700222 // Properties to vary by build target (host or device, os, os+archictecture)
Colin Cross3f40fa42015-01-30 17:27:36 -0800223 Target struct {
Colin Cross7d5136f2015-05-11 13:39:40 -0700224 // Properties for module variants being built to run on the host
225 Host interface{} `blueprint:"filter(android:\"arch_variant\")"`
226 // Properties for module variants being built to run on the device
227 Android interface{} `blueprint:"filter(android:\"arch_variant\")"`
228 // Properties for module variants being built to run on arm devices
229 Android_arm interface{} `blueprint:"filter(android:\"arch_variant\")"`
230 // Properties for module variants being built to run on arm64 devices
231 Android_arm64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
232 // Properties for module variants being built to run on mips devices
233 Android_mips interface{} `blueprint:"filter(android:\"arch_variant\")"`
234 // Properties for module variants being built to run on mips64 devices
235 Android_mips64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
236 // Properties for module variants being built to run on x86 devices
237 Android_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
238 // Properties for module variants being built to run on x86_64 devices
239 Android_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
240 // Properties for module variants being built to run on devices that support 64-bit
241 Android64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
242 // Properties for module variants being built to run on devices that do not support 64-bit
243 Android32 interface{} `blueprint:"filter(android:\"arch_variant\")"`
244 // Properties for module variants being built to run on linux hosts
245 Linux interface{} `blueprint:"filter(android:\"arch_variant\")"`
246 // Properties for module variants being built to run on linux x86 hosts
247 Linux_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
248 // Properties for module variants being built to run on linux x86_64 hosts
249 Linux_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
250 // Properties for module variants being built to run on darwin hosts
251 Darwin interface{} `blueprint:"filter(android:\"arch_variant\")"`
252 // Properties for module variants being built to run on darwin x86 hosts
253 Darwin_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
254 // Properties for module variants being built to run on darwin x86_64 hosts
255 Darwin_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
256 // Properties for module variants being built to run on windows hosts
257 Windows interface{} `blueprint:"filter(android:\"arch_variant\")"`
Dan Willemsen490fd492015-11-24 17:53:15 -0800258 // Properties for module variants being built to run on windows x86 hosts
259 Windows_x86 interface{} `blueprint:"filter(android:\"arch_variant\")"`
Dan Willemsen07cd0512016-02-03 23:16:33 -0800260 // Properties for module variants being built to run on windows x86_64 hosts
261 Windows_x86_64 interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross7d5136f2015-05-11 13:39:40 -0700262 // Properties for module variants being built to run on linux or darwin hosts
263 Not_windows interface{} `blueprint:"filter(android:\"arch_variant\")"`
Colin Cross3f40fa42015-01-30 17:27:36 -0800264 }
265}
266
Colin Crossc5c24ad2015-11-20 15:35:00 -0800267var archFeatureMap = map[ArchType]map[string][]string{}
268
269func RegisterArchFeatures(arch ArchType, variant string, features ...string) {
Colin Cross85a88972015-11-23 13:29:51 -0800270 archField := proptools.FieldNameForProperty(arch.Name)
271 variantField := proptools.FieldNameForProperty(variant)
272 archStruct := reflect.ValueOf(archProperties{}.Arch).FieldByName(archField)
Colin Crossc5c24ad2015-11-20 15:35:00 -0800273 if variant != "" {
Colin Cross85a88972015-11-23 13:29:51 -0800274 if !archStruct.FieldByName(variantField).IsValid() {
Colin Crossc5c24ad2015-11-20 15:35:00 -0800275 panic(fmt.Errorf("Invalid variant %q for arch %q", variant, arch))
276 }
277 }
278 for _, feature := range features {
279 field := proptools.FieldNameForProperty(feature)
Colin Cross85a88972015-11-23 13:29:51 -0800280 if !archStruct.FieldByName(field).IsValid() {
Colin Crossc5c24ad2015-11-20 15:35:00 -0800281 panic(fmt.Errorf("Invalid feature %q for arch %q variant %q", feature, arch, variant))
282 }
283 }
284 if archFeatureMap[arch] == nil {
285 archFeatureMap[arch] = make(map[string][]string)
286 }
287 archFeatureMap[arch][variant] = features
288}
289
Colin Cross3f40fa42015-01-30 17:27:36 -0800290// An Arch indicates a single CPU architecture.
291type Arch struct {
Colin Crossc5c24ad2015-11-20 15:35:00 -0800292 ArchType ArchType
293 ArchVariant string
294 CpuVariant string
295 Abi []string
296 ArchFeatures []string
Dan Willemsen17f05262016-05-31 16:27:00 -0700297 Native bool
Colin Cross3f40fa42015-01-30 17:27:36 -0800298}
299
300func (a Arch) String() string {
Colin Crossd3ba0392015-05-07 14:11:29 -0700301 s := a.ArchType.String()
Colin Cross3f40fa42015-01-30 17:27:36 -0800302 if a.ArchVariant != "" {
303 s += "_" + a.ArchVariant
304 }
305 if a.CpuVariant != "" {
306 s += "_" + a.CpuVariant
307 }
308 return s
309}
310
311type ArchType struct {
Colin Crossec193632015-07-06 17:49:43 -0700312 Name string
313 Multilib string
Colin Cross3f40fa42015-01-30 17:27:36 -0800314}
315
Colin Crossec193632015-07-06 17:49:43 -0700316func newArch(name, multilib string) ArchType {
Colin Cross3f40fa42015-01-30 17:27:36 -0800317 return ArchType{
Colin Crossec193632015-07-06 17:49:43 -0700318 Name: name,
319 Multilib: multilib,
Colin Cross3f40fa42015-01-30 17:27:36 -0800320 }
321}
322
323func (a ArchType) String() string {
324 return a.Name
325}
326
Colin Crossa1ad8d12016-06-01 17:09:44 -0700327var BuildOs = func() OsType {
Dan Willemsen490fd492015-11-24 17:53:15 -0800328 switch runtime.GOOS {
329 case "linux":
330 return Linux
331 case "darwin":
332 return Darwin
333 default:
334 panic(fmt.Sprintf("unsupported OS: %s", runtime.GOOS))
335 }
Colin Crossa1ad8d12016-06-01 17:09:44 -0700336}()
337
338var (
339 osTypeList []OsType
340
341 NoOsType OsType
342 Linux = NewOsType("linux", Host)
343 Darwin = NewOsType("darwin", Host)
344 Windows = NewOsType("windows", HostCross)
345 Android = NewOsType("android", Device)
346)
347
348type OsType struct {
349 Name, Field string
350 Class OsClass
Dan Willemsen490fd492015-11-24 17:53:15 -0800351}
352
Colin Crossa1ad8d12016-06-01 17:09:44 -0700353type OsClass int
354
355const (
356 Device OsClass = iota
357 Host
358 HostCross
359)
360
361func (os OsType) String() string {
362 return os.Name
Colin Cross54c71122016-06-01 17:09:44 -0700363}
364
Colin Crossa1ad8d12016-06-01 17:09:44 -0700365func NewOsType(name string, class OsClass) OsType {
366 os := OsType{
367 Name: name,
368 Field: strings.Title(name),
369 Class: class,
Colin Cross54c71122016-06-01 17:09:44 -0700370 }
Colin Crossa1ad8d12016-06-01 17:09:44 -0700371 osTypeList = append(osTypeList, os)
372 return os
373}
374
375func osByName(name string) OsType {
376 for _, os := range osTypeList {
377 if os.Name == name {
378 return os
379 }
380 }
381
382 return NoOsType
Dan Willemsen490fd492015-11-24 17:53:15 -0800383}
384
Colin Cross3f40fa42015-01-30 17:27:36 -0800385var (
Colin Crossa1ad8d12016-06-01 17:09:44 -0700386 commonTarget = Target{
387 Os: Android,
388 Arch: Arch{
389 ArchType: Common,
390 },
Colin Cross2fe66872015-03-30 17:20:39 -0700391 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800392)
393
Colin Crossa1ad8d12016-06-01 17:09:44 -0700394type Target struct {
395 Os OsType
396 Arch Arch
Colin Crossd3ba0392015-05-07 14:11:29 -0700397}
398
Colin Crossa1ad8d12016-06-01 17:09:44 -0700399func (target Target) String() string {
400 return target.Os.String() + "_" + target.Arch.String()
Dan Willemsen490fd492015-11-24 17:53:15 -0800401}
402
Colin Cross635c3b02016-05-18 15:37:25 -0700403func ArchMutator(mctx BottomUpMutatorContext) {
404 var module Module
Colin Cross3f40fa42015-01-30 17:27:36 -0800405 var ok bool
Colin Cross635c3b02016-05-18 15:37:25 -0700406 if module, ok = mctx.Module().(Module); !ok {
Colin Cross3f40fa42015-01-30 17:27:36 -0800407 return
408 }
409
Colin Crossa1ad8d12016-06-01 17:09:44 -0700410 osClasses := module.base().OsClassSupported()
Colin Cross3f40fa42015-01-30 17:27:36 -0800411
Colin Crossa1ad8d12016-06-01 17:09:44 -0700412 if len(osClasses) == 0 {
Colin Crossb9db4802016-06-03 01:50:47 +0000413 return
414 }
415
Colin Crossa1ad8d12016-06-01 17:09:44 -0700416 var moduleTargets []Target
417
418 for _, class := range osClasses {
419 targets := mctx.AConfig().Targets[class]
420 if len(targets) == 0 {
421 continue
422 }
423 multilib := module.base().commonProperties.Compile_multilib
424 targets, err := decodeMultilib(multilib, targets)
425 if err != nil {
426 mctx.ModuleErrorf("%s", err.Error())
427 }
428 moduleTargets = append(moduleTargets, targets...)
Colin Crossb9db4802016-06-03 01:50:47 +0000429 }
430
Dan Willemsen3f32f032016-07-11 14:36:48 -0700431 if len(moduleTargets) == 0 {
432 module.base().commonProperties.Enabled = boolPtr(false)
433 return
434 }
435
Colin Crossa1ad8d12016-06-01 17:09:44 -0700436 targetNames := make([]string, len(moduleTargets))
Colin Crossb9db4802016-06-03 01:50:47 +0000437
Colin Crossa1ad8d12016-06-01 17:09:44 -0700438 for i, target := range moduleTargets {
439 targetNames[i] = target.String()
440 }
441
442 modules := mctx.CreateVariations(targetNames...)
Colin Cross3f40fa42015-01-30 17:27:36 -0800443 for i, m := range modules {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700444 m.(Module).base().SetTarget(moduleTargets[i])
Colin Cross635c3b02016-05-18 15:37:25 -0700445 m.(Module).base().setArchProperties(mctx)
Colin Cross3f40fa42015-01-30 17:27:36 -0800446 }
447}
448
Colin Cross635c3b02016-05-18 15:37:25 -0700449func InitArchModule(m Module,
Colin Cross3f40fa42015-01-30 17:27:36 -0800450 propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
451
452 base := m.base()
453
Colin Cross3f40fa42015-01-30 17:27:36 -0800454 base.generalProperties = append(base.generalProperties,
Colin Cross3f40fa42015-01-30 17:27:36 -0800455 propertyStructs...)
456
457 for _, properties := range base.generalProperties {
458 propertiesValue := reflect.ValueOf(properties)
Colin Cross62496a02016-08-08 15:49:17 -0700459 t := propertiesValue.Type()
Colin Cross3f40fa42015-01-30 17:27:36 -0800460 if propertiesValue.Kind() != reflect.Ptr {
Colin Crossca860ac2016-01-04 14:34:37 -0800461 panic(fmt.Errorf("properties must be a pointer to a struct, got %T",
462 propertiesValue.Interface()))
Colin Cross3f40fa42015-01-30 17:27:36 -0800463 }
464
465 propertiesValue = propertiesValue.Elem()
466 if propertiesValue.Kind() != reflect.Struct {
Colin Crossca860ac2016-01-04 14:34:37 -0800467 panic(fmt.Errorf("properties must be a pointer to a struct, got %T",
468 propertiesValue.Interface()))
Colin Cross3f40fa42015-01-30 17:27:36 -0800469 }
470
471 archProperties := &archProperties{}
472 forEachInterface(reflect.ValueOf(archProperties), func(v reflect.Value) {
Colin Cross62496a02016-08-08 15:49:17 -0700473 newValue := reflect.Zero(t)
Colin Cross3f40fa42015-01-30 17:27:36 -0800474 v.Set(newValue)
475 })
476
477 base.archProperties = append(base.archProperties, archProperties)
478 }
479
480 var allProperties []interface{}
481 allProperties = append(allProperties, base.generalProperties...)
482 for _, asp := range base.archProperties {
483 allProperties = append(allProperties, asp)
484 }
485
Colin Crossa120ec12016-08-19 16:07:38 -0700486 base.customizableProperties = allProperties
487
Colin Cross3f40fa42015-01-30 17:27:36 -0800488 return m, allProperties
489}
490
Colin Crossa716add2015-12-16 11:07:39 -0800491var variantReplacer = strings.NewReplacer("-", "_", ".", "_")
Colin Crossec193632015-07-06 17:49:43 -0700492
Colin Cross635c3b02016-05-18 15:37:25 -0700493func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
Colin Cross85a88972015-11-23 13:29:51 -0800494 dst, src interface{}, field, srcPrefix string) interface{} {
Colin Cross06a931b2015-10-28 17:23:31 -0700495
Colin Crosseeabb892015-11-20 13:07:51 -0800496 srcField := reflect.ValueOf(src).FieldByName(field)
497 if !srcField.IsValid() {
498 ctx.ModuleErrorf("field %q does not exist", srcPrefix)
Colin Cross85a88972015-11-23 13:29:51 -0800499 return nil
500 }
501
502 ret := srcField
503
504 if srcField.Kind() == reflect.Struct {
505 srcField = srcField.FieldByName("Embed")
Colin Crosseeabb892015-11-20 13:07:51 -0800506 }
507
508 src = srcField.Elem().Interface()
Colin Cross06a931b2015-10-28 17:23:31 -0700509
510 filter := func(property string,
511 dstField, srcField reflect.StructField,
512 dstValue, srcValue interface{}) (bool, error) {
513
514 srcProperty := srcPrefix + "." + property
515
516 if !proptools.HasTag(dstField, "android", "arch_variant") {
517 if ctx.ContainsProperty(srcProperty) {
518 return false, fmt.Errorf("can't be specific to a build variant")
519 } else {
520 return false, nil
521 }
522 }
523
524 return true, nil
525 }
526
Colin Cross6ee75b62016-05-05 15:57:15 -0700527 order := func(property string,
528 dstField, srcField reflect.StructField,
529 dstValue, srcValue interface{}) (proptools.Order, error) {
530 if proptools.HasTag(dstField, "android", "variant_prepend") {
531 return proptools.Prepend, nil
532 } else {
533 return proptools.Append, nil
534 }
535 }
536
537 err := proptools.ExtendProperties(dst, src, filter, order)
Colin Cross06a931b2015-10-28 17:23:31 -0700538 if err != nil {
539 if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
540 ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
541 } else {
542 panic(err)
543 }
544 }
Colin Cross85a88972015-11-23 13:29:51 -0800545
546 return ret.Interface()
Colin Cross06a931b2015-10-28 17:23:31 -0700547}
548
Colin Cross3f40fa42015-01-30 17:27:36 -0800549// Rewrite the module's properties structs to contain arch-specific values.
Colin Cross635c3b02016-05-18 15:37:25 -0700550func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700551 arch := a.Arch()
552 os := a.Os()
Colin Crossd3ba0392015-05-07 14:11:29 -0700553
Colin Cross2fe66872015-03-30 17:20:39 -0700554 if arch.ArchType == Common {
555 return
556 }
557
Colin Cross3f40fa42015-01-30 17:27:36 -0800558 for i := range a.generalProperties {
Colin Cross06a931b2015-10-28 17:23:31 -0700559 genProps := a.generalProperties[i]
560 archProps := a.archProperties[i]
Colin Cross3f40fa42015-01-30 17:27:36 -0800561 // Handle arch-specific properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700562 // arch: {
563 // arm64: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800564 // key: value,
565 // },
566 // },
567 t := arch.ArchType
Colin Cross06a931b2015-10-28 17:23:31 -0700568
Colin Crossec193632015-07-06 17:49:43 -0700569 field := proptools.FieldNameForProperty(t.Name)
Colin Cross06a931b2015-10-28 17:23:31 -0700570 prefix := "arch." + t.Name
Colin Cross85a88972015-11-23 13:29:51 -0800571 archStruct := a.appendProperties(ctx, genProps, archProps.Arch, field, prefix)
Colin Crossec193632015-07-06 17:49:43 -0700572
573 // Handle arch-variant-specific properties in the form:
574 // arch: {
575 // variant: {
576 // key: value,
577 // },
578 // },
Colin Crossa716add2015-12-16 11:07:39 -0800579 v := variantReplacer.Replace(arch.ArchVariant)
Colin Crossec193632015-07-06 17:49:43 -0700580 if v != "" {
581 field := proptools.FieldNameForProperty(v)
Colin Cross85a88972015-11-23 13:29:51 -0800582 prefix := "arch." + t.Name + "." + v
583 a.appendProperties(ctx, genProps, archStruct, field, prefix)
Colin Crossec193632015-07-06 17:49:43 -0700584 }
585
586 // Handle cpu-variant-specific properties in the form:
587 // arch: {
588 // variant: {
589 // key: value,
590 // },
591 // },
Colin Crossa716add2015-12-16 11:07:39 -0800592 c := variantReplacer.Replace(arch.CpuVariant)
Colin Crossec193632015-07-06 17:49:43 -0700593 if c != "" {
594 field := proptools.FieldNameForProperty(c)
Colin Cross85a88972015-11-23 13:29:51 -0800595 prefix := "arch." + t.Name + "." + c
596 a.appendProperties(ctx, genProps, archStruct, field, prefix)
Colin Crossec193632015-07-06 17:49:43 -0700597 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800598
Colin Crossc5c24ad2015-11-20 15:35:00 -0800599 // Handle arch-feature-specific properties in the form:
600 // arch: {
601 // feature: {
602 // key: value,
603 // },
604 // },
605 for _, feature := range arch.ArchFeatures {
606 field := proptools.FieldNameForProperty(feature)
Colin Cross85a88972015-11-23 13:29:51 -0800607 prefix := "arch." + t.Name + "." + feature
608 a.appendProperties(ctx, genProps, archStruct, field, prefix)
Colin Crossc5c24ad2015-11-20 15:35:00 -0800609 }
610
Colin Cross3f40fa42015-01-30 17:27:36 -0800611 // Handle multilib-specific properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700612 // multilib: {
613 // lib32: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800614 // key: value,
615 // },
616 // },
Colin Cross06a931b2015-10-28 17:23:31 -0700617 field = proptools.FieldNameForProperty(t.Multilib)
618 prefix = "multilib." + t.Multilib
619 a.appendProperties(ctx, genProps, archProps.Multilib, field, prefix)
Colin Cross3f40fa42015-01-30 17:27:36 -0800620
Colin Crossa1ad8d12016-06-01 17:09:44 -0700621 // Handle host-specific properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700622 // target: {
623 // host: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800624 // key: value,
625 // },
626 // },
Colin Crossa1ad8d12016-06-01 17:09:44 -0700627 if os.Class == Host || os.Class == HostCross {
628 field = "Host"
629 prefix = "target.host"
630 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
631 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800632
Colin Crossa1ad8d12016-06-01 17:09:44 -0700633 // Handle target OS properties in the form:
Colin Crossb05bff22015-04-30 15:08:04 -0700634 // target: {
635 // linux: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800636 // key: value,
637 // },
Colin Crossb05bff22015-04-30 15:08:04 -0700638 // not_windows: {
639 // key: value,
640 // },
641 // linux_x86: {
642 // key: value,
643 // },
644 // linux_arm: {
Colin Cross3f40fa42015-01-30 17:27:36 -0800645 // key: value,
646 // },
Colin Crossa1ad8d12016-06-01 17:09:44 -0700647 // android {
648 // key: value,
649 // },
650 // android_arm {
651 // key: value,
652 // },
653 // android_x86 {
654 // key: value,
655 // },
Colin Cross3f40fa42015-01-30 17:27:36 -0800656 // },
Colin Crossa1ad8d12016-06-01 17:09:44 -0700657 // },
658 field = os.Field
659 prefix = "target." + os.Name
660 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
Colin Crossb9db4802016-06-03 01:50:47 +0000661
Colin Crossa1ad8d12016-06-01 17:09:44 -0700662 field = os.Field + "_" + t.Name
663 prefix = "target." + os.Name + "_" + t.Name
664 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
Colin Crossb9db4802016-06-03 01:50:47 +0000665
Colin Crossa1ad8d12016-06-01 17:09:44 -0700666 if (os.Class == Host || os.Class == HostCross) && os != Windows {
667 field := "Not_windows"
668 prefix := "target.not_windows"
669 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
Colin Cross3f40fa42015-01-30 17:27:36 -0800670 }
671
Colin Crossf8209412015-03-26 14:44:26 -0700672 // Handle 64-bit device properties in the form:
673 // target {
674 // android64 {
675 // key: value,
676 // },
677 // android32 {
678 // key: value,
679 // },
680 // },
681 // WARNING: this is probably not what you want to use in your blueprints file, it selects
682 // options for all targets on a device that supports 64-bit binaries, not just the targets
683 // that are being compiled for 64-bit. Its expected use case is binaries like linker and
684 // 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 -0700685 if os.Class == Device {
686 if ctx.AConfig().Android64() {
Colin Cross06a931b2015-10-28 17:23:31 -0700687 field := "Android64"
688 prefix := "target.android64"
689 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
Colin Crossf8209412015-03-26 14:44:26 -0700690 } else {
Colin Cross06a931b2015-10-28 17:23:31 -0700691 field := "Android32"
692 prefix := "target.android32"
693 a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
Colin Crossf8209412015-03-26 14:44:26 -0700694 }
695 }
Colin Cross3f40fa42015-01-30 17:27:36 -0800696 }
697}
698
699func forEachInterface(v reflect.Value, f func(reflect.Value)) {
700 switch v.Kind() {
701 case reflect.Interface:
702 f(v)
703 case reflect.Struct:
704 for i := 0; i < v.NumField(); i++ {
705 forEachInterface(v.Field(i), f)
706 }
707 case reflect.Ptr:
708 forEachInterface(v.Elem(), f)
709 default:
710 panic(fmt.Errorf("Unsupported kind %s", v.Kind()))
711 }
712}
Colin Cross4225f652015-09-17 14:33:42 -0700713
Colin Crossa1ad8d12016-06-01 17:09:44 -0700714// Convert the arch product variables into a list of targets for each os class structs
Colin Cross9272ade2016-08-17 15:24:12 -0700715func decodeTargetProductVariables(config *config) (map[OsClass][]Target, error) {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700716 variables := config.ProductVariables
Dan Willemsen490fd492015-11-24 17:53:15 -0800717
Colin Crossa1ad8d12016-06-01 17:09:44 -0700718 targets := make(map[OsClass][]Target)
719 var targetErr error
720
721 addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi *[]string) {
722 if targetErr != nil {
723 return
Dan Willemsen490fd492015-11-24 17:53:15 -0800724 }
Colin Crossa1ad8d12016-06-01 17:09:44 -0700725
726 arch, err := decodeArch(archName, archVariant, cpuVariant, abi)
727 if err != nil {
728 targetErr = err
729 return
730 }
731
732 targets[os.Class] = append(targets[os.Class],
733 Target{
734 Os: os,
735 Arch: arch,
736 })
Dan Willemsen490fd492015-11-24 17:53:15 -0800737 }
738
Colin Cross4225f652015-09-17 14:33:42 -0700739 if variables.HostArch == nil {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700740 return nil, fmt.Errorf("No host primary architecture set")
Colin Cross4225f652015-09-17 14:33:42 -0700741 }
742
Colin Crossa1ad8d12016-06-01 17:09:44 -0700743 addTarget(BuildOs, *variables.HostArch, nil, nil, nil)
Colin Cross4225f652015-09-17 14:33:42 -0700744
Colin Crosseeabb892015-11-20 13:07:51 -0800745 if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700746 addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil)
Dan Willemsen490fd492015-11-24 17:53:15 -0800747 }
748
749 if variables.CrossHost != nil && *variables.CrossHost != "" {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700750 crossHostOs := osByName(*variables.CrossHost)
751 if crossHostOs == NoOsType {
752 return nil, fmt.Errorf("Unknown cross host OS %q", *variables.CrossHost)
753 }
754
Dan Willemsen490fd492015-11-24 17:53:15 -0800755 if variables.CrossHostArch == nil || *variables.CrossHostArch == "" {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700756 return nil, fmt.Errorf("No cross-host primary architecture set")
Dan Willemsen490fd492015-11-24 17:53:15 -0800757 }
758
Colin Crossa1ad8d12016-06-01 17:09:44 -0700759 addTarget(crossHostOs, *variables.CrossHostArch, nil, nil, nil)
Dan Willemsen490fd492015-11-24 17:53:15 -0800760
761 if variables.CrossHostSecondaryArch != nil && *variables.CrossHostSecondaryArch != "" {
Colin Crossa1ad8d12016-06-01 17:09:44 -0700762 addTarget(crossHostOs, *variables.CrossHostSecondaryArch, nil, nil, nil)
Dan Willemsen490fd492015-11-24 17:53:15 -0800763 }
764 }
765
Dan Willemsen3f32f032016-07-11 14:36:48 -0700766 if variables.DeviceArch != nil && *variables.DeviceArch != "" {
767 addTarget(Android, *variables.DeviceArch, variables.DeviceArchVariant,
768 variables.DeviceCpuVariant, variables.DeviceAbi)
Colin Cross4225f652015-09-17 14:33:42 -0700769
Dan Willemsen3f32f032016-07-11 14:36:48 -0700770 if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" {
771 addTarget(Android, *variables.DeviceSecondaryArch,
772 variables.DeviceSecondaryArchVariant, variables.DeviceSecondaryCpuVariant,
773 variables.DeviceSecondaryAbi)
Colin Cross4225f652015-09-17 14:33:42 -0700774
Dan Willemsen3f32f032016-07-11 14:36:48 -0700775 deviceArches := targets[Device]
776 if deviceArches[0].Arch.ArchType.Multilib == deviceArches[1].Arch.ArchType.Multilib {
777 deviceArches[1].Arch.Native = false
778 }
Colin Cross4225f652015-09-17 14:33:42 -0700779 }
Colin Cross4225f652015-09-17 14:33:42 -0700780 }
781
Colin Crossa1ad8d12016-06-01 17:09:44 -0700782 if targetErr != nil {
783 return nil, targetErr
784 }
785
786 return targets, nil
Colin Cross4225f652015-09-17 14:33:42 -0700787}
788
Colin Crossa1ad8d12016-06-01 17:09:44 -0700789func decodeMegaDevice() ([]Target, error) {
Dan Willemsen322acaf2016-01-12 23:07:05 -0800790 archSettings := []struct {
791 arch string
792 archVariant string
793 cpuVariant string
794 abi []string
795 }{
Dan Willemsen110a89d2016-01-14 15:17:19 -0800796 // armv5 is only used for unbundled apps
797 //{"arm", "armv5te", "", []string{"armeabi"}},
798 {"arm", "armv7-a", "generic", []string{"armeabi-v7a"}},
799 {"arm", "armv7-a-neon", "generic", []string{"armeabi-v7a"}},
Dan Willemsen322acaf2016-01-12 23:07:05 -0800800 {"arm", "armv7-a-neon", "cortex-a7", []string{"armeabi-v7a"}},
801 {"arm", "armv7-a-neon", "cortex-a8", []string{"armeabi-v7a"}},
Dan Willemsen110a89d2016-01-14 15:17:19 -0800802 {"arm", "armv7-a-neon", "cortex-a9", []string{"armeabi-v7a"}},
Dan Willemsen322acaf2016-01-12 23:07:05 -0800803 {"arm", "armv7-a-neon", "cortex-a15", []string{"armeabi-v7a"}},
804 {"arm", "armv7-a-neon", "cortex-a53", []string{"armeabi-v7a"}},
805 {"arm", "armv7-a-neon", "cortex-a53.a57", []string{"armeabi-v7a"}},
806 {"arm", "armv7-a-neon", "denver", []string{"armeabi-v7a"}},
807 {"arm", "armv7-a-neon", "krait", []string{"armeabi-v7a"}},
Dan Willemsen110a89d2016-01-14 15:17:19 -0800808 {"arm64", "armv8-a", "cortex-a53", []string{"arm64-v8a"}},
809 {"arm64", "armv8-a", "denver64", []string{"arm64-v8a"}},
Dan Willemsen468cc312016-01-13 23:25:19 -0800810 {"mips", "mips32-fp", "", []string{"mips"}},
811 {"mips", "mips32r2-fp", "", []string{"mips"}},
812 {"mips", "mips32r2-fp-xburst", "", []string{"mips"}},
Dan Willemsen65fb9812016-07-19 21:37:28 -0700813 //{"mips", "mips32r6", "", []string{"mips"}},
Dan Willemsen468cc312016-01-13 23:25:19 -0800814 // mips32r2dsp[r2]-fp fails in the assembler for divdf3.c in compiler-rt:
815 // (same errors in make and soong)
816 // Error: invalid operands `mtlo $ac0,$11'
817 // Error: invalid operands `mthi $ac0,$12'
Dan Willemsen322acaf2016-01-12 23:07:05 -0800818 //{"mips", "mips32r2dsp-fp", "", []string{"mips"}},
819 //{"mips", "mips32r2dspr2-fp", "", []string{"mips"}},
820 // mips64r2 is mismatching 64r2 and 64r6 libraries during linking to libgcc
821 //{"mips64", "mips64r2", "", []string{"mips64"}},
822 {"mips64", "mips64r6", "", []string{"mips64"}},
823 {"x86", "", "", []string{"x86"}},
824 {"x86", "atom", "", []string{"x86"}},
825 {"x86", "haswell", "", []string{"x86"}},
826 {"x86", "ivybridge", "", []string{"x86"}},
827 {"x86", "sandybridge", "", []string{"x86"}},
828 {"x86", "silvermont", "", []string{"x86"}},
Dan Willemsen8a354052016-05-10 14:30:51 -0700829 {"x86", "x86_64", "", []string{"x86"}},
Dan Willemsen322acaf2016-01-12 23:07:05 -0800830 {"x86_64", "", "", []string{"x86_64"}},
831 {"x86_64", "haswell", "", []string{"x86_64"}},
832 {"x86_64", "ivybridge", "", []string{"x86_64"}},
833 {"x86_64", "sandybridge", "", []string{"x86_64"}},
834 {"x86_64", "silvermont", "", []string{"x86_64"}},
835 }
836
Colin Crossa1ad8d12016-06-01 17:09:44 -0700837 var ret []Target
Dan Willemsen322acaf2016-01-12 23:07:05 -0800838
839 for _, config := range archSettings {
840 arch, err := decodeArch(config.arch, &config.archVariant,
841 &config.cpuVariant, &config.abi)
842 if err != nil {
843 return nil, err
844 }
Dan Willemsen17f05262016-05-31 16:27:00 -0700845 arch.Native = false
Colin Crossa1ad8d12016-06-01 17:09:44 -0700846 ret = append(ret, Target{
847 Os: Android,
848 Arch: arch,
849 })
Dan Willemsen322acaf2016-01-12 23:07:05 -0800850 }
851
852 return ret, nil
853}
854
Colin Cross4225f652015-09-17 14:33:42 -0700855// Convert a set of strings from product variables into a single Arch struct
856func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Arch, error) {
857 stringPtr := func(p *string) string {
858 if p != nil {
859 return *p
860 }
861 return ""
862 }
863
864 slicePtr := func(p *[]string) []string {
865 if p != nil {
866 return *p
867 }
868 return nil
869 }
870
Colin Crosseeabb892015-11-20 13:07:51 -0800871 archType, ok := archTypeMap[arch]
872 if !ok {
873 return Arch{}, fmt.Errorf("unknown arch %q", arch)
874 }
Colin Cross4225f652015-09-17 14:33:42 -0700875
Colin Crosseeabb892015-11-20 13:07:51 -0800876 a := Arch{
Colin Cross4225f652015-09-17 14:33:42 -0700877 ArchType: archType,
878 ArchVariant: stringPtr(archVariant),
879 CpuVariant: stringPtr(cpuVariant),
880 Abi: slicePtr(abi),
Dan Willemsen17f05262016-05-31 16:27:00 -0700881 Native: true,
Colin Crosseeabb892015-11-20 13:07:51 -0800882 }
883
884 if a.ArchVariant == a.ArchType.Name || a.ArchVariant == "generic" {
885 a.ArchVariant = ""
886 }
887
888 if a.CpuVariant == a.ArchType.Name || a.CpuVariant == "generic" {
889 a.CpuVariant = ""
890 }
891
892 for i := 0; i < len(a.Abi); i++ {
893 if a.Abi[i] == "" {
894 a.Abi = append(a.Abi[:i], a.Abi[i+1:]...)
895 i--
896 }
897 }
898
Colin Crossc5c24ad2015-11-20 15:35:00 -0800899 if featureMap, ok := archFeatureMap[archType]; ok {
Dan Willemsenb4850992016-05-06 17:21:20 -0700900 a.ArchFeatures = featureMap[a.ArchVariant]
Colin Crossc5c24ad2015-11-20 15:35:00 -0800901 }
902
Colin Crosseeabb892015-11-20 13:07:51 -0800903 return a, nil
Colin Cross4225f652015-09-17 14:33:42 -0700904}
905
Colin Crossa1ad8d12016-06-01 17:09:44 -0700906// Use the module multilib setting to select one or more targets from a target list
907func decodeMultilib(multilib string, targets []Target) ([]Target, error) {
908 buildTargets := []Target{}
Colin Cross4225f652015-09-17 14:33:42 -0700909 switch multilib {
910 case "common":
Colin Crossa1ad8d12016-06-01 17:09:44 -0700911 buildTargets = append(buildTargets, commonTarget)
Colin Cross4225f652015-09-17 14:33:42 -0700912 case "both":
Colin Crossa1ad8d12016-06-01 17:09:44 -0700913 buildTargets = append(buildTargets, targets...)
Colin Cross4225f652015-09-17 14:33:42 -0700914 case "first":
Colin Crossa1ad8d12016-06-01 17:09:44 -0700915 buildTargets = append(buildTargets, targets[0])
Colin Cross4225f652015-09-17 14:33:42 -0700916 case "32":
Colin Crossa1ad8d12016-06-01 17:09:44 -0700917 for _, t := range targets {
918 if t.Arch.ArchType.Multilib == "lib32" {
919 buildTargets = append(buildTargets, t)
Colin Cross4225f652015-09-17 14:33:42 -0700920 }
921 }
922 case "64":
Colin Crossa1ad8d12016-06-01 17:09:44 -0700923 for _, t := range targets {
924 if t.Arch.ArchType.Multilib == "lib64" {
925 buildTargets = append(buildTargets, t)
Colin Cross4225f652015-09-17 14:33:42 -0700926 }
927 }
928 default:
929 return nil, fmt.Errorf(`compile_multilib must be "both", "first", "32", or "64", found %q`,
930 multilib)
Colin Cross4225f652015-09-17 14:33:42 -0700931 }
932
Colin Crossa1ad8d12016-06-01 17:09:44 -0700933 return buildTargets, nil
Colin Cross4225f652015-09-17 14:33:42 -0700934}