blob: c219aa378932afee5aff5e087bee0971bd391765 [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}"
18
19GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}"
20GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"'
Brad Bishopd7bf8c12018-02-25 22:55:05 -050021
22do_configure() {
23 :
24}
25
26do_configure_libc-musl() {
27 rm -f ${S}/src/runtime/race/*.syso
28}
29
30do_compile() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040031 export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}"
32 export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}"
33
Brad Bishopd7bf8c12018-02-25 22:55:05 -050034 cd src
Brad Bishop316dfdd2018-06-25 12:45:53 -040035 ./make.bash --target-only --no-banner std
Brad Bishopd7bf8c12018-02-25 22:55:05 -050036 if [ -n "${GO_DYNLINK}" ]; then
Brad Bishop316dfdd2018-06-25 12:45:53 -040037 export GOTOOLDIR="${B}/pkg/tool/native_native"
38 CC="$CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}" GOARCH="${TARGET_GOARCH}" GOOS="${TARGET_GOOS}" GOROOT=${B} \
39 $GOTOOLDIR/go_bootstrap install -linkshared -buildmode=shared ${GO_SHLIB_LDFLAGS} std
Brad Bishopd7bf8c12018-02-25 22:55:05 -050040 fi
41 cd ${B}
42}
Brad Bishop316dfdd2018-06-25 12:45:53 -040043do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg"
44do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050045
46do_install() {
47 install -d ${D}${libdir}/go/src
48 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
49 if [ "${BUILD_GOTUPLE}" != "${TARGET_GOTUPLE}" ]; then
50 rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE}
51 rm -rf ${D}${libdir}/go/pkg/obj/${BUILD_GOTUPLE}
52 fi
53 rm -rf ${D}${libdir}/go/pkg/tool
54 rm -rf ${D}${libdir}/go/pkg/obj
55 rm -rf ${D}${libdir}/go/pkg/bootstrap
56 find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do
57 cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/
58 done
Brad Bishop316dfdd2018-06-25 12:45:53 -040059 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
Brad Bishopd7bf8c12018-02-25 22:55:05 -050060 rm -f ${D}${libdir}/go/src/cmd/dist/dist
61}
62
Brad Bishopd7bf8c12018-02-25 22:55:05 -050063ALLOW_EMPTY_${PN} = "1"
64FILES_${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}"
65FILES_${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \
66 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.shlibname \
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 \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050073 ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.a \
74 ${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"
Brad Bishop316dfdd2018-06-25 12:45:53 -040081FILES_${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE}"
82
83# Go sources include some scripts and pre-built binaries for
84# multiple architectures. The static .a files for dynamically-linked
85# runtime are also required in -dev.
86INSANE_SKIP_${PN}-dev = "staticdev file-rdeps arch"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050087
88INHIBIT_PACKAGE_STRIP = "1"
89INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
Brad Bishop316dfdd2018-06-25 12:45:53 -040090INHIBIT_SYSROOT_STRIP = "1"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050091
92BBCLASSEXTEND = "nativesdk"