1DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" 2DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go go-native" 3 4DEBUG_PREFIX_MAP = "\ 5 -fdebug-prefix-map=${STAGING_DIR_HOST}= \ 6 -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ 7" 8 9export CGO_CFLAGS = "${CFLAGS}" 10export CGO_CPPFLAGS = "${CPPFLAGS}" 11export CGO_CXXFLAGS = "${CXXFLAGS}" 12# Filter out -fdebug-prefix-map options as they clash with the GO's build system 13export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }" 14 15export GOCACHE = "${B}/.cache" 16export GO_LDFLAGS = "" 17export GOBUILDFLAGS = "-gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH -trimpath" 18CC:append:class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}" 19 20do_configure[noexec] = "1" 21 22do_compile() { 23 export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}" 24 export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}" 25 26 cd src 27 ./make.bash --target-only --no-banner 28 cd ${B} 29} 30do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" 31 32do_install() { 33 install -d ${D}${libdir}/go/pkg/tool 34 cp --preserve=mode,timestamps -R ${B}/pkg/tool/${TARGET_GOTUPLE} ${D}${libdir}/go/pkg/tool/ 35 install -d ${D}${libdir}/go/src 36 cp --preserve=mode,timestamps -R ${S}/src/cmd ${D}${libdir}/go/src/ 37 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; 38 install -d ${D}${libdir}/go/bin 39 install -d ${D}${bindir} 40 for f in ${B}/${GO_BUILD_BINDIR}/*; do 41 name=`basename $f` 42 install -m 0755 $f ${D}${libdir}/go/bin/ 43 ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/ 44 done 45 rm -rf ${D}${libdir}/go/src 46} 47 48PACKAGES = "${PN} ${PN}-dev" 49FILES:${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}" 50RDEPENDS:${PN} = "go-runtime" 51INSANE_SKIP:${PN} = "ldflags" 52 53BBCLASSEXTEND = "nativesdk" 54