Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" |
Andrew Geissler | 028142b | 2023-05-05 11:29:21 -0500 | [diff] [blame] | 2 | DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go go-native" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 3 | |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 4 | DEBUG_PREFIX_MAP = "\ |
| 5 | -fdebug-prefix-map=${STAGING_DIR_HOST}= \ |
| 6 | -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ |
| 7 | " |
| 8 | |
| 9 | export CGO_CFLAGS = "${CFLAGS}" |
| 10 | export CGO_CPPFLAGS = "${CPPFLAGS}" |
| 11 | export CGO_CXXFLAGS = "${CXXFLAGS}" |
| 12 | # Filter out -fdebug-prefix-map options as they clash with the GO's build system |
| 13 | export CGO_LDFLAGS = "${@ ' '.join(filter(lambda f: not f.startswith('-fdebug-prefix-map'), d.getVar('LDFLAGS').split())) }" |
| 14 | |
Brad Bishop | c8f4712 | 2019-06-24 09:36:18 -0400 | [diff] [blame] | 15 | export GOCACHE = "${B}/.cache" |
Patrick Williams | b58112e | 2024-03-07 11:16:36 -0600 | [diff] [blame] | 16 | export GO_LDFLAGS = "" |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 17 | export GOBUILDFLAGS = "-gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH -trimpath" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 18 | CC:append:class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 19 | |
| 20 | do_configure[noexec] = "1" |
| 21 | |
| 22 | do_compile() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 23 | export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}" |
| 24 | export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 25 | |
| 26 | cd src |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 27 | ./make.bash --target-only --no-banner |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 28 | cd ${B} |
| 29 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 30 | do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 31 | |
| 32 | do_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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 37 | find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \; |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 38 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 43 | ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 44 | done |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 45 | rm -rf ${D}${libdir}/go/src |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | PACKAGES = "${PN} ${PN}-dev" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 49 | FILES:${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}" |
| 50 | RDEPENDS:${PN} = "go-runtime" |
| 51 | INSANE_SKIP:${PN} = "ldflags" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 52 | |
| 53 | BBCLASSEXTEND = "nativesdk" |