blob: e282195619ca9fd701f2e61274ca612b2b682f57 [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"
3PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
4
5export GOHOSTOS = "${BUILD_GOOS}"
6export GOHOSTARCH = "${BUILD_GOARCH}"
7export GOOS = "${TARGET_GOOS}"
8export GOARCH = "${TARGET_GOARCH}"
9export GOARM = "${TARGET_GOARM}"
10export GO386 = "${TARGET_GO386}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040011export GOMIPS = "${TARGET_GOMIPS}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050012export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
13export GOROOT_FINAL = "${libdir}/go"
Brad Bishop316dfdd2018-06-25 12:45:53 -040014export CGO_CFLAGS = "${CFLAGS}"
15export CGO_CPPFLAGS = "${CPPFLAGS}"
16export CGO_CXXFLAGS = "${CXXFLAGS}"
17export CGO_LDFLAGS = "${LDFLAGS}"
Brad Bishopc8f47122019-06-24 09:36:18 -040018export GOCACHE = "${B}/.cache"
Brad Bishop316dfdd2018-06-25 12:45:53 -040019
20GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
21GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050022
23do_configure() {
24 :
25}
26
27do_configure_libc-musl() {
28 rm -f ${S}/src/runtime/race/*.syso
29}
30
31do_compile() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040032 export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}"
33 export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}"
34
Brad Bishopd7bf8c12018-02-25 22:55:05 -050035 cd src
Brad Bishop316dfdd2018-06-25 12:45:53 -040036 ./make.bash --target-only --no-banner std
Brad Bishopd7bf8c12018-02-25 22:55:05 -050037 if [ -n "${GO_DYNLINK}" ]; then
Brad Bishop316dfdd2018-06-25 12:45:53 -040038 export GOTOOLDIR="${B}/pkg/tool/native_native"
39 CC="$CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \
40 $GOTOOLDIR/go_bootstrap install -linkshared -buildmode=shared ${GO_SHLIB_LDFLAGS} std
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041 fi
42 cd ${B}
43}
Brad Bishop316dfdd2018-06-25 12:45:53 -040044do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg"
45do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050046
47do_install() {
48 install -d ${D}${libdir}/go/src
49 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
50 if [ "${BUILD_GOTUPLE}" != "${TARGET_GOTUPLE}" ]; then
51 rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE}
52 rm -rf ${D}${libdir}/go/pkg/obj/${BUILD_GOTUPLE}
53 fi
54 rm -rf ${D}${libdir}/go/pkg/tool
55 rm -rf ${D}${libdir}/go/pkg/obj
56 rm -rf ${D}${libdir}/go/pkg/bootstrap
57 find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do
58 cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/
59 done
Brad Bishop316dfdd2018-06-25 12:45:53 -040060 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
Brad Bishopd7bf8c12018-02-25 22:55:05 -050061 rm -f ${D}${libdir}/go/src/cmd/dist/dist
62}
63
Brad Bishopd7bf8c12018-02-25 22:55:05 -050064ALLOW_EMPTY_${PN} = "1"
65FILES_${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}"
66FILES_${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \
67 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.shlibname \
68 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.shlibname \
69 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.shlibname \
70 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*.shlibname \
71 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*.shlibname \
72 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.shlibname \
73 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.shlibname \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050074 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.a \
75 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.a \
76 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.a \
77 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*.a \
78 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*.a \
79 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.a \
80 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.a \
81"
Brad Bishop316dfdd2018-06-25 12:45:53 -040082FILES_${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE}"
83
84# Go sources include some scripts and pre-built binaries for
85# multiple architectures. The static .a files for dynamically-linked
86# runtime are also required in -dev.
87INSANE_SKIP_${PN}-dev = "staticdev file-rdeps arch"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050088
89INHIBIT_PACKAGE_STRIP = "1"
90INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
Brad Bishop316dfdd2018-06-25 12:45:53 -040091INHIBIT_SYSROOT_STRIP = "1"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050092
93BBCLASSEXTEND = "nativesdk"