Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | DEPENDS = "virtual/${TUNE_PKGARCH}-go go-native" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 2 | DEPENDS_class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk" |
| 3 | PROVIDES = "virtual/${TARGET_PREFIX}go-runtime" |
| 4 | |
| 5 | export GOHOSTOS = "${BUILD_GOOS}" |
| 6 | export GOHOSTARCH = "${BUILD_GOARCH}" |
| 7 | export GOOS = "${TARGET_GOOS}" |
| 8 | export GOARCH = "${TARGET_GOARCH}" |
| 9 | export GOARM = "${TARGET_GOARM}" |
| 10 | export GO386 = "${TARGET_GO386}" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11 | export GOMIPS = "${TARGET_GOMIPS}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12 | export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" |
| 13 | export GOROOT_FINAL = "${libdir}/go" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 14 | export CGO_CFLAGS = "${CFLAGS}" |
| 15 | export CGO_CPPFLAGS = "${CPPFLAGS}" |
| 16 | export CGO_CXXFLAGS = "${CXXFLAGS}" |
| 17 | export CGO_LDFLAGS = "${LDFLAGS}" |
| 18 | |
| 19 | GO_EXTLDFLAGS ?= "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS} ${LDFLAGS}" |
| 20 | GO_SHLIB_LDFLAGS ?= '-ldflags="--linkmode=external -extldflags '${GO_EXTLDFLAGS}'"' |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 21 | |
| 22 | do_configure() { |
| 23 | : |
| 24 | } |
| 25 | |
| 26 | do_configure_libc-musl() { |
| 27 | rm -f ${S}/src/runtime/race/*.syso |
| 28 | } |
| 29 | |
| 30 | do_compile() { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CC}" |
| 32 | export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${CXX}" |
| 33 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 34 | cd src |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 35 | ./make.bash --target-only --no-banner std |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 36 | if [ -n "${GO_DYNLINK}" ]; then |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 37 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 40 | fi |
| 41 | cd ${B} |
| 42 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 43 | do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg" |
| 44 | do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 45 | |
| 46 | do_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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 59 | 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] | 60 | rm -f ${D}${libdir}/go/src/cmd/dist/dist |
| 61 | } |
| 62 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 63 | ALLOW_EMPTY_${PN} = "1" |
| 64 | FILES_${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}" |
| 65 | FILES_${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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 73 | ${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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 81 | FILES_${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. |
| 86 | INSANE_SKIP_${PN}-dev = "staticdev file-rdeps arch" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 87 | |
| 88 | INHIBIT_PACKAGE_STRIP = "1" |
| 89 | INHIBIT_PACKAGE_DEBUG_SPLIT = "1" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 90 | INHIBIT_SYSROOT_STRIP = "1" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 91 | |
| 92 | BBCLASSEXTEND = "nativesdk" |