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