blob: 3d5803bf07ae5ae691c0c772490fc229e8aadcdf [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[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg"
21do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050022
23make_wrapper() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040024 rm -f ${D}${bindir}/$2
25 cat <<END >${D}${bindir}/$2
Brad Bishopd7bf8c12018-02-25 22:55:05 -050026#!/bin/bash
27here=\`dirname \$0\`
28export GOARCH="${TARGET_GOARCH}"
29export GOOS="${TARGET_GOOS}"
30export GOARM="\${GOARM:-${TARGET_GOARM}}"
31export GO386="\${GO386:-${TARGET_GO386}}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040032export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050033\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
34END
Brad Bishop316dfdd2018-06-25 12:45:53 -040035 chmod +x ${D}${bindir}/$2
Brad Bishopd7bf8c12018-02-25 22:55:05 -050036}
37
38do_install() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040039 install -d ${D}${libdir}/go
40 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
41 install -d ${D}${libdir}/go/src
42 (cd ${S}/src; for d in *; do \
43 [ ! -d $d ] || cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \
44 done)
45 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
46 install -d ${D}${bindir} ${D}${libdir}/go/bin
47 for f in ${B}/bin/*
48 do
49 base=`basename $f`
50 install -m755 $f ${D}${libdir}/go/bin
51 make_wrapper $base ${TARGET_PREFIX}$base
52 done
Brad Bishopd7bf8c12018-02-25 22:55:05 -050053}