Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame^] | 1 | DEPENDS = "virtual/${TARGET_PREFIX}go go-native" |
| 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}" |
| 11 | export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" |
| 12 | export GOROOT_FINAL = "${libdir}/go" |
| 13 | export GO_TARGET_INSTALL = "std" |
| 14 | export CGO_ENABLED = "1" |
| 15 | export CC_FOR_TARGET="${CC}" |
| 16 | export CXX_FOR_TARGET="${CXX}" |
| 17 | export GOROOT_OVERRIDE = "1" |
| 18 | |
| 19 | do_configure() { |
| 20 | : |
| 21 | } |
| 22 | |
| 23 | do_configure_libc-musl() { |
| 24 | rm -f ${S}/src/runtime/race/*.syso |
| 25 | } |
| 26 | |
| 27 | do_compile() { |
| 28 | export GOBIN="${B}/bin" |
| 29 | export CC="${@d.getVar('BUILD_CC').strip()}" |
| 30 | rm -rf ${GOBIN} ${B}/pkg |
| 31 | mkdir ${GOBIN} |
| 32 | cd src |
| 33 | ./make.bash --host-only |
| 34 | cp ${B}/pkg/tool/${BUILD_GOTUPLE}/go_bootstrap ${B} |
| 35 | rm -rf ${B}/pkg/${TARGET_GOTUPLE} |
| 36 | ./make.bash --target-only |
| 37 | if [ -n "${GO_DYNLINK}" ]; then |
| 38 | cp ${B}/go_bootstrap ${B}/pkg/tool/${BUILD_GOTUPLE} |
| 39 | GO_FLAGS="-buildmode=shared" GO_LDFLAGS="-extldflags \"${LDFLAGS}\"" ./make.bash --target-only |
| 40 | fi |
| 41 | cd ${B} |
| 42 | } |
| 43 | |
| 44 | do_install() { |
| 45 | install -d ${D}${libdir}/go/src |
| 46 | cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/ |
| 47 | if [ "${BUILD_GOTUPLE}" != "${TARGET_GOTUPLE}" ]; then |
| 48 | rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE} |
| 49 | rm -rf ${D}${libdir}/go/pkg/obj/${BUILD_GOTUPLE} |
| 50 | fi |
| 51 | rm -rf ${D}${libdir}/go/pkg/tool |
| 52 | rm -rf ${D}${libdir}/go/pkg/obj |
| 53 | rm -rf ${D}${libdir}/go/pkg/bootstrap |
| 54 | find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do |
| 55 | cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/ |
| 56 | done |
| 57 | rm -f ${D}${libdir}/go/src/cmd/dist/dist |
| 58 | } |
| 59 | |
| 60 | # Remove test binaries that cannot be relocated |
| 61 | do_install_append_class-nativesdk() { |
| 62 | rm -rf ${D}${libdir}/go/src/runtime/pprof/testdata |
| 63 | } |
| 64 | |
| 65 | # These testdata directories aren't needed for builds and contain binaries |
| 66 | # that can cause errors in sysroot_strip(), so just remove them. |
| 67 | sysroot_stage_all_append() { |
| 68 | find ${SYSROOT_DESTDIR}${libdir}/go/src -depth -type d -name 'testdata' -exec rm -rf {} \; |
| 69 | } |
| 70 | |
| 71 | ALLOW_EMPTY_${PN} = "1" |
| 72 | FILES_${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}" |
| 73 | FILES_${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include \ |
| 74 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.shlibname \ |
| 75 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.shlibname \ |
| 76 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.shlibname \ |
| 77 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*.shlibname \ |
| 78 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*.shlibname \ |
| 79 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.shlibname \ |
| 80 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.shlibname \ |
| 81 | " |
| 82 | FILES_${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE} \ |
| 83 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*.a \ |
| 84 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*.a \ |
| 85 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*.a \ |
| 86 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*.a \ |
| 87 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*.a \ |
| 88 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*.a \ |
| 89 | ${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*/*/*/*/*/*/*.a \ |
| 90 | " |
| 91 | # The testdata directories in the source tree include some binaries for various |
| 92 | # architectures, scripts, and .a files |
| 93 | INSANE_SKIP_${PN}-dev = "staticdev ldflags file-rdeps arch" |
| 94 | |
| 95 | INHIBIT_PACKAGE_STRIP = "1" |
| 96 | INHIBIT_PACKAGE_DEBUG_SPLIT = "1" |
| 97 | |
| 98 | BBCLASSEXTEND = "nativesdk" |