diff options
| author | Khem Raj <raj.khem@gmail.com> | 2017-03-07 22:40:22 -0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-10 15:51:55 +0000 |
| commit | 760e81678cec80dcdaab12c2a0a0148e3e0ba275 (patch) | |
| tree | 6b587a2e9bd13c68788c1ff20df54db7e2f38c53 /meta/classes/go.bbclass | |
| parent | 0efe58df2e5389f86dfbd53f90afc8f2970def7d (diff) | |
| download | poky-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.bbclass | 79 |
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 @@ | |||
| 1 | inherit goarch | ||
| 2 | |||
| 3 | # Incompatible with musl, at least for now | ||
| 4 | COMPATIBLE_HOST_libc-musl_class-target = "null" | ||
| 5 | # x32 ABI is not supported on go compiler so far | ||
| 6 | COMPATIBLE_HOST_linux-gnux32 = "null" | ||
| 7 | # ppc32 is not supported in go compilers | ||
| 8 | COMPATIBLE_HOST_powerpc = "null" | ||
| 9 | |||
| 10 | GOROOT_class-native = "${STAGING_LIBDIR_NATIVE}/go" | ||
| 11 | GOROOT = "${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go" | ||
| 12 | GOBIN_FINAL_class-native = "${GOROOT_FINAL}/bin" | ||
| 13 | GOBIN_FINAL = "${GOROOT_FINAL}/bin/${GOOS}_${GOARCH}" | ||
| 14 | |||
| 15 | export GOOS = "${TARGET_GOOS}" | ||
| 16 | export GOARCH = "${TARGET_GOARCH}" | ||
| 17 | export GOARM = "${TARGET_GOARM}" | ||
| 18 | export CGO_ENABLED = "1" | ||
| 19 | export GOROOT | ||
| 20 | export GOROOT_FINAL = "${libdir}/${TARGET_SYS}/go" | ||
| 21 | export GOBIN_FINAL | ||
| 22 | export GOPKG_FINAL = "${GOROOT_FINAL}/pkg/${GOOS}_${GOARCH}" | ||
| 23 | export GOSRC_FINAL = "${GOROOT_FINAL}/src" | ||
| 24 | export GO_GCFLAGS = "${TARGET_CFLAGS}" | ||
| 25 | export GO_LDFLAGS = "${TARGET_LDFLAGS}" | ||
| 26 | export CGO_CFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CFLAGS}" | ||
| 27 | export CGO_CPPFLAGS = "${TARGET_CPPFLAGS}" | ||
| 28 | export CGO_CXXFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CXXFLAGS}" | ||
| 29 | export CGO_LDFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_LDFLAGS}" | ||
| 30 | |||
| 31 | DEPENDS += "go-cross-${TARGET_ARCH}" | ||
| 32 | DEPENDS_class-native += "go-native" | ||
| 33 | |||
| 34 | FILES_${PN}-staticdev += "${GOSRC_FINAL}/${GO_IMPORT}" | ||
| 35 | FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*" | ||
| 36 | |||
| 37 | GO_INSTALL ?= "${GO_IMPORT}/..." | ||
| 38 | |||
| 39 | do_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 | |||
| 46 | do_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 | |||
| 73 | do_compile() { | ||
| 74 | do_go_compile | ||
| 75 | } | ||
| 76 | |||
| 77 | do_install() { | ||
| 78 | do_go_install | ||
| 79 | } | ||
