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 | 213cb26 | 2021-08-07 19:21:33 -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 |
| 19 | |
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[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" |
| 33 | do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 34 | |
| 35 | do_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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | 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] | 41 | 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 46 | ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 47 | done |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 48 | rm -rf ${D}${libdir}/go/src |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | PACKAGES = "${PN} ${PN}-dev" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 52 | FILES:${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}" |
| 53 | RDEPENDS:${PN} = "go-runtime" |
| 54 | INSANE_SKIP:${PN} = "ldflags" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 55 | |
| 56 | BBCLASSEXTEND = "nativesdk" |