Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 2 | DEPENDS:class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk 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" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 16 | GO_LDFLAGS = "" |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 17 | GO_LDFLAGS:class-nativesdk = " -linkmode external" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 18 | export GO_LDFLAGS |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 19 | export GOBUILDFLAGS = "-gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH -trimpath" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 20 | CC:append:class-nativesdk = " ${SECURITY_NOPIE_CFLAGS}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 21 | |
| 22 | do_configure[noexec] = "1" |
| 23 | |
| 24 | do_compile() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 25 | export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}" |
| 26 | export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 27 | |
| 28 | cd src |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 29 | ./make.bash --target-only --no-banner |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 30 | cd ${B} |
| 31 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 32 | do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 33 | |
| 34 | do_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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 39 | 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] | 40 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 45 | ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 46 | done |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 47 | rm -rf ${D}${libdir}/go/src |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | PACKAGES = "${PN} ${PN}-dev" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 51 | FILES:${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}" |
| 52 | RDEPENDS:${PN} = "go-runtime" |
| 53 | INSANE_SKIP:${PN} = "ldflags" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 54 | |
| 55 | BBCLASSEXTEND = "nativesdk" |