Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | inherit cross-canadian |
| 2 | |
| 3 | DEPENDS = "go-native virtual/${HOST_PREFIX}go-crosssdk virtual/nativesdk-${HOST_PREFIX}go-runtime \ |
| 4 | virtual/${HOST_PREFIX}gcc-crosssdk virtual/nativesdk-${HOST_PREFIX}libc-for-gcc \ |
| 5 | virtual/nativesdk-${HOST_PREFIX}compilerlibs" |
| 6 | PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}" |
| 7 | |
| 8 | export GOHOSTOS = "${BUILD_GOOS}" |
| 9 | export GOHOSTARCH = "${BUILD_GOARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10 | export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" |
| 11 | export GOTOOLDIR_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/${HOST_SYS}/go/pkg/tool/${BUILD_GOTUPLE}" |
| 12 | export GOROOT_FINAL = "${libdir}/go" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 13 | export CGO_CFLAGS = "${CFLAGS}" |
| 14 | export CGO_LDFLAGS = "${LDFLAGS}" |
| 15 | export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "--sysroot=${STAGING_DIR_HOST} ${SECURITY_NOPIE_CFLAGS} ${HOST_CC_ARCH} ${LDFLAGS}"' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | |
| 17 | do_configure[noexec] = "1" |
| 18 | |
| 19 | do_compile() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 20 | export CC_FOR_${HOST_GOOS}_${HOST_GOARCH}="${HOST_PREFIX}gcc --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}" |
| 21 | export CXX_FOR_${HOST_GOOS}_${HOST_GOARCH}="${HOST_PREFIX}gxx --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 22 | cd src |
| 23 | ./make.bash --host-only --no-banner |
| 24 | cd ${B} |
| 25 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 26 | do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" |
| 27 | do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 28 | |
| 29 | |
| 30 | make_wrapper() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | rm -f ${D}${bindir}/$2 |
| 32 | cat <<END >${D}${bindir}/$2 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 33 | #!/bin/sh |
| 34 | here=\`dirname \$0\` |
| 35 | native_goroot=\`readlink -f \$here/../../lib/${TARGET_SYS}/go\` |
| 36 | export GOARCH="${TARGET_GOARCH}" |
| 37 | export GOOS="${TARGET_GOOS}" |
| 38 | test -n "\$GOARM" || export GOARM="${TARGET_GOARM}" |
| 39 | test -n "\$GO386" || export GO386="${TARGET_GO386}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | test -n "\$GOMIPS" || export GOMIPS="${TARGET_GOMIPS}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 41 | export GOTOOLDIR="\$native_goroot/pkg/tool/${HOST_GOTUPLE}" |
| 42 | test -n "\$GOROOT" || export GOROOT="\$OECORE_TARGET_SYSROOT/${target_libdir}/go" |
| 43 | \$here/../../lib/${TARGET_SYS}/go/bin/$1 "\$@" |
| 44 | END |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 45 | chmod +x ${D}${bindir}/$2 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | do_install() { |
| 49 | install -d ${D}${libdir}/go/pkg/tool |
| 50 | cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE} ${D}${libdir}/go/pkg/tool/ |
| 51 | install -d ${D}${bindir} ${D}${libdir}/go/bin |
| 52 | for f in ${B}/${GO_BUILD_BINDIR}/* |
| 53 | do |
| 54 | base=`basename $f` |
| 55 | install -m755 $f ${D}${libdir}/go/bin |
| 56 | make_wrapper $base ${TARGET_PREFIX}$base |
| 57 | done |
| 58 | } |