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 | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8 | export GOHOSTOS = "${BUILD_GOOS}" |
| 9 | export GOHOSTARCH = "${BUILD_GOARCH}" |
| 10 | export GOOS = "${TARGET_GOOS}" |
| 11 | export GOARCH = "${TARGET_GOARCH}" |
| 12 | export GOARM = "${TARGET_GOARM}" |
| 13 | export GO386 = "${TARGET_GO386}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14 | export GOMIPS = "${TARGET_GOMIPS}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 15 | export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" |
| 16 | export GOROOT_FINAL = "${libdir}/go" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 17 | CC = "${@d.getVar('BUILD_CC').strip()}" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 18 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 19 | do_configure[noexec] = "1" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 20 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 21 | do_compile() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 22 | export CC_FOR_${GOOS}_${GOARCH}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" |
| 23 | export CXX_FOR_${GOOS}_${GOARCh}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" |
| 24 | cd src |
| 25 | ./make.bash --host-only --no-banner |
| 26 | cd ${B} |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 27 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 28 | do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" |
| 29 | do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 30 | |
| 31 | make_wrapper() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 32 | rm -f ${D}${bindir}/$2 |
| 33 | cat <<END >${D}${bindir}/$2 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 34 | #!/bin/bash |
| 35 | here=\`dirname \$0\` |
| 36 | export GOARCH="${TARGET_GOARCH}" |
| 37 | export GOOS="${TARGET_GOOS}" |
| 38 | export GOARM="\${GOARM:-${TARGET_GOARM}}" |
| 39 | export GO386="\${GO386:-${TARGET_GO386}}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 41 | \$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@" |
| 42 | END |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 43 | chmod +x ${D}${bindir}/$2 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | do_install() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 47 | install -d ${D}${libdir}/go |
| 48 | cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/ |
| 49 | install -d ${D}${libdir}/go/src |
| 50 | (cd ${S}/src; for d in *; do \ |
| 51 | [ ! -d $d ] || cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \ |
| 52 | done) |
| 53 | find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; |
| 54 | install -d ${D}${bindir} ${D}${libdir}/go/bin |
| 55 | for f in ${B}/bin/* |
| 56 | do |
| 57 | base=`basename $f` |
| 58 | install -m755 $f ${D}${libdir}/go/bin |
| 59 | make_wrapper $base ${TARGET_PREFIX}$base |
| 60 | done |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 61 | } |