Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | BUILD_GOOS = "${@go_map_os(d.getVar('BUILD_OS'), d)}" |
| 2 | BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 3 | BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 4 | HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}" |
| 5 | HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}" |
| 6 | HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
| 7 | HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8 | HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9 | TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}" |
| 10 | TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}" |
| 11 | TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
| 12 | TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 13 | TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 14 | GO_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 |
| 18 | GO_DYNLINK = "" |
| 19 | GO_DYNLINK_arm = "1" |
| 20 | GO_DYNLINK_aarch64 = "1" |
| 21 | GO_DYNLINK_x86 = "1" |
| 22 | GO_DYNLINK_x86-64 = "1" |
| 23 | GO_DYNLINK_powerpc64 = "1" |
| 24 | GO_DYNLINK_class-native = "" |
| 25 | |
| 26 | # define here because everybody inherits this class |
| 27 | # |
| 28 | COMPATIBLE_HOST_linux-gnux32 = "null" |
| 29 | COMPATIBLE_HOST_linux-muslx32 = "null" |
| 30 | COMPATIBLE_HOST_powerpc = "null" |
| 31 | COMPATIBLE_HOST_powerpc64 = "null" |
| 32 | COMPATIBLE_HOST_mipsarchn32 = "null" |
| 33 | ARM_INSTRUCTION_SET = "arm" |
| 34 | TUNE_CCARGS_remove = "-march=mips32r2" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 35 | |
| 36 | def 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 46 | elif re.match('mips64el.*', a): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 47 | return 'mips64le' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 48 | elif re.match('mips64.*', a): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 49 | return 'mips64' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 50 | elif a == 'mips': |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 51 | return 'mips' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 52 | elif a == 'mipsel': |
| 53 | return 'mipsle' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 54 | 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 | |
| 61 | def 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 68 | elif 'armv5' in f: |
| 69 | return '5' |
| 70 | return '' |
| 71 | |
| 72 | def 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 79 | return '' |
| 80 | |
| 81 | def go_map_os(o, d): |
| 82 | if o.startswith('linux'): |
| 83 | return 'linux' |
| 84 | return o |
| 85 | |
| 86 | |