Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" |
Andrew Geissler | 028142b | 2023-05-05 11:29:21 -0500 | [diff] [blame] | 2 | DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 3 | PROVIDES = "virtual/${TARGET_PREFIX}go-runtime" |
| 4 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 5 | DEBUG_PREFIX_MAP = "\ |
| 6 | -fdebug-prefix-map=${STAGING_DIR_HOST}= \ |
| 7 | -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ |
| 8 | " |
| 9 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 10 | export CGO_CFLAGS = "${CFLAGS}" |
| 11 | export CGO_CPPFLAGS = "${CPPFLAGS}" |
| 12 | export CGO_CXXFLAGS = "${CXXFLAGS}" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 13 | # Filter out -fdebug-prefix-map options as they clash with the GO's build system |
| 14 | export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }" |
Brad Bishop | c8f4712 | 2019-06-24 09:36:18 -0400 | [diff] [blame] | 15 | export GOCACHE = "${B}/.cache" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 16 | |
| 17 | GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}" |
| 18 | GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 19 | |
| 20 | do_configure() { |
| 21 | : |
| 22 | } |
| 23 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 24 | do_configure:libc-musl() { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 25 | rm -f ${S}/src/runtime/race/*.syso |
| 26 | } |
| 27 | |
| 28 | do_compile() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 29 | export CC_FOR_${TARGET_GOTUPLE}="${CC}" |
| 30 | export CXX_FOR_${TARGET_GOTUPLE}="${CXX}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 32 | cd src |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 33 | ./make.bash --target-only --no-banner std |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 34 | if [ -n "${GO_DYNLINK}" ]; then |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 35 | export GOTOOLDIR="${B}/pkg/tool/native_native" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 36 | CC="$CC_FOR_${TARGET_GOTUPLE}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 37 | $GOTOOLDIR/go_bootstrap install -linkshared -buildmode=shared ${GO_SHLIB_LDFLAGS} std |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 38 | fi |
| 39 | cd ${B} |
| 40 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 41 | do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 42 | |
| 43 | do_install() { |
| 44 | install -d ${D}${libdir}/go/src |
| 45 | cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/ |
| 46 | if [ "${BUILD_GOTUPLE}" != "${TARGET_GOTUPLE}" ]; then |
| 47 | rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE} |
| 48 | rm -rf ${D}${libdir}/go/pkg/obj/${BUILD_GOTUPLE} |
| 49 | fi |
| 50 | rm -rf ${D}${libdir}/go/pkg/tool |
| 51 | rm -rf ${D}${libdir}/go/pkg/obj |
| 52 | rm -rf ${D}${libdir}/go/pkg/bootstrap |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 53 | # the cmd directory is built for the native arch so if BUILD == TARGET |
| 54 | rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE}/cmd |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 55 | find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do |
| 56 | cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/ |
| 57 | done |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 58 | find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 59 | rm -f ${D}${libdir}/go/src/cmd/dist/dist |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 60 | rm -f ${D}${libdir}/go/src/cmd/cgo/zdefaultcc.go |
| 61 | rm -f ${D}${libdir}/go/src/cmd/go/internal/cfg/zdefaultcc.go |
| 62 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 63 | } |
| 64 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 65 | ALLOW_EMPTY:${PN} = "1" |
| 66 | FILES:${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}" |
| 67 | FILES:${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 68 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.shlibname \ |
| 69 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.shlibname \ |
| 70 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.shlibname \ |
| 71 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*.shlibname \ |
| 72 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*.shlibname \ |
| 73 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.shlibname \ |
| 74 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.shlibname \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 75 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.a \ |
| 76 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.a \ |
| 77 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.a \ |
| 78 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*.a \ |
| 79 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*.a \ |
| 80 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.a \ |
| 81 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.a \ |
| 82 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 83 | FILES:${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 84 | |
| 85 | # Go sources include some scripts and pre-built binaries for |
| 86 | # multiple architectures. The static .a files for dynamically-linked |
| 87 | # runtime are also required in -dev. |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 88 | INSANE_SKIP:${PN}-dev = "staticdev file-rdeps arch" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 89 | |
| 90 | INHIBIT_PACKAGE_STRIP = "1" |
| 91 | INHIBIT_PACKAGE_DEBUG_SPLIT = "1" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 92 | INHIBIT_SYSROOT_STRIP = "1" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 93 | |
| 94 | BBCLASSEXTEND = "nativesdk" |