blob: b0d487ae1c21831c29e10be97108df7f9a50a6d8 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
Patrick Williams213cb262021-08-07 19:21:33 -05002DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk go-native"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05003
Andrew Geissler595f6302022-01-24 19:11:47 +00004DEBUG_PREFIX_MAP = "\
5 -fdebug-prefix-map=${STAGING_DIR_HOST}= \
6 -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \
7"
8
9export CGO_CFLAGS = "${CFLAGS}"
10export CGO_CPPFLAGS = "${CPPFLAGS}"
11export CGO_CXXFLAGS = "${CXXFLAGS}"
12# Filter out -fdebug-prefix-map options as they clash with the GO's build system
13export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }"
14
Brad Bishopc8f47122019-06-24 09:36:18 -040015export GOCACHE = "${B}/.cache"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050016GO_LDFLAGS = ""
Patrick Williams213cb262021-08-07 19:21:33 -050017GO_LDFLAGS:class-nativesdk = "-linkmode external"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018export GO_LDFLAGS
19
Patrick Williams213cb262021-08-07 19:21:33 -050020CC:append:class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050021
22do_configure[noexec] = "1"
23
24do_compile() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040025 export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}"
26 export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050027
28 cd src
Brad Bishop316dfdd2018-06-25 12:45:53 -040029 ./make.bash --target-only --no-banner
Brad Bishopd7bf8c12018-02-25 22:55:05 -050030 cd ${B}
31}
Brad Bishop316dfdd2018-06-25 12:45:53 -040032do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg"
33do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050034
35do_install() {
36 install -d ${D}${libdir}/go/pkg/tool
37 cp --preserve=mode,timestamps -R ${B}/pkg/tool/${TARGET_GOTUPLE} ${D}${libdir}/go/pkg/tool/
38 install -d ${D}${libdir}/go/src
39 cp --preserve=mode,timestamps -R ${S}/src/cmd ${D}${libdir}/go/src/
Brad Bishop316dfdd2018-06-25 12:45:53 -040040 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041 install -d ${D}${libdir}/go/bin
42 install -d ${D}${bindir}
43 for f in ${B}/${GO_BUILD_BINDIR}/*; do
44 name=`basename $f`
45 install -m 0755 $f ${D}${libdir}/go/bin/
Brad Bishop19323692019-04-05 15:28:33 -040046 ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/
Brad Bishopd7bf8c12018-02-25 22:55:05 -050047 done
Andrew Geissler82c905d2020-04-13 13:39:40 -050048 rm -rf ${D}${libdir}/go/src
Brad Bishopd7bf8c12018-02-25 22:55:05 -050049}
50
51PACKAGES = "${PN} ${PN}-dev"
Patrick Williams213cb262021-08-07 19:21:33 -050052FILES:${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}"
53RDEPENDS:${PN} = "go-runtime"
54INSANE_SKIP:${PN} = "ldflags"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050055
56BBCLASSEXTEND = "nativesdk"