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 \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 4 | virtual/${HOST_PREFIX}gcc-crosssdk virtual/nativesdk-libc \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5 | virtual/nativesdk-${HOST_PREFIX}compilerlibs" |
| 6 | PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}" |
| 7 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 8 | # it uses gcc on build machine during go-cross-canadian bootstrap, but |
| 9 | # the gcc version may be old and not support option '-fmacro-prefix-map' |
| 10 | # which is one of default values of DEBUG_PREFIX_MAP |
| 11 | DEBUG_PREFIX_MAP = "-fdebug-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \ |
| 12 | -fdebug-prefix-map=${STAGING_DIR_HOST}= \ |
| 13 | -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ |
| 14 | " |
| 15 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | export GOHOSTOS = "${BUILD_GOOS}" |
| 17 | export GOHOSTARCH = "${BUILD_GOARCH}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 18 | export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" |
| 19 | export GOTOOLDIR_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/${HOST_SYS}/go/pkg/tool/${BUILD_GOTUPLE}" |
| 20 | export GOROOT_FINAL = "${libdir}/go" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 21 | export CGO_CFLAGS = "${CFLAGS}" |
| 22 | export CGO_LDFLAGS = "${LDFLAGS}" |
| 23 | 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] | 24 | |
| 25 | do_configure[noexec] = "1" |
| 26 | |
| 27 | do_compile() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 28 | export CC_FOR_${HOST_GOOS}_${HOST_GOARCH}="${HOST_PREFIX}gcc --sysroot=${STAGING_DIR_HOST}${SDKPATHNATIVE} ${SECURITY_NOPIE_CFLAGS}" |
| 29 | 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] | 30 | cd src |
| 31 | ./make.bash --host-only --no-banner |
| 32 | cd ${B} |
| 33 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 34 | do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" |
| 35 | do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 36 | |
| 37 | |
| 38 | make_wrapper() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 39 | rm -f ${D}${bindir}/$2 |
| 40 | cat <<END >${D}${bindir}/$2 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 41 | #!/bin/sh |
| 42 | here=\`dirname \$0\` |
| 43 | native_goroot=\`readlink -f \$here/../../lib/${TARGET_SYS}/go\` |
| 44 | export GOARCH="${TARGET_GOARCH}" |
| 45 | export GOOS="${TARGET_GOOS}" |
| 46 | test -n "\$GOARM" || export GOARM="${TARGET_GOARM}" |
| 47 | test -n "\$GO386" || export GO386="${TARGET_GO386}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 48 | test -n "\$GOMIPS" || export GOMIPS="${TARGET_GOMIPS}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 49 | export GOTOOLDIR="\$native_goroot/pkg/tool/${HOST_GOTUPLE}" |
| 50 | test -n "\$GOROOT" || export GOROOT="\$OECORE_TARGET_SYSROOT/${target_libdir}/go" |
| 51 | \$here/../../lib/${TARGET_SYS}/go/bin/$1 "\$@" |
| 52 | END |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 53 | chmod +x ${D}${bindir}/$2 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | do_install() { |
| 57 | install -d ${D}${libdir}/go/pkg/tool |
| 58 | cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE} ${D}${libdir}/go/pkg/tool/ |
| 59 | install -d ${D}${bindir} ${D}${libdir}/go/bin |
| 60 | for f in ${B}/${GO_BUILD_BINDIR}/* |
| 61 | do |
| 62 | base=`basename $f` |
| 63 | install -m755 $f ${D}${libdir}/go/bin |
| 64 | make_wrapper $base ${TARGET_PREFIX}$base |
| 65 | done |
| 66 | } |