blob: cd23cca2fe3fab32266b24d0693bc56d8d6d08f4 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001inherit crosssdk
2
3DEPENDS = "go-native virtual/${TARGET_PREFIX}gcc-crosssdk virtual/nativesdk-${TARGET_PREFIX}compilerlibs virtual/${TARGET_PREFIX}binutils-crosssdk"
Brad Bishop19323692019-04-05 15:28:33 -04004PN = "go-crosssdk-${SDK_SYS}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005PROVIDES = "virtual/${TARGET_PREFIX}go-crosssdk"
6
Brad Bishopd7bf8c12018-02-25 22:55:05 -05007do_configure[noexec] = "1"
8
9do_compile() {
Andrew Geissler82c905d2020-04-13 13:39:40 -050010 export CC_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}"
11 export CXX_FOR_${TARGET_GOTUPLE}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012 cd src
Brad Bishop316dfdd2018-06-25 12:45:53 -040013 ./make.bash --host-only --no-banner
Brad Bishopd7bf8c12018-02-25 22:55:05 -050014 cd ${B}
15}
Brad Bishop316dfdd2018-06-25 12:45:53 -040016do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050017
18make_wrapper() {
19 rm -f ${D}${bindir}/$2
20 cat <<END >${D}${bindir}/$2
21#!/bin/bash
22here=\`dirname \$0\`
23export GOARCH="${TARGET_GOARCH}"
24export GOOS="${TARGET_GOOS}"
25\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
26END
27 chmod +x ${D}${bindir}/$2
28}
29
30do_install() {
31 install -d ${D}${libdir}/go
32 install -d ${D}${libdir}/go/bin
33 install -d ${D}${libdir}/go/pkg/tool
34 install -d ${D}${bindir}
35 cp --preserve=mode,timestamps -R ${S}/pkg/tool/${BUILD_GOTUPLE} ${D}${libdir}/go/pkg/tool/
36 for f in ${B}/bin/*
37 do
38 base=`basename $f`
39 install -m755 $f ${D}${libdir}/go/bin
40 make_wrapper $base ${TARGET_PREFIX}$base
41 done
42}