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[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" |
| 21 | do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 22 | |
| 23 | make_wrapper() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 24 | rm -f ${D}${bindir}/$2 |
| 25 | cat <<END >${D}${bindir}/$2 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 26 | #!/bin/bash |
| 27 | here=\`dirname \$0\` |
| 28 | export GOARCH="${TARGET_GOARCH}" |
| 29 | export GOOS="${TARGET_GOOS}" |
| 30 | export GOARM="\${GOARM:-${TARGET_GOARM}}" |
| 31 | export GO386="\${GO386:-${TARGET_GO386}}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 32 | export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 33 | \$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@" |
| 34 | END |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 35 | chmod +x ${D}${bindir}/$2 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | do_install() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 39 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 53 | } |