blob: 663c9ffc3d7be237049f45bc9088217aab508f86 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001BUILD_GOOS = "${@go_map_os(d.getVar('BUILD_OS'), d)}"
2BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05003BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05004HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}"
5HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}"
6HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
7HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05009TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}"
10TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}"
11TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
12TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050014GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}"
15
16# Go supports dynamic linking on a limited set of architectures.
17# See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go
18GO_DYNLINK = ""
19GO_DYNLINK_arm = "1"
20GO_DYNLINK_aarch64 = "1"
21GO_DYNLINK_x86 = "1"
22GO_DYNLINK_x86-64 = "1"
23GO_DYNLINK_powerpc64 = "1"
24GO_DYNLINK_class-native = ""
25
26# define here because everybody inherits this class
27#
28COMPATIBLE_HOST_linux-gnux32 = "null"
29COMPATIBLE_HOST_linux-muslx32 = "null"
30COMPATIBLE_HOST_powerpc = "null"
31COMPATIBLE_HOST_powerpc64 = "null"
32COMPATIBLE_HOST_mipsarchn32 = "null"
33ARM_INSTRUCTION_SET = "arm"
34TUNE_CCARGS_remove = "-march=mips32r2"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050035
36def go_map_arch(a, d):
37 import re
38 if re.match('i.86', a):
39 return '386'
40 elif a == 'x86_64':
41 return 'amd64'
42 elif re.match('arm.*', a):
43 return 'arm'
44 elif re.match('aarch64.*', a):
45 return 'arm64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050046 elif re.match('mips64el.*', a):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050047 return 'mips64le'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050048 elif re.match('mips64.*', a):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050049 return 'mips64'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050050 elif a == 'mips':
Brad Bishop6e60e8b2018-02-01 10:27:11 -050051 return 'mips'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050052 elif a == 'mipsel':
53 return 'mipsle'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054 elif re.match('p(pc|owerpc)(64)', a):
55 return 'ppc64'
56 elif re.match('p(pc|owerpc)(64el)', a):
57 return 'ppc64le'
58 else:
59 raise bb.parse.SkipPackage("Unsupported CPU architecture: %s" % a)
60
61def go_map_arm(a, f, d):
62 import re
63 if re.match('arm.*', a):
64 if 'armv7' in f:
65 return '7'
66 elif 'armv6' in f:
67 return '6'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050068 elif 'armv5' in f:
69 return '5'
70 return ''
71
72def go_map_386(a, f, d):
73 import re
74 if re.match('i.86', a):
75 if ('core2' in f) or ('corei7' in f):
76 return 'sse2'
77 else:
78 return '387'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050079 return ''
80
81def go_map_os(o, d):
82 if o.startswith('linux'):
83 return 'linux'
84 return o
85
86