summaryrefslogtreecommitdiffstats
path: root/meta/classes/go.bbclass
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2017-03-07 22:40:22 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-03-10 15:51:55 +0000
commit760e81678cec80dcdaab12c2a0a0148e3e0ba275 (patch)
tree6b587a2e9bd13c68788c1ff20df54db7e2f38c53 /meta/classes/go.bbclass
parent0efe58df2e5389f86dfbd53f90afc8f2970def7d (diff)
downloadpoky-760e81678cec80dcdaab12c2a0a0148e3e0ba275.tar.gz
go: Add recipes for golang compilers and tools
* This is converging the recipes for go from meta-virtualization and oe-meta-go * Add recipes for go 1.7 * go.bbclass is added to ease out writing recipes for go packages * go-examples: Add an example, helloworld written in go This should serve as temlate for writing go recipes * Disable for musl, at least for now * Disable for x32/ppc32 which is not supported (From OE-Core rev: 78615e9260fb5d6569de4883521b049717fa4340) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/go.bbclass')
-rw-r--r--meta/classes/go.bbclass79
1 files changed, 79 insertions, 0 deletions
diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
new file mode 100644
index 0000000000..f1984604b0
--- /dev/null
+++ b/meta/classes/go.bbclass
@@ -0,0 +1,79 @@
1inherit goarch
2
3# Incompatible with musl, at least for now
4COMPATIBLE_HOST_libc-musl_class-target = "null"
5# x32 ABI is not supported on go compiler so far
6COMPATIBLE_HOST_linux-gnux32 = "null"
7# ppc32 is not supported in go compilers
8COMPATIBLE_HOST_powerpc = "null"
9
10GOROOT_class-native = "${STAGING_LIBDIR_NATIVE}/go"
11GOROOT = "${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
12GOBIN_FINAL_class-native = "${GOROOT_FINAL}/bin"
13GOBIN_FINAL = "${GOROOT_FINAL}/bin/${GOOS}_${GOARCH}"
14
15export GOOS = "${TARGET_GOOS}"
16export GOARCH = "${TARGET_GOARCH}"
17export GOARM = "${TARGET_GOARM}"
18export CGO_ENABLED = "1"
19export GOROOT
20export GOROOT_FINAL = "${libdir}/${TARGET_SYS}/go"
21export GOBIN_FINAL
22export GOPKG_FINAL = "${GOROOT_FINAL}/pkg/${GOOS}_${GOARCH}"
23export GOSRC_FINAL = "${GOROOT_FINAL}/src"
24export GO_GCFLAGS = "${TARGET_CFLAGS}"
25export GO_LDFLAGS = "${TARGET_LDFLAGS}"
26export CGO_CFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CFLAGS}"
27export CGO_CPPFLAGS = "${TARGET_CPPFLAGS}"
28export CGO_CXXFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CXXFLAGS}"
29export CGO_LDFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_LDFLAGS}"
30
31DEPENDS += "go-cross-${TARGET_ARCH}"
32DEPENDS_class-native += "go-native"
33
34FILES_${PN}-staticdev += "${GOSRC_FINAL}/${GO_IMPORT}"
35FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*"
36
37GO_INSTALL ?= "${GO_IMPORT}/..."
38
39do_go_compile() {
40 GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env
41 if test -n "${GO_INSTALL}" ; then
42 GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install -v ${GO_INSTALL}
43 fi
44}
45
46do_go_install() {
47 rm -rf ${WORKDIR}/staging
48 install -d ${WORKDIR}/staging${GOROOT_FINAL} ${D}${GOROOT_FINAL}
49 tar -C ${S} -cf - . | tar -C ${WORKDIR}/staging${GOROOT_FINAL} -xpvf -
50
51 find ${WORKDIR}/staging${GOROOT_FINAL} \( \
52 -name \*.indirectionsymlink -o \
53 -name .git\* -o \
54 -name .hg -o \
55 -name .svn -o \
56 -name .pc\* -o \
57 -name patches\* \
58 \) -print0 | \
59 xargs -r0 rm -rf
60
61 tar -C ${WORKDIR}/staging${GOROOT_FINAL} -cf - . | \
62 tar -C ${D}${GOROOT_FINAL} -xpvf -
63
64 chown -R root:root "${D}${GOROOT_FINAL}"
65
66 if test -e "${D}${GOBIN_FINAL}" ; then
67 install -d -m 0755 "${D}${bindir}"
68 find "${D}${GOBIN_FINAL}" ! -type d -print0 | xargs -r0 mv --target-directory="${D}${bindir}"
69 rmdir -p "${D}${GOBIN_FINAL}" || true
70 fi
71}
72
73do_compile() {
74 do_go_compile
75}
76
77do_install() {
78 do_go_install
79}