diff options
author | Matt Madison <matt@madison.systems> | 2017-09-12 09:50:31 -0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-09-12 23:55:29 +0100 |
commit | 6255c002af95ba4481d96741bea59e3db7c663df (patch) | |
tree | ccc117fdfc71e55f29d767efc7e61833691a287c /meta/recipes-devtools/go/go-cross-canadian.inc | |
parent | d7f07283dec4a77c293318cdfee4566fe21cd3c2 (diff) | |
download | poky-6255c002af95ba4481d96741bea59e3db7c663df.tar.gz |
go-cross-canadian: add recipe
Enable cross-canadian builds of the Go toolchain. This
requires an additional patch to the Go source to allow us
to use the native GOTOOLDIR during the bootstrap phase.
(From OE-Core rev: 9daa02f63a0d53ab90a515f2bd3e783187c9415b)
Signed-off-by: Matt Madison <matt@madison.systems>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/go/go-cross-canadian.inc')
-rw-r--r-- | meta/recipes-devtools/go/go-cross-canadian.inc | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-cross-canadian.inc b/meta/recipes-devtools/go/go-cross-canadian.inc new file mode 100644 index 0000000000..f0315d558a --- /dev/null +++ b/meta/recipes-devtools/go/go-cross-canadian.inc | |||
@@ -0,0 +1,64 @@ | |||
1 | inherit cross-canadian | ||
2 | |||
3 | DEPENDS = "go-native virtual/${HOST_PREFIX}gcc-crosssdk virtual/nativesdk-${HOST_PREFIX}libc-for-gcc virtual/nativesdk-${HOST_PREFIX}compilerlibs" | ||
4 | PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}" | ||
5 | |||
6 | export GOHOSTOS = "${BUILD_GOOS}" | ||
7 | export GOHOSTARCH = "${BUILD_GOARCH}" | ||
8 | export GOOS = "${HOST_GOOS}" | ||
9 | export GOARCH = "${HOST_GOARCH}" | ||
10 | export GOARM = "${HOST_GOARM}" | ||
11 | export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" | ||
12 | export GOTOOLDIR_BOOTSTRAP = "${GOROOT_BOOTSTRAP}/pkg/tool/${BUILD_GOTUPLE}" | ||
13 | export GOROOT_FINAL = "${libdir}/go" | ||
14 | export CGO_ENABLED = "1" | ||
15 | export CC_FOR_TARGET = "${HOST_CC}" | ||
16 | export CXX_FOR_TARGET = "${HOST_CXX}" | ||
17 | CC = "${@d.getVar('BUILD_CC', True).strip()}" | ||
18 | export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "${TOOLCHAIN_OPTIONS} ${LDFLAGS}"' | ||
19 | |||
20 | do_configure[noexec] = "1" | ||
21 | |||
22 | do_compile() { | ||
23 | export GOBIN="${B}/bin" | ||
24 | rm -rf ${GOBIN} ${B}/pkg | ||
25 | mkdir ${GOBIN} | ||
26 | cd src | ||
27 | ./make.bash --host-only --no-banner | ||
28 | cd ${B} | ||
29 | } | ||
30 | |||
31 | |||
32 | make_wrapper() { | ||
33 | rm -f ${D}${bindir}/$2 | ||
34 | cat <<END >${D}${bindir}/$2 | ||
35 | #!/bin/bash | ||
36 | here=\`dirname \$0\` | ||
37 | native_goroot=\`readlink -f \$here/../../lib/${TARGET_SYS}/go\` | ||
38 | export GOARCH="${TARGET_GOARCH}" | ||
39 | export GOOS="${TARGET_GOOS}" | ||
40 | export GOARM="\${GOARM:-${TARGET_GOARM}}" | ||
41 | export GOTOOLDIR="\$native_goroot/pkg/tool/${HOST_GOTUPLE}" | ||
42 | export GOROOT="\${GOROOT:-\$OECORE_TARGET_SYSROOT/${target_libdir}/go}" | ||
43 | \$here/../../lib/${TARGET_SYS}/go/bin/$1 "\$@" | ||
44 | END | ||
45 | chmod +x ${D}${bindir}/$2 | ||
46 | } | ||
47 | |||
48 | do_install() { | ||
49 | install -d ${D}${libdir}/go | ||
50 | cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/ | ||
51 | install -d ${D}${libdir}/go/src | ||
52 | (cd ${S}/src; for d in *; do \ | ||
53 | [ -d $d ] && cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \ | ||
54 | done) | ||
55 | install -d ${D}${bindir} ${D}${libdir}/go/bin | ||
56 | for f in ${B}/bin/* | ||
57 | do | ||
58 | base=`basename $f` | ||
59 | install -m755 $f ${D}${libdir}/go/bin | ||
60 | make_wrapper $base ${TARGET_PREFIX}$base | ||
61 | done | ||
62 | } | ||
63 | |||
64 | FILES_${PN}-staticdev = "${libdir}/go/pkg" | ||