blob: 981c7abd313725958bde6b442d82afba4058c6c3 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
Andrew Geissler028142b2023-05-05 11:29:21 -05002DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go 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"
Patrick Williamsb58112e2024-03-07 11:16:36 -060016export GO_LDFLAGS = ""
Patrick Williams03907ee2022-05-01 06:28:52 -050017export GOBUILDFLAGS = "-gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH -trimpath"
Patrick Williams213cb262021-08-07 19:21:33 -050018CC:append:class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019
20do_configure[noexec] = "1"
21
22do_compile() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040023 export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}"
24 export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050025
26 cd src
Brad Bishop316dfdd2018-06-25 12:45:53 -040027 ./make.bash --target-only --no-banner
Brad Bishopd7bf8c12018-02-25 22:55:05 -050028 cd ${B}
29}
Brad Bishop316dfdd2018-06-25 12:45:53 -040030do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050031
32do_install() {
33 install -d ${D}${libdir}/go/pkg/tool
34 cp --preserve=mode,timestamps -R ${B}/pkg/tool/${TARGET_GOTUPLE} ${D}${libdir}/go/pkg/tool/
35 install -d ${D}${libdir}/go/src
36 cp --preserve=mode,timestamps -R ${S}/src/cmd ${D}${libdir}/go/src/
Brad Bishop316dfdd2018-06-25 12:45:53 -040037 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
Brad Bishopd7bf8c12018-02-25 22:55:05 -050038 install -d ${D}${libdir}/go/bin
39 install -d ${D}${bindir}
40 for f in ${B}/${GO_BUILD_BINDIR}/*; do
41 name=`basename $f`
42 install -m 0755 $f ${D}${libdir}/go/bin/
Brad Bishop19323692019-04-05 15:28:33 -040043 ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/
Brad Bishopd7bf8c12018-02-25 22:55:05 -050044 done
Andrew Geissler82c905d2020-04-13 13:39:40 -050045 rm -rf ${D}${libdir}/go/src
Brad Bishopd7bf8c12018-02-25 22:55:05 -050046}
47
48PACKAGES = "${PN} ${PN}-dev"
Patrick Williams213cb262021-08-07 19:21:33 -050049FILES:${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}"
50RDEPENDS:${PN} = "go-runtime"
51INSANE_SKIP:${PN} = "ldflags"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050052
53BBCLASSEXTEND = "nativesdk"