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