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