1inherit cross 2 3PROVIDES = "virtual/${TUNE_PKGARCH}-go" 4DEPENDS = "go-native" 5 6PN = "go-cross-${TUNE_PKGARCH}" 7 8export GOCACHE = "${B}/.cache" 9CC = "${@d.getVar('BUILD_CC').strip()}" 10 11do_configure[noexec] = "1" 12 13do_compile() { 14 export CC_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" 15 export CXX_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" 16 cd src 17 ./make.bash --host-only --no-banner 18 cd ${B} 19} 20do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" 21 22make_wrapper() { 23 rm -f ${D}${bindir}/$2 24 cat <<END >${D}${bindir}/$2 25#!/bin/bash 26here=\`dirname \$0\` 27export GOARCH="${TARGET_GOARCH}" 28export GOOS="${TARGET_GOOS}" 29export GOARM="\${GOARM:-${TARGET_GOARM}}" 30export GO386="\${GO386:-${TARGET_GO386}}" 31export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}" 32\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@" 33END 34 chmod +x ${D}${bindir}/$2 35} 36 37do_install() { 38 install -d ${D}${libdir}/go 39 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/ 40 install -d ${D}${libdir}/go/src 41 (cd ${S}/src; for d in *; do \ 42 [ ! -d $d ] || cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \ 43 done) 44 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; 45 install -d ${D}${bindir} ${D}${libdir}/go/bin 46 for f in ${B}/bin/* 47 do 48 base=`basename $f` 49 install -m755 $f ${D}${libdir}/go/bin 50 make_wrapper $base ${TARGET_PREFIX}$base 51 done 52} 53