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