blob: 91efd3e97700d434f66a439868366c9422b6b82c [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05002DEPENDS_class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk go-native"
3
4export GOHOSTOS = "${BUILD_GOOS}"
5export GOHOSTARCH = "${BUILD_GOARCH}"
6export GOOS = "${TARGET_GOOS}"
7export GOARCH = "${TARGET_GOARCH}"
8export GOARM = "${TARGET_GOARM}"
9export GO386 = "${TARGET_GO386}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040010export GOMIPS = "${TARGET_GOMIPS}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050011export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
12export GOROOT_FINAL = "${libdir}/go"
Brad Bishopc8f47122019-06-24 09:36:18 -040013export GOCACHE = "${B}/.cache"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050014GO_LDFLAGS = ""
15GO_LDFLAGS_class-nativesdk = "-linkmode external"
16export GO_LDFLAGS
17
Brad Bishop316dfdd2018-06-25 12:45:53 -040018CC_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[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg"
31do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050032
33do_install() {
34 install -d ${D}${libdir}/go/pkg/tool
35 cp --preserve=mode,timestamps -R ${B}/pkg/tool/${TARGET_GOTUPLE} ${D}${libdir}/go/pkg/tool/
36 install -d ${D}${libdir}/go/src
37 cp --preserve=mode,timestamps -R ${S}/src/cmd ${D}${libdir}/go/src/
Brad Bishop316dfdd2018-06-25 12:45:53 -040038 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
Brad Bishopd7bf8c12018-02-25 22:55:05 -050039 install -d ${D}${libdir}/go/bin
40 install -d ${D}${bindir}
41 for f in ${B}/${GO_BUILD_BINDIR}/*; do
42 name=`basename $f`
43 install -m 0755 $f ${D}${libdir}/go/bin/
Brad Bishop19323692019-04-05 15:28:33 -040044 ln -sf ../${baselib}/go/bin/$name ${D}${bindir}/
Brad Bishopd7bf8c12018-02-25 22:55:05 -050045 done
46}
47
48PACKAGES = "${PN} ${PN}-dev"
49FILES_${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}"
50FILES_${PN}-dev = "${libdir}/go"
51RDEPENDS_${PN}-dev = "perl bash"
52INSANE_SKIP_${PN} = "ldflags"
53
54BBCLASSEXTEND = "nativesdk"