blob: a0fbdbe3b9385f3572ff5bb3aec99087768931d7 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001inherit cross
2
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08003PROVIDES = "virtual/${TUNE_PKGARCH}-go"
Brad Bishop316dfdd2018-06-25 12:45:53 -04004DEPENDS = "go-native"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08006PN = "go-cross-${TUNE_PKGARCH}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05007
Brad Bishopc8f47122019-06-24 09:36:18 -04008export GOCACHE = "${B}/.cache"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05009CC = "${@d.getVar('BUILD_CC').strip()}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010
Brad Bishopd7bf8c12018-02-25 22:55:05 -050011do_configure[noexec] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050012
Brad Bishopd7bf8c12018-02-25 22:55:05 -050013do_compile() {
Andrew Geissler82c905d2020-04-13 13:39:40 -050014 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}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040016 cd src
17 ./make.bash --host-only --no-banner
18 cd ${B}
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019}
Brad Bishop316dfdd2018-06-25 12:45:53 -040020do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050021
22make_wrapper() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040023 rm -f ${D}${bindir}/$2
24 cat <<END >${D}${bindir}/$2
Brad Bishopd7bf8c12018-02-25 22:55:05 -050025#!/bin/bash
26here=\`dirname \$0\`
27export GOARCH="${TARGET_GOARCH}"
28export GOOS="${TARGET_GOOS}"
29export GOARM="\${GOARM:-${TARGET_GOARM}}"
30export GO386="\${GO386:-${TARGET_GO386}}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040031export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050032\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
33END
Brad Bishop316dfdd2018-06-25 12:45:53 -040034 chmod +x ${D}${bindir}/$2
Brad Bishopd7bf8c12018-02-25 22:55:05 -050035}
36
37do_install() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040038 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
Brad Bishopd7bf8c12018-02-25 22:55:05 -050052}