Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | inherit cross |
| 2 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 3 | PROVIDES = "virtual/${TUNE_PKGARCH}-go" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 4 | DEPENDS = "go-native" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 5 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 6 | PN = "go-cross-${TUNE_PKGARCH}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 7 | |
Brad Bishop | c8f4712 | 2019-06-24 09:36:18 -0400 | [diff] [blame] | 8 | export GOCACHE = "${B}/.cache" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 9 | CC = "${@d.getVar('BUILD_CC').strip()}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 11 | do_configure[noexec] = "1" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 12 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 13 | do_compile() { |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 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}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 16 | cd src |
| 17 | ./make.bash --host-only --no-banner |
| 18 | cd ${B} |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 19 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 20 | do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 21 | |
| 22 | make_wrapper() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 23 | rm -f ${D}${bindir}/$2 |
| 24 | cat <<END >${D}${bindir}/$2 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 25 | #!/bin/bash |
| 26 | here=\`dirname \$0\` |
| 27 | export GOARCH="${TARGET_GOARCH}" |
| 28 | export GOOS="${TARGET_GOOS}" |
| 29 | export GOARM="\${GOARM:-${TARGET_GOARM}}" |
| 30 | export GO386="\${GO386:-${TARGET_GO386}}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 32 | \$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@" |
| 33 | END |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 34 | chmod +x ${D}${bindir}/$2 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | do_install() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 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 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 52 | } |