Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | inherit crosssdk |
| 2 | |
| 3 | DEPENDS = "go-native virtual/${TARGET_PREFIX}gcc-crosssdk virtual/nativesdk-${TARGET_PREFIX}compilerlibs virtual/${TARGET_PREFIX}binutils-crosssdk" |
| 4 | PN = "go-crosssdk-${TARGET_ARCH}" |
| 5 | PROVIDES = "virtual/${TARGET_PREFIX}go-crosssdk" |
| 6 | |
| 7 | export GOHOSTOS = "${BUILD_GOOS}" |
| 8 | export GOHOSTARCH = "${BUILD_GOARCH}" |
| 9 | export GOOS = "${TARGET_GOOS}" |
| 10 | export GOARCH = "${TARGET_GOARCH}" |
| 11 | export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" |
| 12 | export GOROOT_FINAL = "${libdir}/go" |
| 13 | export CGO_ENABLED = "1" |
| 14 | export CC_FOR_TARGET="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}" |
| 15 | export CXX_FOR_TARGET="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}" |
| 16 | export GO_INSTALL = "cmd" |
| 17 | CC = "${@d.getVar('BUILD_CC').strip()}" |
| 18 | |
| 19 | do_configure[noexec] = "1" |
| 20 | |
| 21 | do_compile() { |
| 22 | export GOBIN="${B}/bin" |
| 23 | rm -rf ${GOBIN} ${B}/pkg |
| 24 | mkdir ${GOBIN} |
| 25 | cd src |
| 26 | ./make.bash --host-only |
| 27 | cd ${B} |
| 28 | } |
| 29 | |
| 30 | make_wrapper() { |
| 31 | rm -f ${D}${bindir}/$2 |
| 32 | cat <<END >${D}${bindir}/$2 |
| 33 | #!/bin/bash |
| 34 | here=\`dirname \$0\` |
| 35 | export GOARCH="${TARGET_GOARCH}" |
| 36 | export GOOS="${TARGET_GOOS}" |
| 37 | \$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@" |
| 38 | END |
| 39 | chmod +x ${D}${bindir}/$2 |
| 40 | } |
| 41 | |
| 42 | do_install() { |
| 43 | install -d ${D}${libdir}/go |
| 44 | install -d ${D}${libdir}/go/bin |
| 45 | install -d ${D}${libdir}/go/pkg/tool |
| 46 | install -d ${D}${bindir} |
| 47 | cp --preserve=mode,timestamps -R ${S}/pkg/tool/${BUILD_GOTUPLE} ${D}${libdir}/go/pkg/tool/ |
| 48 | for f in ${B}/bin/* |
| 49 | do |
| 50 | base=`basename $f` |
| 51 | install -m755 $f ${D}${libdir}/go/bin |
| 52 | make_wrapper $base ${TARGET_PREFIX}$base |
| 53 | done |
| 54 | } |