1DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" 2DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk" 3PROVIDES = "virtual/${TARGET_PREFIX}go-runtime" 4 5export CGO_CFLAGS = "${CFLAGS}" 6export CGO_CPPFLAGS = "${CPPFLAGS}" 7export CGO_CXXFLAGS = "${CXXFLAGS}" 8export CGO_LDFLAGS = "${LDFLAGS}" 9export GOCACHE = "${B}/.cache" 10 11GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}" 12GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"' 13 14do_configure() { 15 : 16} 17 18do_configure:libc-musl() { 19 rm -f ${S}/src/runtime/race/*.syso 20} 21 22do_compile() { 23 export CC_FOR_${TARGET_GOTUPLE}="${CC}" 24 export CXX_FOR_${TARGET_GOTUPLE}="${CXX}" 25 26 cd src 27 ./make.bash --target-only --no-banner std 28 if [ -n "${GO_DYNLINK}" ]; then 29 export GOTOOLDIR="${B}/pkg/tool/native_native" 30 CC="$CC_FOR_${TARGET_GOTUPLE}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \ 31 $GOTOOLDIR/go_bootstrap install -linkshared -buildmode=shared ${GO_SHLIB_LDFLAGS} std 32 fi 33 cd ${B} 34} 35do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" 36do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" 37 38do_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 51 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; 52 rm -f ${D}${libdir}/go/src/cmd/dist/dist 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 56} 57 58ALLOW_EMPTY:${PN} = "1" 59FILES:${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}" 60FILES:${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \ 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 \ 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" 76FILES:${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE}" 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. 81INSANE_SKIP:${PN}-dev = "staticdev file-rdeps arch" 82 83INHIBIT_PACKAGE_STRIP = "1" 84INHIBIT_PACKAGE_DEBUG_SPLIT = "1" 85INHIBIT_SYSROOT_STRIP = "1" 86 87BBCLASSEXTEND = "nativesdk" 88