blob: ed09cfe8061f99ba2b8690f33d69a1a6f8503c72 [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 Williams03907ee2022-05-01 06:28:52 -050017GO_LDFLAGS:class-nativesdk = " -linkmode external"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018export GO_LDFLAGS
Patrick Williams03907ee2022-05-01 06:28:52 -050019export GOBUILDFLAGS = "-gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH -trimpath"
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[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050033
34do_install() {
35 install -d ${D}${libdir}/go/pkg/tool
36 cp --preserve=mode,timestamps -R ${B}/pkg/tool/${TARGET_GOTUPLE} ${D}${libdir}/go/pkg/tool/
37 install -d ${D}${libdir}/go/src
38 cp --preserve=mode,timestamps -R ${S}/src/cmd ${D}${libdir}/go/src/
Brad Bishop316dfdd2018-06-25 12:45:53 -040039 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
Brad Bishopd7bf8c12018-02-25 22:55:05 -050040 install -d ${D}${libdir}/go/bin
41 install -d ${D}${bindir}
42 for f in ${B}/${GO_BUILD_BINDIR}/*; do
43 name=`basename $f`
44 install -m 0755 $f ${D}${libdir}/go/bin/
Brad Bishop19323692019-04-05 15:28:33 -040045 ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/
Brad Bishopd7bf8c12018-02-25 22:55:05 -050046 done
Andrew Geissler82c905d2020-04-13 13:39:40 -050047 rm -rf ${D}${libdir}/go/src
Brad Bishopd7bf8c12018-02-25 22:55:05 -050048}
49
50PACKAGES = "${PN} ${PN}-dev"
Patrick Williams213cb262021-08-07 19:21:33 -050051FILES:${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}"
52RDEPENDS:${PN} = "go-runtime"
53INSANE_SKIP:${PN} = "ldflags"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050054
55BBCLASSEXTEND = "nativesdk"