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}" |
| 10 | export GOHOSTOS_CROSS = "${HOST_GOOS}" |
| 11 | export GOHOSTARCH_CROSS = "${HOST_GOARCH}" |
| 12 | export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" |
| 13 | export GOTOOLDIR_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/${HOST_SYS}/go/pkg/tool/${BUILD_GOTUPLE}" |
| 14 | export GOROOT_FINAL = "${libdir}/go" |
| 15 | export CGO_ENABLED = "1" |
| 16 | export CC_FOR_TARGET = "${TARGET_PREFIX}gcc" |
| 17 | export CXX_FOR_TARGET = "${TARGET_PREFIX}g++" |
| 18 | CC = "${HOST_PREFIX}gcc" |
| 19 | export CGO_CFLAGS = "--sysroot=${STAGING_DIR_TARGET} ${HOST_CC_ARCH} ${CFLAGS}" |
| 20 | export CGO_LDFLAGS = "--sysroot=${STAGING_DIR_TARGET} ${HOST_CC_ARCH} ${LDFLAGS}" |
| 21 | export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "--sysroot=${STAGING_DIR_TARGET} ${HOST_CC_ARCH} ${LDFLAGS}"' |
| 22 | |
| 23 | do_configure[noexec] = "1" |
| 24 | |
| 25 | do_compile() { |
| 26 | export GOBIN="${B}/bin" |
| 27 | rm -rf ${GOBIN} ${B}/pkg |
| 28 | mkdir ${GOBIN} |
| 29 | cd src |
| 30 | ./make.bash --host-only --no-banner |
| 31 | cd ${B} |
| 32 | } |
| 33 | |
| 34 | |
| 35 | make_wrapper() { |
| 36 | rm -f ${D}${bindir}/$2 |
| 37 | cat <<END >${D}${bindir}/$2 |
| 38 | #!/bin/sh |
| 39 | here=\`dirname \$0\` |
| 40 | native_goroot=\`readlink -f \$here/../../lib/${TARGET_SYS}/go\` |
| 41 | export GOARCH="${TARGET_GOARCH}" |
| 42 | export GOOS="${TARGET_GOOS}" |
| 43 | test -n "\$GOARM" || export GOARM="${TARGET_GOARM}" |
| 44 | test -n "\$GO386" || export GO386="${TARGET_GO386}" |
| 45 | export GOTOOLDIR="\$native_goroot/pkg/tool/${HOST_GOTUPLE}" |
| 46 | test -n "\$GOROOT" || export GOROOT="\$OECORE_TARGET_SYSROOT/${target_libdir}/go" |
| 47 | \$here/../../lib/${TARGET_SYS}/go/bin/$1 "\$@" |
| 48 | END |
| 49 | chmod +x ${D}${bindir}/$2 |
| 50 | } |
| 51 | |
| 52 | do_install() { |
| 53 | install -d ${D}${libdir}/go/pkg/tool |
| 54 | cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE} ${D}${libdir}/go/pkg/tool/ |
| 55 | install -d ${D}${bindir} ${D}${libdir}/go/bin |
| 56 | for f in ${B}/${GO_BUILD_BINDIR}/* |
| 57 | do |
| 58 | base=`basename $f` |
| 59 | install -m755 $f ${D}${libdir}/go/bin |
| 60 | make_wrapper $base ${TARGET_PREFIX}$base |
| 61 | done |
| 62 | } |