1DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" 2DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go" 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 # the cmd directory is built for the native arch so if BUILD == TARGET 54 rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE}/cmd 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 58 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; 59 rm -f ${D}${libdir}/go/src/cmd/dist/dist 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 63} 64 65ALLOW_EMPTY:${PN} = "1" 66FILES:${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}" 67FILES:${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \ 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 \ 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" 83FILES:${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE}" 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. 88INSANE_SKIP:${PN}-dev = "staticdev file-rdeps arch" 89 90INHIBIT_PACKAGE_STRIP = "1" 91INHIBIT_PACKAGE_DEBUG_SPLIT = "1" 92INHIBIT_SYSROOT_STRIP = "1" 93 94BBCLASSEXTEND = "nativesdk" 95