1DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" 2DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk" 3PROVIDES = "virtual/${TARGET_PREFIX}go-runtime" 4 5DEBUG_PREFIX_MAP = "\ 6 -fdebug-prefix-map=${STAGING_DIR_HOST}= \ 7 -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ 8" 9 10export CGO_CFLAGS = "${CFLAGS}" 11export CGO_CPPFLAGS = "${CPPFLAGS}" 12export CGO_CXXFLAGS = "${CXXFLAGS}" 13# Filter out -fdebug-prefix-map options as they clash with the GO's build system 14export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }" 15export GOCACHE = "${B}/.cache" 16 17GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}" 18GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"' 19 20do_configure() { 21 : 22} 23 24do_configure:libc-musl() { 25 rm -f ${S}/src/runtime/race/*.syso 26} 27 28do_compile() { 29 export CC_FOR_${TARGET_GOTUPLE}="${CC}" 30 export CXX_FOR_${TARGET_GOTUPLE}="${CXX}" 31 32 cd src 33 ./make.bash --target-only --no-banner std 34 if [ -n "${GO_DYNLINK}" ]; then 35 export GOTOOLDIR="${B}/pkg/tool/native_native" 36 CC="$CC_FOR_${TARGET_GOTUPLE}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \ 37 $GOTOOLDIR/go_bootstrap install -linkshared -buildmode=shared ${GO_SHLIB_LDFLAGS} std 38 fi 39 cd ${B} 40} 41do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" 42 43do_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 53 find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do 54 cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/ 55 done 56 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; 57 rm -f ${D}${libdir}/go/src/cmd/dist/dist 58 rm -f ${D}${libdir}/go/src/cmd/cgo/zdefaultcc.go 59 rm -f ${D}${libdir}/go/src/cmd/go/internal/cfg/zdefaultcc.go 60 61} 62 63ALLOW_EMPTY:${PN} = "1" 64FILES:${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}" 65FILES:${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \ 66 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.shlibname \ 67 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.shlibname \ 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/*.a \ 74 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.a \ 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" 81FILES:${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE}" 82 83# Go sources include some scripts and pre-built binaries for 84# multiple architectures. The static .a files for dynamically-linked 85# runtime are also required in -dev. 86INSANE_SKIP:${PN}-dev = "staticdev file-rdeps arch" 87 88INHIBIT_PACKAGE_STRIP = "1" 89INHIBIT_PACKAGE_DEBUG_SPLIT = "1" 90INHIBIT_SYSROOT_STRIP = "1" 91 92BBCLASSEXTEND = "nativesdk" 93