summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go/go-cross-canadian.inc
diff options
context:
space:
mode:
authorMatt Madison <matt@madison.systems>2017-09-12 09:50:31 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-12 23:55:29 +0100
commit6255c002af95ba4481d96741bea59e3db7c663df (patch)
treeccc117fdfc71e55f29d767efc7e61833691a287c /meta/recipes-devtools/go/go-cross-canadian.inc
parentd7f07283dec4a77c293318cdfee4566fe21cd3c2 (diff)
downloadpoky-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.inc64
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 @@
1inherit cross-canadian
2
3DEPENDS = "go-native virtual/${HOST_PREFIX}gcc-crosssdk virtual/nativesdk-${HOST_PREFIX}libc-for-gcc virtual/nativesdk-${HOST_PREFIX}compilerlibs"
4PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"
5
6export GOHOSTOS = "${BUILD_GOOS}"
7export GOHOSTARCH = "${BUILD_GOARCH}"
8export GOOS = "${HOST_GOOS}"
9export GOARCH = "${HOST_GOARCH}"
10export GOARM = "${HOST_GOARM}"
11export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
12export GOTOOLDIR_BOOTSTRAP = "${GOROOT_BOOTSTRAP}/pkg/tool/${BUILD_GOTUPLE}"
13export GOROOT_FINAL = "${libdir}/go"
14export CGO_ENABLED = "1"
15export CC_FOR_TARGET = "${HOST_CC}"
16export CXX_FOR_TARGET = "${HOST_CXX}"
17CC = "${@d.getVar('BUILD_CC', True).strip()}"
18export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "${TOOLCHAIN_OPTIONS} ${LDFLAGS}"'
19
20do_configure[noexec] = "1"
21
22do_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
32make_wrapper() {
33 rm -f ${D}${bindir}/$2
34 cat <<END >${D}${bindir}/$2
35#!/bin/bash
36here=\`dirname \$0\`
37native_goroot=\`readlink -f \$here/../../lib/${TARGET_SYS}/go\`
38export GOARCH="${TARGET_GOARCH}"
39export GOOS="${TARGET_GOOS}"
40export GOARM="\${GOARM:-${TARGET_GOARM}}"
41export GOTOOLDIR="\$native_goroot/pkg/tool/${HOST_GOTUPLE}"
42export GOROOT="\${GOROOT:-\$OECORE_TARGET_SYSROOT/${target_libdir}/go}"
43\$here/../../lib/${TARGET_SYS}/go/bin/$1 "\$@"
44END
45 chmod +x ${D}${bindir}/$2
46}
47
48do_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
64FILES_${PN}-staticdev = "${libdir}/go/pkg"