blob: 85f71a2e9a6e5a860c6adb30eb75ff1012ea8ce2 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001inherit goarch
2
3# x32 ABI is not supported on go compiler so far
4COMPATIBLE_HOST_linux-gnux32 = "null"
5# ppc32 is not supported in go compilers
6COMPATIBLE_HOST_powerpc = "null"
7
8GOROOT_class-native = "${STAGING_LIBDIR_NATIVE}/go"
9GOROOT = "${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go"
10GOBIN_FINAL_class-native = "${GOROOT_FINAL}/bin"
11GOBIN_FINAL = "${GOROOT_FINAL}/bin/${GOOS}_${GOARCH}"
12
13export GOOS = "${TARGET_GOOS}"
14export GOARCH = "${TARGET_GOARCH}"
15export GOARM = "${TARGET_GOARM}"
16export CGO_ENABLED = "1"
17export GOROOT
18export GOROOT_FINAL = "${libdir}/${TARGET_SYS}/go"
19export GOBIN_FINAL
20export GOPKG_FINAL = "${GOROOT_FINAL}/pkg/${GOOS}_${GOARCH}"
21export GOSRC_FINAL = "${GOROOT_FINAL}/src"
22export GO_GCFLAGS = "${TARGET_CFLAGS}"
23export GO_LDFLAGS = "${TARGET_LDFLAGS}"
24export CGO_CFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CFLAGS}"
25export CGO_CPPFLAGS = "${TARGET_CPPFLAGS}"
26export CGO_CXXFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CXXFLAGS}"
27export CGO_LDFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_LDFLAGS}"
28
29DEPENDS += "go-cross-${TARGET_ARCH}"
30DEPENDS_class-native += "go-native"
31
32FILES_${PN}-staticdev += "${GOSRC_FINAL}/${GO_IMPORT}"
33FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*"
34
35GO_INSTALL ?= "${GO_IMPORT}/..."
36
37do_go_compile() {
38 GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env
39 if [ -n "${GO_INSTALL}" ]; then
40 GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install -v ${GO_INSTALL}
41 fi
42}
43
44do_go_install() {
45 rm -rf ${WORKDIR}/staging
46 install -d ${WORKDIR}/staging${GOROOT_FINAL} ${D}${GOROOT_FINAL}
47 tar -C ${S} -cf - . | tar -C ${WORKDIR}/staging${GOROOT_FINAL} -xpvf -
48
49 find ${WORKDIR}/staging${GOROOT_FINAL} \( \
50 -name \*.indirectionsymlink -o \
51 -name .git\* -o \
52 -name .hg -o \
53 -name .svn -o \
54 -name .pc\* -o \
55 -name patches\* \
56 \) -print0 | \
57 xargs -r0 rm -rf
58
59 tar -C ${WORKDIR}/staging${GOROOT_FINAL} -cf - . | \
60 tar -C ${D}${GOROOT_FINAL} -xpvf -
61
62 chown -R root:root "${D}${GOROOT_FINAL}"
63
64 if [ -e "${D}${GOBIN_FINAL}" ]; then
65 install -d -m 0755 "${D}${bindir}"
66 find "${D}${GOBIN_FINAL}" ! -type d -print0 | xargs -r0 mv --target-directory="${D}${bindir}"
67 rmdir -p "${D}${GOBIN_FINAL}" || true
68 fi
69}
70
71do_compile() {
72 do_go_compile
73}
74
75do_install() {
76 do_go_install
77}