2015-01-31 02:27:36 +01:00
|
|
|
// Copyright 2015 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
package android
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"reflect"
|
|
|
|
"runtime"
|
|
|
|
"strings"
|
2015-03-24 19:13:38 +01:00
|
|
|
|
|
|
|
"github.com/google/blueprint/proptools"
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2016-06-24 08:44:54 +02:00
|
|
|
archTypeList []ArchType
|
|
|
|
|
2015-07-07 02:49:43 +02:00
|
|
|
Arm = newArch("arm", "lib32")
|
|
|
|
Arm64 = newArch("arm64", "lib64")
|
|
|
|
Mips = newArch("mips", "lib32")
|
|
|
|
Mips64 = newArch("mips64", "lib64")
|
|
|
|
X86 = newArch("x86", "lib32")
|
|
|
|
X86_64 = newArch("x86_64", "lib64")
|
2015-03-31 02:20:39 +02:00
|
|
|
|
|
|
|
Common = ArchType{
|
|
|
|
Name: "common",
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
)
|
|
|
|
|
2015-09-17 23:33:42 +02:00
|
|
|
var archTypeMap = map[string]ArchType{
|
|
|
|
"arm": Arm,
|
|
|
|
"arm64": Arm64,
|
|
|
|
"mips": Mips,
|
2015-11-24 01:28:31 +01:00
|
|
|
"mips64": Mips64,
|
2015-09-17 23:33:42 +02:00
|
|
|
"x86": X86,
|
|
|
|
"x86_64": X86_64,
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
/*
|
|
|
|
Example blueprints file containing all variant property groups, with comment listing what type
|
|
|
|
of variants get properties in that group:
|
|
|
|
|
|
|
|
module {
|
|
|
|
arch: {
|
|
|
|
arm: {
|
|
|
|
// Host or device variants with arm architecture
|
|
|
|
},
|
|
|
|
arm64: {
|
|
|
|
// Host or device variants with arm64 architecture
|
|
|
|
},
|
|
|
|
mips: {
|
|
|
|
// Host or device variants with mips architecture
|
|
|
|
},
|
|
|
|
mips64: {
|
|
|
|
// Host or device variants with mips64 architecture
|
|
|
|
},
|
|
|
|
x86: {
|
|
|
|
// Host or device variants with x86 architecture
|
|
|
|
},
|
|
|
|
x86_64: {
|
|
|
|
// Host or device variants with x86_64 architecture
|
|
|
|
},
|
|
|
|
},
|
|
|
|
multilib: {
|
|
|
|
lib32: {
|
|
|
|
// Host or device variants for 32-bit architectures
|
|
|
|
},
|
|
|
|
lib64: {
|
|
|
|
// Host or device variants for 64-bit architectures
|
|
|
|
},
|
|
|
|
},
|
|
|
|
target: {
|
|
|
|
android: {
|
|
|
|
// Device variants
|
|
|
|
},
|
|
|
|
host: {
|
|
|
|
// Host variants
|
|
|
|
},
|
2017-10-03 04:42:01 +02:00
|
|
|
linux_glibc: {
|
2015-01-31 02:27:36 +01:00
|
|
|
// Linux host variants
|
|
|
|
},
|
|
|
|
darwin: {
|
|
|
|
// Darwin host variants
|
|
|
|
},
|
|
|
|
windows: {
|
|
|
|
// Windows host variants
|
|
|
|
},
|
|
|
|
not_windows: {
|
|
|
|
// Non-windows host variants
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
*/
|
2015-05-11 22:39:40 +02:00
|
|
|
|
2019-01-16 23:33:13 +01:00
|
|
|
var archVariants = map[ArchType][]string{
|
|
|
|
Arm: {
|
|
|
|
"armv7-a-neon",
|
|
|
|
"armv8-a",
|
|
|
|
"armv8-2a",
|
|
|
|
"cortex-a7",
|
|
|
|
"cortex-a8",
|
|
|
|
"cortex-a9",
|
|
|
|
"cortex-a15",
|
|
|
|
"cortex-a53",
|
|
|
|
"cortex-a53-a57",
|
|
|
|
"cortex-a55",
|
|
|
|
"cortex-a72",
|
|
|
|
"cortex-a73",
|
|
|
|
"cortex-a75",
|
|
|
|
"cortex-a76",
|
|
|
|
"krait",
|
|
|
|
"kryo",
|
|
|
|
"kryo385",
|
|
|
|
"exynos-m1",
|
|
|
|
"exynos-m2",
|
|
|
|
},
|
|
|
|
Arm64: {
|
|
|
|
"armv8_a",
|
|
|
|
"armv8_2a",
|
|
|
|
"cortex-a53",
|
|
|
|
"cortex-a55",
|
|
|
|
"cortex-a72",
|
|
|
|
"cortex-a73",
|
|
|
|
"cortex-a75",
|
|
|
|
"cortex-a76",
|
|
|
|
"kryo",
|
|
|
|
"kryo385",
|
|
|
|
"exynos-m1",
|
|
|
|
"exynos-m2",
|
|
|
|
},
|
|
|
|
Mips: {
|
|
|
|
"mips32_fp",
|
|
|
|
"mips32r2_fp",
|
|
|
|
"mips32r2_fp_xburst",
|
|
|
|
"mips32r2dsp_fp",
|
|
|
|
"mips32r2dspr2_fp",
|
|
|
|
"mips32r6",
|
|
|
|
},
|
|
|
|
Mips64: {
|
|
|
|
"mips64r2",
|
|
|
|
"mips64r6",
|
|
|
|
},
|
|
|
|
X86: {
|
|
|
|
"atom",
|
|
|
|
"haswell",
|
|
|
|
"ivybridge",
|
|
|
|
"sandybridge",
|
|
|
|
"silvermont",
|
|
|
|
"x86_64",
|
|
|
|
},
|
|
|
|
X86_64: {
|
|
|
|
"haswell",
|
|
|
|
"ivybridge",
|
|
|
|
"sandybridge",
|
|
|
|
"silvermont",
|
|
|
|
},
|
|
|
|
}
|
2015-07-07 02:49:43 +02:00
|
|
|
|
2019-01-16 23:33:13 +01:00
|
|
|
var archFeatures = map[ArchType][]string{
|
|
|
|
Arm: {
|
|
|
|
"neon",
|
|
|
|
},
|
|
|
|
Mips: {
|
|
|
|
"dspr2",
|
|
|
|
"rev6",
|
|
|
|
"msa",
|
|
|
|
},
|
|
|
|
Mips64: {
|
|
|
|
"rev6",
|
|
|
|
"msa",
|
|
|
|
},
|
|
|
|
X86: {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"aes_ni",
|
|
|
|
"avx",
|
|
|
|
"popcnt",
|
|
|
|
"movbe",
|
|
|
|
},
|
|
|
|
X86_64: {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"aes_ni",
|
|
|
|
"avx",
|
|
|
|
"popcnt",
|
|
|
|
},
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-01-16 23:33:13 +01:00
|
|
|
var archFeatureMap = map[ArchType]map[string][]string{
|
|
|
|
Arm: {
|
|
|
|
"armv7-a-neon": {
|
|
|
|
"neon",
|
|
|
|
},
|
|
|
|
"armv8-a": {
|
|
|
|
"neon",
|
|
|
|
},
|
|
|
|
"armv8-2a": {
|
|
|
|
"neon",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Mips: {
|
|
|
|
"mips32r2dspr2_fp": {
|
|
|
|
"dspr2",
|
|
|
|
},
|
|
|
|
"mips32r6": {
|
|
|
|
"rev6",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Mips64: {
|
|
|
|
"mips64r6": {
|
|
|
|
"rev6",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
X86: {
|
|
|
|
"atom": {
|
|
|
|
"ssse3",
|
|
|
|
"movbe",
|
|
|
|
},
|
|
|
|
"haswell": {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"aes_ni",
|
|
|
|
"avx",
|
|
|
|
"popcnt",
|
|
|
|
"movbe",
|
|
|
|
},
|
|
|
|
"ivybridge": {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"aes_ni",
|
|
|
|
"avx",
|
|
|
|
"popcnt",
|
|
|
|
},
|
|
|
|
"sandybridge": {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"popcnt",
|
|
|
|
},
|
|
|
|
"silvermont": {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"aes_ni",
|
|
|
|
"popcnt",
|
|
|
|
"movbe",
|
|
|
|
},
|
|
|
|
"x86_64": {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"popcnt",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
X86_64: {
|
|
|
|
"haswell": {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"aes_ni",
|
|
|
|
"avx",
|
|
|
|
"popcnt",
|
|
|
|
},
|
|
|
|
"ivybridge": {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"aes_ni",
|
|
|
|
"avx",
|
|
|
|
"popcnt",
|
|
|
|
},
|
|
|
|
"sandybridge": {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"popcnt",
|
|
|
|
},
|
|
|
|
"silvermont": {
|
|
|
|
"ssse3",
|
|
|
|
"sse4",
|
|
|
|
"sse4_1",
|
|
|
|
"sse4_2",
|
|
|
|
"aes_ni",
|
|
|
|
"popcnt",
|
|
|
|
},
|
|
|
|
},
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
2015-11-21 00:35:00 +01:00
|
|
|
|
2019-01-16 23:33:13 +01:00
|
|
|
var defaultArchFeatureMap = map[OsType]map[ArchType][]string{}
|
|
|
|
|
2019-01-12 04:02:16 +01:00
|
|
|
func RegisterDefaultArchVariantFeatures(os OsType, arch ArchType, features ...string) {
|
|
|
|
checkCalledFromInit()
|
|
|
|
|
|
|
|
for _, feature := range features {
|
|
|
|
if !InList(feature, archFeatures[arch]) {
|
|
|
|
panic(fmt.Errorf("Invalid feature %q for arch %q variant \"\"", feature, arch))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if defaultArchFeatureMap[os] == nil {
|
|
|
|
defaultArchFeatureMap[os] = make(map[ArchType][]string)
|
|
|
|
}
|
|
|
|
defaultArchFeatureMap[os][arch] = features
|
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
// An Arch indicates a single CPU architecture.
|
|
|
|
type Arch struct {
|
2015-11-21 00:35:00 +01:00
|
|
|
ArchType ArchType
|
|
|
|
ArchVariant string
|
|
|
|
CpuVariant string
|
|
|
|
Abi []string
|
|
|
|
ArchFeatures []string
|
2016-06-01 01:27:00 +02:00
|
|
|
Native bool
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a Arch) String() string {
|
2015-05-07 23:11:29 +02:00
|
|
|
s := a.ArchType.String()
|
2015-01-31 02:27:36 +01:00
|
|
|
if a.ArchVariant != "" {
|
|
|
|
s += "_" + a.ArchVariant
|
|
|
|
}
|
|
|
|
if a.CpuVariant != "" {
|
|
|
|
s += "_" + a.CpuVariant
|
|
|
|
}
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
|
|
|
type ArchType struct {
|
2015-07-07 02:49:43 +02:00
|
|
|
Name string
|
2016-06-24 08:44:54 +02:00
|
|
|
Field string
|
2015-07-07 02:49:43 +02:00
|
|
|
Multilib string
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-07-07 02:49:43 +02:00
|
|
|
func newArch(name, multilib string) ArchType {
|
2016-06-24 08:44:54 +02:00
|
|
|
archType := ArchType{
|
2015-07-07 02:49:43 +02:00
|
|
|
Name: name,
|
2016-06-24 08:44:54 +02:00
|
|
|
Field: proptools.FieldNameForProperty(name),
|
2015-07-07 02:49:43 +02:00
|
|
|
Multilib: multilib,
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2016-06-24 08:44:54 +02:00
|
|
|
archTypeList = append(archTypeList, archType)
|
|
|
|
return archType
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a ArchType) String() string {
|
|
|
|
return a.Name
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
var BuildOs = func() OsType {
|
|
|
|
switch runtime.GOOS {
|
|
|
|
case "linux":
|
|
|
|
return Linux
|
|
|
|
case "darwin":
|
|
|
|
return Darwin
|
2015-11-25 02:53:15 +01:00
|
|
|
default:
|
2016-06-02 02:09:44 +02:00
|
|
|
panic(fmt.Sprintf("unsupported OS: %s", runtime.GOOS))
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
2016-06-02 02:09:44 +02:00
|
|
|
}()
|
2015-11-25 02:53:15 +01:00
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
var (
|
2017-02-27 19:12:13 +01:00
|
|
|
osTypeList []OsType
|
|
|
|
commonTargetMap = make(map[string]Target)
|
2015-05-07 23:11:29 +02:00
|
|
|
|
2016-11-17 09:25:59 +01:00
|
|
|
NoOsType OsType
|
2017-09-22 21:28:24 +02:00
|
|
|
Linux = NewOsType("linux_glibc", Host, false)
|
2016-11-17 09:25:59 +01:00
|
|
|
Darwin = NewOsType("darwin", Host, false)
|
2018-10-11 02:58:19 +02:00
|
|
|
LinuxBionic = NewOsType("linux_bionic", Host, false)
|
2016-11-17 09:25:59 +01:00
|
|
|
Windows = NewOsType("windows", HostCross, true)
|
|
|
|
Android = NewOsType("android", Device, false)
|
2019-01-16 21:06:11 +01:00
|
|
|
Fuchsia = NewOsType("fuchsia", Device, false)
|
2016-06-24 08:44:54 +02:00
|
|
|
|
|
|
|
osArchTypeMap = map[OsType][]ArchType{
|
2016-11-17 09:25:59 +01:00
|
|
|
Linux: []ArchType{X86, X86_64},
|
|
|
|
LinuxBionic: []ArchType{X86_64},
|
2018-08-29 02:12:56 +02:00
|
|
|
Darwin: []ArchType{X86_64},
|
2016-11-17 09:25:59 +01:00
|
|
|
Windows: []ArchType{X86, X86_64},
|
|
|
|
Android: []ArchType{Arm, Arm64, Mips, Mips64, X86, X86_64},
|
2019-01-16 21:06:11 +01:00
|
|
|
Fuchsia: []ArchType{Arm64, X86_64},
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
2016-06-02 02:09:44 +02:00
|
|
|
)
|
2015-05-07 23:11:29 +02:00
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
type OsType struct {
|
|
|
|
Name, Field string
|
|
|
|
Class OsClass
|
2016-11-13 19:16:05 +01:00
|
|
|
|
|
|
|
DefaultDisabled bool
|
2016-06-03 03:50:47 +02:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
type OsClass int
|
2015-05-07 23:11:29 +02:00
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
const (
|
2016-11-29 02:50:06 +01:00
|
|
|
Generic OsClass = iota
|
|
|
|
Device
|
2016-06-02 02:09:44 +02:00
|
|
|
Host
|
|
|
|
HostCross
|
2016-06-02 02:09:44 +02:00
|
|
|
)
|
2015-05-07 23:11:29 +02:00
|
|
|
|
2017-05-09 22:45:28 +02:00
|
|
|
func (class OsClass) String() string {
|
|
|
|
switch class {
|
|
|
|
case Generic:
|
|
|
|
return "generic"
|
|
|
|
case Device:
|
|
|
|
return "device"
|
|
|
|
case Host:
|
|
|
|
return "host"
|
|
|
|
case HostCross:
|
|
|
|
return "host cross"
|
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("unknown class %d", class))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
func (os OsType) String() string {
|
|
|
|
return os.Name
|
2016-06-02 02:09:44 +02:00
|
|
|
}
|
2015-05-07 23:11:29 +02:00
|
|
|
|
2017-09-22 21:28:24 +02:00
|
|
|
func (os OsType) Bionic() bool {
|
|
|
|
return os == Android || os == LinuxBionic
|
|
|
|
}
|
|
|
|
|
|
|
|
func (os OsType) Linux() bool {
|
|
|
|
return os == Android || os == Linux || os == LinuxBionic
|
|
|
|
}
|
|
|
|
|
2016-11-13 19:16:05 +01:00
|
|
|
func NewOsType(name string, class OsClass, defDisabled bool) OsType {
|
2016-06-02 02:09:44 +02:00
|
|
|
os := OsType{
|
|
|
|
Name: name,
|
|
|
|
Field: strings.Title(name),
|
|
|
|
Class: class,
|
2016-11-13 19:16:05 +01:00
|
|
|
|
|
|
|
DefaultDisabled: defDisabled,
|
2015-05-07 23:11:29 +02:00
|
|
|
}
|
2016-06-02 02:09:44 +02:00
|
|
|
osTypeList = append(osTypeList, os)
|
2017-02-27 19:12:13 +01:00
|
|
|
|
|
|
|
if _, found := commonTargetMap[name]; found {
|
|
|
|
panic(fmt.Errorf("Found Os type duplicate during OsType registration: %q", name))
|
|
|
|
} else {
|
|
|
|
commonTargetMap[name] = Target{Os: os, Arch: Arch{ArchType: Common}}
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
return os
|
2015-05-07 23:11:29 +02:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
func osByName(name string) OsType {
|
|
|
|
for _, os := range osTypeList {
|
|
|
|
if os.Name == name {
|
|
|
|
return os
|
|
|
|
}
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
2016-06-02 02:09:44 +02:00
|
|
|
|
|
|
|
return NoOsType
|
2016-06-02 02:09:44 +02:00
|
|
|
}
|
2015-11-25 02:53:15 +01:00
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
type Target struct {
|
|
|
|
Os OsType
|
|
|
|
Arch Arch
|
|
|
|
}
|
2016-06-03 03:50:47 +02:00
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
func (target Target) String() string {
|
|
|
|
return target.Os.String() + "_" + target.Arch.String()
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
|
|
|
|
2018-10-03 07:01:37 +02:00
|
|
|
// archMutator splits a module into a variant for each Target requested by the module. Target selection
|
|
|
|
// for a module is in three levels, OsClass, mulitlib, and then Target.
|
|
|
|
// OsClass selection is determined by:
|
|
|
|
// - The HostOrDeviceSupported value passed in to InitAndroidArchModule by the module type factory, which selects
|
|
|
|
// whether the module type can compile for host, device or both.
|
|
|
|
// - The host_supported and device_supported properties on the module.
|
|
|
|
// If host is supported for the module, the Host and HostCross OsClasses are are selected. If device is supported
|
|
|
|
// for the module, the Device OsClass is selected.
|
|
|
|
// Within each selected OsClass, the multilib selection is determined by:
|
|
|
|
// - The compile_multilib property if it set (which may be overriden by target.android.compile_multlib or
|
|
|
|
// target.host.compile_multilib).
|
|
|
|
// - The default multilib passed to InitAndroidArchModule if compile_multilib was not set.
|
|
|
|
// Valid multilib values include:
|
|
|
|
// "both": compile for all Targets supported by the OsClass (generally x86_64 and x86, or arm64 and arm).
|
|
|
|
// "first": compile for only a single preferred Target supported by the OsClass. This is generally x86_64 or arm64,
|
|
|
|
// but may be arm for a 32-bit only build or a build with TARGET_PREFER_32_BIT=true set.
|
|
|
|
// "32": compile for only a single 32-bit Target supported by the OsClass.
|
|
|
|
// "64": compile for only a single 64-bit Target supported by the OsClass.
|
|
|
|
// "common": compile a for a single Target that will work on all Targets suported by the OsClass (for example Java).
|
|
|
|
//
|
|
|
|
// Once the list of Targets is determined, the module is split into a variant for each Target.
|
|
|
|
//
|
|
|
|
// Modules can be initialized with InitAndroidMultiTargetsArchModule, in which case they will be split by OsClass,
|
|
|
|
// but will have a common Target that is expected to handle all other selected Targets via ctx.MultiTargets().
|
2016-10-12 23:38:15 +02:00
|
|
|
func archMutator(mctx BottomUpMutatorContext) {
|
2016-05-19 00:37:25 +02:00
|
|
|
var module Module
|
2015-01-31 02:27:36 +01:00
|
|
|
var ok bool
|
2016-05-19 00:37:25 +02:00
|
|
|
if module, ok = mctx.Module().(Module); !ok {
|
2015-01-31 02:27:36 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-10-02 23:02:10 +02:00
|
|
|
base := module.base()
|
|
|
|
|
|
|
|
if !base.ArchSpecific() {
|
2016-06-02 02:09:44 +02:00
|
|
|
return
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
var moduleTargets []Target
|
2018-10-03 07:01:37 +02:00
|
|
|
moduleMultiTargets := make(map[int][]Target)
|
2016-09-13 18:59:14 +02:00
|
|
|
primaryModules := make(map[int]bool)
|
2018-10-11 02:02:29 +02:00
|
|
|
osClasses := base.OsClassSupported()
|
|
|
|
|
|
|
|
for _, os := range osTypeList {
|
|
|
|
supportedClass := false
|
|
|
|
for _, osClass := range osClasses {
|
|
|
|
if os.Class == osClass {
|
|
|
|
supportedClass = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !supportedClass {
|
|
|
|
continue
|
|
|
|
}
|
2016-06-02 02:09:44 +02:00
|
|
|
|
2018-10-11 02:02:29 +02:00
|
|
|
osTargets := mctx.Config().Targets[os]
|
|
|
|
if len(osTargets) == 0 {
|
2016-06-02 02:09:44 +02:00
|
|
|
continue
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
2018-10-03 07:01:37 +02:00
|
|
|
|
2018-10-02 23:02:10 +02:00
|
|
|
// only the primary arch in the recovery partition
|
2018-10-11 02:02:29 +02:00
|
|
|
if os == Android && module.InstallInRecovery() {
|
|
|
|
osTargets = []Target{osTargets[0]}
|
2018-10-02 23:02:10 +02:00
|
|
|
}
|
|
|
|
|
2018-10-02 22:59:46 +02:00
|
|
|
prefer32 := false
|
|
|
|
if base.prefer32 != nil {
|
2018-10-11 02:02:29 +02:00
|
|
|
prefer32 = base.prefer32(mctx, base, os.Class)
|
2016-09-13 18:59:14 +02:00
|
|
|
}
|
2018-10-02 22:59:46 +02:00
|
|
|
|
2018-10-11 02:02:29 +02:00
|
|
|
multilib, extraMultilib := decodeMultilib(base, os.Class)
|
|
|
|
targets, err := decodeMultilibTargets(multilib, osTargets, prefer32)
|
2016-06-03 03:50:47 +02:00
|
|
|
if err != nil {
|
|
|
|
mctx.ModuleErrorf("%s", err.Error())
|
|
|
|
}
|
2018-10-03 07:01:37 +02:00
|
|
|
|
|
|
|
var multiTargets []Target
|
|
|
|
if extraMultilib != "" {
|
2018-10-11 02:02:29 +02:00
|
|
|
multiTargets, err = decodeMultilibTargets(extraMultilib, osTargets, prefer32)
|
2018-10-03 07:01:37 +02:00
|
|
|
if err != nil {
|
|
|
|
mctx.ModuleErrorf("%s", err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-13 18:59:14 +02:00
|
|
|
if len(targets) > 0 {
|
|
|
|
primaryModules[len(moduleTargets)] = true
|
2018-10-03 07:01:37 +02:00
|
|
|
moduleMultiTargets[len(moduleTargets)] = multiTargets
|
2016-09-13 18:59:14 +02:00
|
|
|
moduleTargets = append(moduleTargets, targets...)
|
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-07-11 23:36:48 +02:00
|
|
|
if len(moduleTargets) == 0 {
|
2018-10-02 23:02:10 +02:00
|
|
|
base.commonProperties.Enabled = boolPtr(false)
|
2016-07-11 23:36:48 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
targetNames := make([]string, len(moduleTargets))
|
2015-03-18 21:28:46 +01:00
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
for i, target := range moduleTargets {
|
|
|
|
targetNames[i] = target.String()
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
modules := mctx.CreateVariations(targetNames...)
|
2015-01-31 02:27:36 +01:00
|
|
|
for i, m := range modules {
|
2018-10-03 07:01:37 +02:00
|
|
|
m.(Module).base().SetTarget(moduleTargets[i], moduleMultiTargets[i], primaryModules[i])
|
2016-05-19 00:37:25 +02:00
|
|
|
m.(Module).base().setArchProperties(mctx)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-03 07:01:37 +02:00
|
|
|
func decodeMultilib(base *ModuleBase, class OsClass) (multilib, extraMultilib string) {
|
|
|
|
switch class {
|
|
|
|
case Device:
|
|
|
|
multilib = String(base.commonProperties.Target.Android.Compile_multilib)
|
|
|
|
case Host, HostCross:
|
|
|
|
multilib = String(base.commonProperties.Target.Host.Compile_multilib)
|
|
|
|
}
|
|
|
|
if multilib == "" {
|
|
|
|
multilib = String(base.commonProperties.Compile_multilib)
|
|
|
|
}
|
|
|
|
if multilib == "" {
|
|
|
|
multilib = base.commonProperties.Default_multilib
|
|
|
|
}
|
|
|
|
|
|
|
|
if base.commonProperties.UseTargetVariants {
|
|
|
|
return multilib, ""
|
|
|
|
} else {
|
|
|
|
// For app modules a single arch variant will be created per OS class which is expected to handle all the
|
|
|
|
// selected arches. Return the common-type as multilib and any Android.bp provided multilib as extraMultilib
|
|
|
|
if multilib == base.commonProperties.Default_multilib {
|
|
|
|
multilib = "first"
|
|
|
|
}
|
|
|
|
return base.commonProperties.Default_multilib, multilib
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
func filterArchStructFields(fields []reflect.StructField) (filteredFields []reflect.StructField, filtered bool) {
|
2018-10-24 21:42:09 +02:00
|
|
|
for _, field := range fields {
|
2016-06-24 08:44:54 +02:00
|
|
|
if !proptools.HasTag(field, "android", "arch_variant") {
|
2019-01-24 23:58:11 +01:00
|
|
|
filtered = true
|
2016-06-24 08:44:54 +02:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// The arch_variant field isn't necessary past this point
|
|
|
|
// Instead of wasting space, just remove it. Go also has a
|
|
|
|
// 16-bit limit on structure name length. The name is constructed
|
|
|
|
// based on the Go source representation of the structure, so
|
|
|
|
// the tag names count towards that length.
|
|
|
|
//
|
|
|
|
// TODO: handle the uncommon case of other tags being involved
|
|
|
|
if field.Tag == `android:"arch_variant"` {
|
|
|
|
field.Tag = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
// Recurse into structs
|
|
|
|
switch field.Type.Kind() {
|
|
|
|
case reflect.Struct:
|
2019-01-24 23:58:11 +01:00
|
|
|
var subFiltered bool
|
|
|
|
field.Type, subFiltered = filterArchStruct(field.Type)
|
|
|
|
filtered = filtered || subFiltered
|
|
|
|
if field.Type == nil {
|
2016-06-24 08:44:54 +02:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
case reflect.Ptr:
|
|
|
|
if field.Type.Elem().Kind() == reflect.Struct {
|
2019-01-24 23:58:11 +01:00
|
|
|
nestedType, subFiltered := filterArchStruct(field.Type.Elem())
|
|
|
|
filtered = filtered || subFiltered
|
|
|
|
if nestedType == nil {
|
2016-06-24 08:44:54 +02:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
field.Type = reflect.PtrTo(nestedType)
|
|
|
|
}
|
|
|
|
case reflect.Interface:
|
|
|
|
panic("Interfaces are not supported in arch_variant properties")
|
|
|
|
}
|
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
filteredFields = append(filteredFields, field)
|
2018-10-24 21:42:09 +02:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
return filteredFields, filtered
|
2018-10-24 21:42:09 +02:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
// filterArchStruct takes a reflect.Type that is either a sturct or a pointer to a struct, and returns a reflect.Type
|
|
|
|
// that only contains the fields in the original type that have an `android:"arch_variant"` struct tag, and a bool
|
|
|
|
// that is true if the new struct type has fewer fields than the original type. If there are no fields in the
|
|
|
|
// original type with the struct tag it returns nil and true.
|
|
|
|
func filterArchStruct(prop reflect.Type) (filteredProp reflect.Type, filtered bool) {
|
2018-10-24 21:42:09 +02:00
|
|
|
var fields []reflect.StructField
|
|
|
|
|
|
|
|
ptr := prop.Kind() == reflect.Ptr
|
|
|
|
if ptr {
|
|
|
|
prop = prop.Elem()
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < prop.NumField(); i++ {
|
|
|
|
fields = append(fields, prop.Field(i))
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
2018-10-24 21:42:09 +02:00
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
filteredFields, filtered := filterArchStructFields(fields)
|
2018-10-24 21:42:09 +02:00
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
if len(filteredFields) == 0 {
|
|
|
|
return nil, true
|
|
|
|
}
|
|
|
|
|
|
|
|
if !filtered {
|
|
|
|
if ptr {
|
|
|
|
return reflect.PtrTo(prop), false
|
|
|
|
}
|
|
|
|
return prop, false
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
ret := reflect.StructOf(filteredFields)
|
2016-06-24 08:44:54 +02:00
|
|
|
if ptr {
|
|
|
|
ret = reflect.PtrTo(ret)
|
|
|
|
}
|
2018-10-24 21:42:09 +02:00
|
|
|
|
2016-06-24 08:44:54 +02:00
|
|
|
return ret, true
|
|
|
|
}
|
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
// filterArchStruct takes a reflect.Type that is either a sturct or a pointer to a struct, and returns a list of
|
|
|
|
// reflect.Type that only contains the fields in the original type that have an `android:"arch_variant"` struct tag,
|
|
|
|
// and a bool that is true if the new struct type has fewer fields than the original type. If there are no fields in
|
|
|
|
// the original type with the struct tag it returns nil and true. Each returned struct type will have a maximum of
|
|
|
|
// 10 top level fields in it to attempt to avoid hitting the reflect.StructOf name length limit, although the limit
|
|
|
|
// can still be reached with a single struct field with many fields in it.
|
|
|
|
func filterArchStructSharded(prop reflect.Type) (filteredProp []reflect.Type, filtered bool) {
|
2018-10-24 21:42:09 +02:00
|
|
|
var fields []reflect.StructField
|
|
|
|
|
|
|
|
ptr := prop.Kind() == reflect.Ptr
|
|
|
|
if ptr {
|
|
|
|
prop = prop.Elem()
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
for i := 0; i < prop.NumField(); i++ {
|
|
|
|
fields = append(fields, prop.Field(i))
|
|
|
|
}
|
2016-06-24 08:44:54 +02:00
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
fields, filtered = filterArchStructFields(fields)
|
|
|
|
if !filtered {
|
|
|
|
if ptr {
|
|
|
|
return []reflect.Type{reflect.PtrTo(prop)}, false
|
|
|
|
}
|
|
|
|
return []reflect.Type{prop}, false
|
|
|
|
}
|
2016-06-24 08:44:54 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
if len(fields) == 0 {
|
2019-01-24 23:58:11 +01:00
|
|
|
return nil, true
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
shards := shardFields(fields, 10)
|
2016-06-24 08:44:54 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
for _, shard := range shards {
|
|
|
|
s := reflect.StructOf(shard)
|
|
|
|
if ptr {
|
|
|
|
s = reflect.PtrTo(s)
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
2019-01-24 23:58:11 +01:00
|
|
|
filteredProp = append(filteredProp, s)
|
2018-10-24 21:42:09 +02:00
|
|
|
}
|
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
return filteredProp, true
|
2018-10-24 21:42:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func shardFields(fields []reflect.StructField, shardSize int) [][]reflect.StructField {
|
|
|
|
ret := make([][]reflect.StructField, 0, (len(fields)+shardSize-1)/shardSize)
|
|
|
|
for len(fields) > shardSize {
|
|
|
|
ret = append(ret, fields[0:shardSize])
|
|
|
|
fields = fields[shardSize:]
|
|
|
|
}
|
|
|
|
if len(fields) > 0 {
|
|
|
|
ret = append(ret, fields)
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2019-01-24 23:58:11 +01:00
|
|
|
// createArchType takes a reflect.Type that is either a struct or a pointer to a struct, and returns a list of
|
|
|
|
// reflect.Type that contains the arch-variant properties inside structs for each architecture, os, target, multilib,
|
|
|
|
// etc.
|
2018-10-24 21:42:09 +02:00
|
|
|
func createArchType(props reflect.Type) []reflect.Type {
|
2019-01-24 23:58:11 +01:00
|
|
|
propShards, _ := filterArchStructSharded(props)
|
|
|
|
if len(propShards) == 0 {
|
2018-10-24 21:42:09 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var ret []reflect.Type
|
|
|
|
for _, props := range propShards {
|
|
|
|
|
|
|
|
variantFields := func(names []string) []reflect.StructField {
|
|
|
|
ret := make([]reflect.StructField, len(names))
|
|
|
|
|
|
|
|
for i, name := range names {
|
|
|
|
ret[i].Name = name
|
|
|
|
ret[i].Type = props
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
archFields := make([]reflect.StructField, len(archTypeList))
|
|
|
|
for i, arch := range archTypeList {
|
|
|
|
variants := []string{}
|
|
|
|
|
|
|
|
for _, archVariant := range archVariants[arch] {
|
|
|
|
archVariant := variantReplacer.Replace(archVariant)
|
|
|
|
variants = append(variants, proptools.FieldNameForProperty(archVariant))
|
|
|
|
}
|
|
|
|
for _, feature := range archFeatures[arch] {
|
|
|
|
feature := variantReplacer.Replace(feature)
|
|
|
|
variants = append(variants, proptools.FieldNameForProperty(feature))
|
|
|
|
}
|
2016-06-24 08:44:54 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
fields := variantFields(variants)
|
2016-06-24 08:44:54 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
fields = append([]reflect.StructField{{
|
|
|
|
Name: "BlueprintEmbed",
|
|
|
|
Type: props,
|
|
|
|
Anonymous: true,
|
|
|
|
}}, fields...)
|
|
|
|
|
|
|
|
archFields[i] = reflect.StructField{
|
|
|
|
Name: arch.Field,
|
|
|
|
Type: reflect.StructOf(fields),
|
|
|
|
}
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
2018-10-24 21:42:09 +02:00
|
|
|
archType := reflect.StructOf(archFields)
|
2016-06-24 08:44:54 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
multilibType := reflect.StructOf(variantFields([]string{"Lib32", "Lib64"}))
|
2016-06-24 08:44:54 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
targets := []string{
|
|
|
|
"Host",
|
|
|
|
"Android64",
|
|
|
|
"Android32",
|
|
|
|
"Bionic",
|
|
|
|
"Linux",
|
|
|
|
"Not_windows",
|
|
|
|
"Arm_on_x86",
|
|
|
|
"Arm_on_x86_64",
|
|
|
|
}
|
|
|
|
for _, os := range osTypeList {
|
|
|
|
targets = append(targets, os.Field)
|
2016-06-24 08:44:54 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
for _, archType := range osArchTypeMap[os] {
|
|
|
|
targets = append(targets, os.Field+"_"+archType.Name)
|
2017-09-22 21:28:24 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
if os.Linux() {
|
|
|
|
target := "Linux_" + archType.Name
|
|
|
|
if !InList(target, targets) {
|
|
|
|
targets = append(targets, target)
|
|
|
|
}
|
2017-09-22 21:28:24 +02:00
|
|
|
}
|
2018-10-24 21:42:09 +02:00
|
|
|
if os.Bionic() {
|
|
|
|
target := "Bionic_" + archType.Name
|
|
|
|
if !InList(target, targets) {
|
|
|
|
targets = append(targets, target)
|
|
|
|
}
|
2017-09-22 21:28:24 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
targetType := reflect.StructOf(variantFields(targets))
|
|
|
|
ret = append(ret, reflect.StructOf([]reflect.StructField{
|
|
|
|
{
|
|
|
|
Name: "Arch",
|
|
|
|
Type: archType,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Multilib",
|
|
|
|
Type: multilibType,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Target",
|
|
|
|
Type: targetType,
|
|
|
|
},
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
return ret
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var archPropTypeMap OncePer
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
func InitArchModule(m Module) {
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
base := m.base()
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
base.generalProperties = m.GetProperties()
|
2015-01-31 02:27:36 +01:00
|
|
|
|
|
|
|
for _, properties := range base.generalProperties {
|
|
|
|
propertiesValue := reflect.ValueOf(properties)
|
2016-08-09 00:49:17 +02:00
|
|
|
t := propertiesValue.Type()
|
2015-01-31 02:27:36 +01:00
|
|
|
if propertiesValue.Kind() != reflect.Ptr {
|
2016-01-04 23:34:37 +01:00
|
|
|
panic(fmt.Errorf("properties must be a pointer to a struct, got %T",
|
|
|
|
propertiesValue.Interface()))
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
propertiesValue = propertiesValue.Elem()
|
|
|
|
if propertiesValue.Kind() != reflect.Struct {
|
2016-01-04 23:34:37 +01:00
|
|
|
panic(fmt.Errorf("properties must be a pointer to a struct, got %T",
|
|
|
|
propertiesValue.Interface()))
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2019-02-04 20:22:08 +01:00
|
|
|
archPropTypes := archPropTypeMap.Once(NewCustomOnceKey(t), func() interface{} {
|
2016-06-24 08:44:54 +02:00
|
|
|
return createArchType(t)
|
2018-10-24 21:42:09 +02:00
|
|
|
}).([]reflect.Type)
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
var archProperties []interface{}
|
|
|
|
for _, t := range archPropTypes {
|
|
|
|
archProperties = append(archProperties, reflect.New(t).Interface())
|
2016-06-24 08:44:54 +02:00
|
|
|
}
|
2018-10-24 21:42:09 +02:00
|
|
|
base.archProperties = append(base.archProperties, archProperties)
|
|
|
|
m.AddProperties(archProperties...)
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2017-06-24 00:06:31 +02:00
|
|
|
base.customizableProperties = m.GetProperties()
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
|
2015-12-16 20:07:39 +01:00
|
|
|
var variantReplacer = strings.NewReplacer("-", "_", ".", "_")
|
2015-07-07 02:49:43 +02:00
|
|
|
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
|
2016-06-24 08:44:54 +02:00
|
|
|
dst interface{}, src reflect.Value, field, srcPrefix string) reflect.Value {
|
2015-10-29 01:23:31 +01:00
|
|
|
|
2016-06-24 08:44:54 +02:00
|
|
|
src = src.FieldByName(field)
|
|
|
|
if !src.IsValid() {
|
2015-11-20 22:07:51 +01:00
|
|
|
ctx.ModuleErrorf("field %q does not exist", srcPrefix)
|
2016-06-24 08:44:54 +02:00
|
|
|
return src
|
2015-11-23 22:29:51 +01:00
|
|
|
}
|
|
|
|
|
2016-06-24 08:44:54 +02:00
|
|
|
ret := src
|
2015-11-23 22:29:51 +01:00
|
|
|
|
2016-06-24 08:44:54 +02:00
|
|
|
if src.Kind() == reflect.Struct {
|
|
|
|
src = src.FieldByName("BlueprintEmbed")
|
2015-10-29 01:23:31 +01:00
|
|
|
}
|
|
|
|
|
2016-05-06 00:57:15 +02:00
|
|
|
order := func(property string,
|
|
|
|
dstField, srcField reflect.StructField,
|
|
|
|
dstValue, srcValue interface{}) (proptools.Order, error) {
|
|
|
|
if proptools.HasTag(dstField, "android", "variant_prepend") {
|
|
|
|
return proptools.Prepend, nil
|
|
|
|
} else {
|
|
|
|
return proptools.Append, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-24 08:44:54 +02:00
|
|
|
err := proptools.ExtendMatchingProperties([]interface{}{dst}, src.Interface(), nil, order)
|
2015-10-29 01:23:31 +01:00
|
|
|
if err != nil {
|
|
|
|
if propertyErr, ok := err.(*proptools.ExtendPropertyError); ok {
|
|
|
|
ctx.PropertyErrorf(propertyErr.Property, "%s", propertyErr.Err.Error())
|
|
|
|
} else {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
2015-11-23 22:29:51 +01:00
|
|
|
|
2016-06-24 08:44:54 +02:00
|
|
|
return ret
|
2015-10-29 01:23:31 +01:00
|
|
|
}
|
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
// Rewrite the module's properties structs to contain arch-specific values.
|
2016-05-19 00:37:25 +02:00
|
|
|
func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
|
2016-06-02 02:09:44 +02:00
|
|
|
arch := a.Arch()
|
|
|
|
os := a.Os()
|
2015-05-07 23:11:29 +02:00
|
|
|
|
2015-01-31 02:27:36 +01:00
|
|
|
for i := range a.generalProperties {
|
2015-10-29 01:23:31 +01:00
|
|
|
genProps := a.generalProperties[i]
|
2016-06-24 08:44:54 +02:00
|
|
|
if a.archProperties[i] == nil {
|
|
|
|
continue
|
|
|
|
}
|
2018-10-24 21:42:09 +02:00
|
|
|
for _, archProperties := range a.archProperties[i] {
|
|
|
|
archPropValues := reflect.ValueOf(archProperties).Elem()
|
2017-10-02 22:55:26 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
archProp := archPropValues.FieldByName("Arch")
|
|
|
|
multilibProp := archPropValues.FieldByName("Multilib")
|
|
|
|
targetProp := archPropValues.FieldByName("Target")
|
2015-10-29 01:23:31 +01:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
var field string
|
|
|
|
var prefix string
|
2017-10-02 22:55:26 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
// Handle arch-specific properties in the form:
|
2017-10-02 22:55:26 +02:00
|
|
|
// arch: {
|
2018-10-24 21:42:09 +02:00
|
|
|
// arm64: {
|
2017-10-02 22:55:26 +02:00
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// },
|
2018-10-24 21:42:09 +02:00
|
|
|
t := arch.ArchType
|
2015-07-07 02:49:43 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
if arch.ArchType != Common {
|
|
|
|
field := proptools.FieldNameForProperty(t.Name)
|
|
|
|
prefix := "arch." + t.Name
|
|
|
|
archStruct := a.appendProperties(ctx, genProps, archProp, field, prefix)
|
|
|
|
|
|
|
|
// Handle arch-variant-specific properties in the form:
|
|
|
|
// arch: {
|
|
|
|
// variant: {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
v := variantReplacer.Replace(arch.ArchVariant)
|
|
|
|
if v != "" {
|
|
|
|
field := proptools.FieldNameForProperty(v)
|
|
|
|
prefix := "arch." + t.Name + "." + v
|
2017-10-02 22:55:26 +02:00
|
|
|
a.appendProperties(ctx, genProps, archStruct, field, prefix)
|
|
|
|
}
|
2018-10-24 21:42:09 +02:00
|
|
|
|
|
|
|
// Handle cpu-variant-specific properties in the form:
|
|
|
|
// arch: {
|
|
|
|
// variant: {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
if arch.CpuVariant != arch.ArchVariant {
|
|
|
|
c := variantReplacer.Replace(arch.CpuVariant)
|
|
|
|
if c != "" {
|
|
|
|
field := proptools.FieldNameForProperty(c)
|
|
|
|
prefix := "arch." + t.Name + "." + c
|
|
|
|
a.appendProperties(ctx, genProps, archStruct, field, prefix)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle arch-feature-specific properties in the form:
|
|
|
|
// arch: {
|
|
|
|
// feature: {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
for _, feature := range arch.ArchFeatures {
|
|
|
|
field := proptools.FieldNameForProperty(feature)
|
|
|
|
prefix := "arch." + t.Name + "." + feature
|
|
|
|
a.appendProperties(ctx, genProps, archStruct, field, prefix)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle multilib-specific properties in the form:
|
|
|
|
// multilib: {
|
|
|
|
// lib32: {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
field = proptools.FieldNameForProperty(t.Multilib)
|
|
|
|
prefix = "multilib." + t.Multilib
|
|
|
|
a.appendProperties(ctx, genProps, multilibProp, field, prefix)
|
2017-10-02 22:55:26 +02:00
|
|
|
}
|
2015-07-07 02:49:43 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
// Handle host-specific properties in the form:
|
|
|
|
// target: {
|
|
|
|
// host: {
|
2017-10-02 22:55:26 +02:00
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// },
|
2018-10-24 21:42:09 +02:00
|
|
|
if os.Class == Host || os.Class == HostCross {
|
|
|
|
field = "Host"
|
|
|
|
prefix = "target.host"
|
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
2016-12-20 18:53:14 +01:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
// Handle target OS generalities of the form:
|
|
|
|
// target: {
|
|
|
|
// bionic: {
|
2017-10-02 22:55:26 +02:00
|
|
|
// key: value,
|
|
|
|
// },
|
2018-10-24 21:42:09 +02:00
|
|
|
// bionic_x86: {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// }
|
|
|
|
if os.Linux() {
|
|
|
|
field = "Linux"
|
|
|
|
prefix = "target.linux"
|
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
2015-01-31 02:27:36 +01:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
if arch.ArchType != Common {
|
|
|
|
field = "Linux_" + arch.ArchType.Name
|
|
|
|
prefix = "target.linux_" + arch.ArchType.Name
|
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
|
|
|
}
|
|
|
|
}
|
2017-09-22 21:28:24 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
if os.Bionic() {
|
|
|
|
field = "Bionic"
|
|
|
|
prefix = "target.bionic"
|
2017-10-02 22:55:26 +02:00
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
2018-10-24 21:42:09 +02:00
|
|
|
|
|
|
|
if arch.ArchType != Common {
|
|
|
|
field = "Bionic_" + t.Name
|
|
|
|
prefix = "target.bionic_" + t.Name
|
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
|
|
|
}
|
2017-10-02 22:55:26 +02:00
|
|
|
}
|
2017-09-22 21:28:24 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
// Handle target OS properties in the form:
|
|
|
|
// target: {
|
|
|
|
// linux_glibc: {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// not_windows: {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// linux_glibc_x86: {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// linux_glibc_arm: {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// android {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// android_arm {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// android_x86 {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
field = os.Field
|
|
|
|
prefix = "target." + os.Name
|
2017-09-22 21:28:24 +02:00
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
|
|
|
|
2017-10-02 22:55:26 +02:00
|
|
|
if arch.ArchType != Common {
|
2018-10-24 21:42:09 +02:00
|
|
|
field = os.Field + "_" + t.Name
|
|
|
|
prefix = "target." + os.Name + "_" + t.Name
|
2017-10-02 22:55:26 +02:00
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
|
|
|
}
|
2017-09-22 21:28:24 +02:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
if (os.Class == Host || os.Class == HostCross) && os != Windows {
|
|
|
|
field := "Not_windows"
|
|
|
|
prefix := "target.not_windows"
|
2016-06-24 08:44:54 +02:00
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
2015-03-26 22:44:26 +01:00
|
|
|
}
|
2016-12-09 02:23:53 +01:00
|
|
|
|
2018-10-24 21:42:09 +02:00
|
|
|
// Handle 64-bit device properties in the form:
|
|
|
|
// target {
|
|
|
|
// android64 {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// android32 {
|
|
|
|
// key: value,
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// WARNING: this is probably not what you want to use in your blueprints file, it selects
|
|
|
|
// options for all targets on a device that supports 64-bit binaries, not just the targets
|
|
|
|
// that are being compiled for 64-bit. Its expected use case is binaries like linker and
|
|
|
|
// debuggerd that need to know when they are a 32-bit process running on a 64-bit device
|
|
|
|
if os.Class == Device {
|
|
|
|
if ctx.Config().Android64() {
|
|
|
|
field := "Android64"
|
|
|
|
prefix := "target.android64"
|
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
|
|
|
} else {
|
|
|
|
field := "Android32"
|
|
|
|
prefix := "target.android32"
|
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arch.ArchType == X86 && (hasArmAbi(arch) ||
|
|
|
|
hasArmAndroidArch(ctx.Config().Targets[Android]))) ||
|
|
|
|
(arch.ArchType == Arm &&
|
|
|
|
hasX86AndroidArch(ctx.Config().Targets[Android])) {
|
|
|
|
field := "Arm_on_x86"
|
|
|
|
prefix := "target.arm_on_x86"
|
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
|
|
|
}
|
|
|
|
if (arch.ArchType == X86_64 && (hasArmAbi(arch) ||
|
|
|
|
hasArmAndroidArch(ctx.Config().Targets[Android]))) ||
|
|
|
|
(arch.ArchType == Arm &&
|
|
|
|
hasX8664AndroidArch(ctx.Config().Targets[Android])) {
|
|
|
|
field := "Arm_on_x86_64"
|
|
|
|
prefix := "target.arm_on_x86_64"
|
|
|
|
a.appendProperties(ctx, genProps, targetProp, field, prefix)
|
|
|
|
}
|
2017-04-14 01:56:14 +02:00
|
|
|
}
|
2016-12-09 02:23:53 +01:00
|
|
|
}
|
2015-01-31 02:27:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func forEachInterface(v reflect.Value, f func(reflect.Value)) {
|
|
|
|
switch v.Kind() {
|
|
|
|
case reflect.Interface:
|
|
|
|
f(v)
|
|
|
|
case reflect.Struct:
|
|
|
|
for i := 0; i < v.NumField(); i++ {
|
|
|
|
forEachInterface(v.Field(i), f)
|
|
|
|
}
|
|
|
|
case reflect.Ptr:
|
|
|
|
forEachInterface(v.Elem(), f)
|
|
|
|
default:
|
|
|
|
panic(fmt.Errorf("Unsupported kind %s", v.Kind()))
|
|
|
|
}
|
|
|
|
}
|
2015-09-17 23:33:42 +02:00
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
// Convert the arch product variables into a list of targets for each os class structs
|
2018-10-11 02:02:29 +02:00
|
|
|
func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
2018-03-10 06:22:06 +01:00
|
|
|
variables := config.productVariables
|
2016-06-02 02:09:44 +02:00
|
|
|
|
2018-10-11 02:02:29 +02:00
|
|
|
targets := make(map[OsType][]Target)
|
2016-06-02 02:09:44 +02:00
|
|
|
var targetErr error
|
|
|
|
|
2019-01-31 23:31:51 +01:00
|
|
|
addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi []string) {
|
2016-06-02 02:09:44 +02:00
|
|
|
if targetErr != nil {
|
|
|
|
return
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
|
|
|
|
2019-01-12 04:02:16 +01:00
|
|
|
arch, err := decodeArch(os, archName, archVariant, cpuVariant, abi)
|
2016-06-02 02:09:44 +02:00
|
|
|
if err != nil {
|
|
|
|
targetErr = err
|
|
|
|
return
|
|
|
|
}
|
2015-11-25 02:53:15 +01:00
|
|
|
|
2018-10-11 02:02:29 +02:00
|
|
|
targets[os] = append(targets[os],
|
2016-06-02 02:09:44 +02:00
|
|
|
Target{
|
|
|
|
Os: os,
|
|
|
|
Arch: arch,
|
|
|
|
})
|
2015-09-17 23:33:42 +02:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
if variables.HostArch == nil {
|
|
|
|
return nil, fmt.Errorf("No host primary architecture set")
|
2015-09-17 23:33:42 +02:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
addTarget(BuildOs, *variables.HostArch, nil, nil, nil)
|
2015-09-17 23:33:42 +02:00
|
|
|
|
2015-11-20 22:07:51 +01:00
|
|
|
if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
|
2016-06-02 02:09:44 +02:00
|
|
|
addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil)
|
2016-06-14 02:19:03 +02:00
|
|
|
}
|
|
|
|
|
2018-04-11 01:15:18 +02:00
|
|
|
if Bool(config.Host_bionic) {
|
2016-06-14 02:19:03 +02:00
|
|
|
addTarget(LinuxBionic, "x86_64", nil, nil, nil)
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
|
|
|
|
2018-04-11 01:15:18 +02:00
|
|
|
if String(variables.CrossHost) != "" {
|
2016-06-02 02:09:44 +02:00
|
|
|
crossHostOs := osByName(*variables.CrossHost)
|
|
|
|
if crossHostOs == NoOsType {
|
|
|
|
return nil, fmt.Errorf("Unknown cross host OS %q", *variables.CrossHost)
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
|
|
|
|
2018-04-11 01:15:18 +02:00
|
|
|
if String(variables.CrossHostArch) == "" {
|
2016-06-02 02:09:44 +02:00
|
|
|
return nil, fmt.Errorf("No cross-host primary architecture set")
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
addTarget(crossHostOs, *variables.CrossHostArch, nil, nil, nil)
|
2015-11-25 02:53:15 +01:00
|
|
|
|
|
|
|
if variables.CrossHostSecondaryArch != nil && *variables.CrossHostSecondaryArch != "" {
|
2016-06-02 02:09:44 +02:00
|
|
|
addTarget(crossHostOs, *variables.CrossHostSecondaryArch, nil, nil, nil)
|
2015-11-25 02:53:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-11 23:36:48 +02:00
|
|
|
if variables.DeviceArch != nil && *variables.DeviceArch != "" {
|
2019-01-16 21:06:11 +01:00
|
|
|
var target = Android
|
|
|
|
if Bool(variables.Fuchsia) {
|
|
|
|
target = Fuchsia
|
|
|
|
}
|
|
|
|
|
|
|
|
addTarget(target, *variables.DeviceArch, variables.DeviceArchVariant,
|
2016-07-11 23:36:48 +02:00
|
|
|
variables.DeviceCpuVariant, variables.DeviceAbi)
|
2015-09-17 23:33:42 +02:00
|
|
|
|
2016-07-11 23:36:48 +02:00
|
|
|
if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" {
|
|
|
|
addTarget(Android, *variables.DeviceSecondaryArch,
|
|
|
|
variables.DeviceSecondaryArchVariant, variables.DeviceSecondaryCpuVariant,
|
|
|
|
variables.DeviceSecondaryAbi)
|
2016-06-02 02:09:44 +02:00
|
|
|
|
2018-10-11 02:02:29 +02:00
|
|
|
deviceArches := targets[Android]
|
2016-07-11 23:36:48 +02:00
|
|
|
if deviceArches[0].Arch.ArchType.Multilib == deviceArches[1].Arch.ArchType.Multilib {
|
|
|
|
deviceArches[1].Arch.Native = false
|
|
|
|
}
|
2016-06-03 03:50:47 +02:00
|
|
|
}
|
2015-09-17 23:33:42 +02:00
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
if targetErr != nil {
|
|
|
|
return nil, targetErr
|
|
|
|
}
|
|
|
|
|
|
|
|
return targets, nil
|
2015-09-17 23:33:42 +02:00
|
|
|
}
|
|
|
|
|
2016-12-09 02:23:53 +01:00
|
|
|
// hasArmAbi returns true if arch has at least one arm ABI
|
|
|
|
func hasArmAbi(arch Arch) bool {
|
|
|
|
for _, abi := range arch.Abi {
|
|
|
|
if strings.HasPrefix(abi, "arm") {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2017-04-14 01:56:14 +02:00
|
|
|
// hasArmArch returns true if targets has at least arm Android arch
|
|
|
|
func hasArmAndroidArch(targets []Target) bool {
|
|
|
|
for _, target := range targets {
|
|
|
|
if target.Os == Android && target.Arch.ArchType == Arm {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2018-03-21 20:30:54 +01:00
|
|
|
// hasX86Arch returns true if targets has at least x86 Android arch
|
|
|
|
func hasX86AndroidArch(targets []Target) bool {
|
|
|
|
for _, target := range targets {
|
|
|
|
if target.Os == Android && target.Arch.ArchType == X86 {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// hasX8664Arch returns true if targets has at least x86_64 Android arch
|
|
|
|
func hasX8664AndroidArch(targets []Target) bool {
|
|
|
|
for _, target := range targets {
|
|
|
|
if target.Os == Android && target.Arch.ArchType == X86_64 {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2016-10-19 23:04:41 +02:00
|
|
|
type archConfig struct {
|
|
|
|
arch string
|
|
|
|
archVariant string
|
|
|
|
cpuVariant string
|
|
|
|
abi []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func getMegaDeviceConfig() []archConfig {
|
|
|
|
return []archConfig{
|
2016-01-15 00:17:19 +01:00
|
|
|
{"arm", "armv7-a-neon", "generic", []string{"armeabi-v7a"}},
|
2016-01-13 08:07:05 +01:00
|
|
|
{"arm", "armv7-a-neon", "cortex-a7", []string{"armeabi-v7a"}},
|
|
|
|
{"arm", "armv7-a-neon", "cortex-a8", []string{"armeabi-v7a"}},
|
2016-01-15 00:17:19 +01:00
|
|
|
{"arm", "armv7-a-neon", "cortex-a9", []string{"armeabi-v7a"}},
|
2016-01-13 08:07:05 +01:00
|
|
|
{"arm", "armv7-a-neon", "cortex-a15", []string{"armeabi-v7a"}},
|
|
|
|
{"arm", "armv7-a-neon", "cortex-a53", []string{"armeabi-v7a"}},
|
|
|
|
{"arm", "armv7-a-neon", "cortex-a53.a57", []string{"armeabi-v7a"}},
|
2018-09-25 01:33:45 +02:00
|
|
|
{"arm", "armv7-a-neon", "cortex-a72", []string{"armeabi-v7a"}},
|
2017-05-16 00:27:12 +02:00
|
|
|
{"arm", "armv7-a-neon", "cortex-a73", []string{"armeabi-v7a"}},
|
2018-04-24 03:15:25 +02:00
|
|
|
{"arm", "armv7-a-neon", "cortex-a75", []string{"armeabi-v7a"}},
|
2018-10-09 23:27:28 +02:00
|
|
|
{"arm", "armv7-a-neon", "cortex-a76", []string{"armeabi-v7a"}},
|
2016-01-13 08:07:05 +01:00
|
|
|
{"arm", "armv7-a-neon", "krait", []string{"armeabi-v7a"}},
|
2016-08-20 00:14:56 +02:00
|
|
|
{"arm", "armv7-a-neon", "kryo", []string{"armeabi-v7a"}},
|
2018-11-15 16:21:51 +01:00
|
|
|
{"arm", "armv7-a-neon", "kryo385", []string{"armeabi-v7a"}},
|
2017-07-24 00:14:55 +02:00
|
|
|
{"arm", "armv7-a-neon", "exynos-m1", []string{"armeabi-v7a"}},
|
2017-07-21 02:07:47 +02:00
|
|
|
{"arm", "armv7-a-neon", "exynos-m2", []string{"armeabi-v7a"}},
|
2016-01-15 00:17:19 +01:00
|
|
|
{"arm64", "armv8-a", "cortex-a53", []string{"arm64-v8a"}},
|
2018-09-25 01:33:45 +02:00
|
|
|
{"arm64", "armv8-a", "cortex-a72", []string{"arm64-v8a"}},
|
2017-05-16 00:27:12 +02:00
|
|
|
{"arm64", "armv8-a", "cortex-a73", []string{"arm64-v8a"}},
|
2016-08-30 15:56:33 +02:00
|
|
|
{"arm64", "armv8-a", "kryo", []string{"arm64-v8a"}},
|
2017-07-24 00:14:55 +02:00
|
|
|
{"arm64", "armv8-a", "exynos-m1", []string{"arm64-v8a"}},
|
2017-07-21 02:07:47 +02:00
|
|
|
{"arm64", "armv8-a", "exynos-m2", []string{"arm64-v8a"}},
|
2018-04-24 03:15:25 +02:00
|
|
|
{"arm64", "armv8-2a", "cortex-a75", []string{"arm64-v8a"}},
|
2018-10-09 23:27:28 +02:00
|
|
|
{"arm64", "armv8-2a", "cortex-a76", []string{"arm64-v8a"}},
|
2018-11-15 16:21:51 +01:00
|
|
|
{"arm64", "armv8-2a", "kryo385", []string{"arm64-v8a"}},
|
2016-01-14 08:25:19 +01:00
|
|
|
{"mips", "mips32-fp", "", []string{"mips"}},
|
|
|
|
{"mips", "mips32r2-fp", "", []string{"mips"}},
|
|
|
|
{"mips", "mips32r2-fp-xburst", "", []string{"mips"}},
|
2016-07-20 06:37:28 +02:00
|
|
|
//{"mips", "mips32r6", "", []string{"mips"}},
|
2017-04-27 04:10:34 +02:00
|
|
|
{"mips", "mips32r2dsp-fp", "", []string{"mips"}},
|
|
|
|
{"mips", "mips32r2dspr2-fp", "", []string{"mips"}},
|
2016-01-13 08:07:05 +01:00
|
|
|
// mips64r2 is mismatching 64r2 and 64r6 libraries during linking to libgcc
|
|
|
|
//{"mips64", "mips64r2", "", []string{"mips64"}},
|
|
|
|
{"mips64", "mips64r6", "", []string{"mips64"}},
|
|
|
|
{"x86", "", "", []string{"x86"}},
|
|
|
|
{"x86", "atom", "", []string{"x86"}},
|
|
|
|
{"x86", "haswell", "", []string{"x86"}},
|
|
|
|
{"x86", "ivybridge", "", []string{"x86"}},
|
|
|
|
{"x86", "sandybridge", "", []string{"x86"}},
|
|
|
|
{"x86", "silvermont", "", []string{"x86"}},
|
2016-05-10 23:30:51 +02:00
|
|
|
{"x86", "x86_64", "", []string{"x86"}},
|
2016-01-13 08:07:05 +01:00
|
|
|
{"x86_64", "", "", []string{"x86_64"}},
|
|
|
|
{"x86_64", "haswell", "", []string{"x86_64"}},
|
|
|
|
{"x86_64", "ivybridge", "", []string{"x86_64"}},
|
|
|
|
{"x86_64", "sandybridge", "", []string{"x86_64"}},
|
|
|
|
{"x86_64", "silvermont", "", []string{"x86_64"}},
|
|
|
|
}
|
2016-10-19 23:04:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func getNdkAbisConfig() []archConfig {
|
|
|
|
return []archConfig{
|
2019-01-24 07:31:26 +01:00
|
|
|
{"arm", "armv7-a-neon", "", []string{"armeabi"}},
|
2016-10-19 23:04:41 +02:00
|
|
|
{"arm64", "armv8-a", "", []string{"arm64-v8a"}},
|
|
|
|
{"x86", "", "", []string{"x86"}},
|
|
|
|
{"x86_64", "", "", []string{"x86_64"}},
|
|
|
|
}
|
|
|
|
}
|
2016-01-13 08:07:05 +01:00
|
|
|
|
2019-01-12 04:02:16 +01:00
|
|
|
func decodeArchSettings(os OsType, archConfigs []archConfig) ([]Target, error) {
|
2016-06-02 02:09:44 +02:00
|
|
|
var ret []Target
|
2016-01-13 08:07:05 +01:00
|
|
|
|
2016-10-19 23:04:41 +02:00
|
|
|
for _, config := range archConfigs {
|
2019-01-12 04:02:16 +01:00
|
|
|
arch, err := decodeArch(os, config.arch, &config.archVariant,
|
2019-01-31 23:31:51 +01:00
|
|
|
&config.cpuVariant, config.abi)
|
2016-01-13 08:07:05 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2016-06-01 01:27:00 +02:00
|
|
|
arch.Native = false
|
2016-06-02 02:09:44 +02:00
|
|
|
ret = append(ret, Target{
|
|
|
|
Os: Android,
|
|
|
|
Arch: arch,
|
|
|
|
})
|
2016-01-13 08:07:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret, nil
|
|
|
|
}
|
|
|
|
|
2015-09-17 23:33:42 +02:00
|
|
|
// Convert a set of strings from product variables into a single Arch struct
|
2019-01-31 23:31:51 +01:00
|
|
|
func decodeArch(os OsType, arch string, archVariant, cpuVariant *string, abi []string) (Arch, error) {
|
2015-09-17 23:33:42 +02:00
|
|
|
stringPtr := func(p *string) string {
|
|
|
|
if p != nil {
|
|
|
|
return *p
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2015-11-20 22:07:51 +01:00
|
|
|
archType, ok := archTypeMap[arch]
|
|
|
|
if !ok {
|
|
|
|
return Arch{}, fmt.Errorf("unknown arch %q", arch)
|
|
|
|
}
|
2015-09-17 23:33:42 +02:00
|
|
|
|
2015-11-20 22:07:51 +01:00
|
|
|
a := Arch{
|
2015-09-17 23:33:42 +02:00
|
|
|
ArchType: archType,
|
|
|
|
ArchVariant: stringPtr(archVariant),
|
|
|
|
CpuVariant: stringPtr(cpuVariant),
|
2019-01-31 23:31:51 +01:00
|
|
|
Abi: abi,
|
2016-06-01 01:27:00 +02:00
|
|
|
Native: true,
|
2015-11-20 22:07:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if a.ArchVariant == a.ArchType.Name || a.ArchVariant == "generic" {
|
|
|
|
a.ArchVariant = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
if a.CpuVariant == a.ArchType.Name || a.CpuVariant == "generic" {
|
|
|
|
a.CpuVariant = ""
|
|
|
|
}
|
|
|
|
|
|
|
|
for i := 0; i < len(a.Abi); i++ {
|
|
|
|
if a.Abi[i] == "" {
|
|
|
|
a.Abi = append(a.Abi[:i], a.Abi[i+1:]...)
|
|
|
|
i--
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-12 04:02:16 +01:00
|
|
|
if a.ArchVariant == "" {
|
|
|
|
if featureMap, ok := defaultArchFeatureMap[os]; ok {
|
|
|
|
a.ArchFeatures = featureMap[archType]
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if featureMap, ok := archFeatureMap[archType]; ok {
|
|
|
|
a.ArchFeatures = featureMap[a.ArchVariant]
|
|
|
|
}
|
2015-11-21 00:35:00 +01:00
|
|
|
}
|
|
|
|
|
2015-11-20 22:07:51 +01:00
|
|
|
return a, nil
|
2015-09-17 23:33:42 +02:00
|
|
|
}
|
|
|
|
|
2016-09-06 19:39:07 +02:00
|
|
|
func filterMultilibTargets(targets []Target, multilib string) []Target {
|
|
|
|
var ret []Target
|
|
|
|
for _, t := range targets {
|
|
|
|
if t.Arch.ArchType.Multilib == multilib {
|
|
|
|
ret = append(ret, t)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2017-02-27 19:12:13 +01:00
|
|
|
func getCommonTargets(targets []Target) []Target {
|
|
|
|
var ret []Target
|
|
|
|
set := make(map[string]bool)
|
|
|
|
|
|
|
|
for _, t := range targets {
|
|
|
|
if _, found := set[t.Os.String()]; !found {
|
|
|
|
set[t.Os.String()] = true
|
|
|
|
ret = append(ret, commonTargetMap[t.Os.String()])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2018-09-06 19:19:57 +02:00
|
|
|
func firstTarget(targets []Target, filters ...string) []Target {
|
2017-12-05 22:42:45 +01:00
|
|
|
for _, filter := range filters {
|
|
|
|
buildTargets := filterMultilibTargets(targets, filter)
|
|
|
|
if len(buildTargets) > 0 {
|
2018-09-06 19:19:57 +02:00
|
|
|
return buildTargets[:1]
|
2017-12-05 22:42:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
// Use the module multilib setting to select one or more targets from a target list
|
2018-10-03 07:01:37 +02:00
|
|
|
func decodeMultilibTargets(multilib string, targets []Target, prefer32 bool) ([]Target, error) {
|
2016-06-02 02:09:44 +02:00
|
|
|
buildTargets := []Target{}
|
2017-12-05 22:42:45 +01:00
|
|
|
|
|
|
|
switch multilib {
|
|
|
|
case "common":
|
|
|
|
buildTargets = getCommonTargets(targets)
|
|
|
|
case "common_first":
|
|
|
|
buildTargets = getCommonTargets(targets)
|
2016-09-13 18:59:14 +02:00
|
|
|
if prefer32 {
|
2018-09-06 19:19:57 +02:00
|
|
|
buildTargets = append(buildTargets, firstTarget(targets, "lib32", "lib64")...)
|
2016-09-13 18:59:14 +02:00
|
|
|
} else {
|
2018-09-06 19:19:57 +02:00
|
|
|
buildTargets = append(buildTargets, firstTarget(targets, "lib64", "lib32")...)
|
2016-09-13 18:59:14 +02:00
|
|
|
}
|
2015-09-17 23:33:42 +02:00
|
|
|
case "both":
|
2016-09-13 18:59:14 +02:00
|
|
|
if prefer32 {
|
|
|
|
buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib32")...)
|
|
|
|
buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib64")...)
|
|
|
|
} else {
|
|
|
|
buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib64")...)
|
|
|
|
buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib32")...)
|
|
|
|
}
|
2015-09-17 23:33:42 +02:00
|
|
|
case "32":
|
2016-09-06 19:39:07 +02:00
|
|
|
buildTargets = filterMultilibTargets(targets, "lib32")
|
2015-09-17 23:33:42 +02:00
|
|
|
case "64":
|
2016-09-06 19:39:07 +02:00
|
|
|
buildTargets = filterMultilibTargets(targets, "lib64")
|
2017-12-05 22:42:45 +01:00
|
|
|
case "first":
|
|
|
|
if prefer32 {
|
2018-09-06 19:19:57 +02:00
|
|
|
buildTargets = firstTarget(targets, "lib32", "lib64")
|
2017-12-05 22:42:45 +01:00
|
|
|
} else {
|
2018-09-06 19:19:57 +02:00
|
|
|
buildTargets = firstTarget(targets, "lib64", "lib32")
|
2016-09-13 18:59:14 +02:00
|
|
|
}
|
2017-12-05 22:42:45 +01:00
|
|
|
case "prefer32":
|
2018-09-06 19:19:57 +02:00
|
|
|
buildTargets = filterMultilibTargets(targets, "lib32")
|
|
|
|
if len(buildTargets) == 0 {
|
|
|
|
buildTargets = filterMultilibTargets(targets, "lib64")
|
|
|
|
}
|
2015-09-17 23:33:42 +02:00
|
|
|
default:
|
2016-09-06 19:39:07 +02:00
|
|
|
return nil, fmt.Errorf(`compile_multilib must be "both", "first", "32", "64", or "prefer32" found %q`,
|
2015-09-17 23:33:42 +02:00
|
|
|
multilib)
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:09:44 +02:00
|
|
|
return buildTargets, nil
|
2015-09-17 23:33:42 +02:00
|
|
|
}
|