blob: 29ae86e4eec28c0cf66449b53c01887d0593f72b [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001DEPENDS = "virtual/${TARGET_PREFIX}go go-native"
2DEPENDS_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}"
11export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
12export GOROOT_FINAL = "${libdir}/go"
13export GO_TARGET_INSTALL = "std"
14export CGO_ENABLED = "1"
15export CC_FOR_TARGET="${CC}"
16export CXX_FOR_TARGET="${CXX}"
17export GOROOT_OVERRIDE = "1"
18
19do_configure() {
20 :
21}
22
23do_configure_libc-musl() {
24 rm -f ${S}/src/runtime/race/*.syso
25}
26
27do_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
44do_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
61do_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.
67sysroot_stage_all_append() {
68 find ${SYSROOT_DESTDIR}${libdir}/go/src -depth -type d -name 'testdata' -exec rm -rf {} \;
69}
70
71ALLOW_EMPTY_${PN} = "1"
72FILES_${PN} = "${libdir}/go/pkg/${TARGET_GOTUPLE}_dynlink/*${SOLIBSDEV}"
73FILES_${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"
82FILES_${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
93INSANE_SKIP_${PN}-dev = "staticdev ldflags file-rdeps arch"
94
95INHIBIT_PACKAGE_STRIP = "1"
96INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
97
98BBCLASSEXTEND = "nativesdk"