Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 1 | inherit goarch |
| 2 | |
| 3 | # x32 ABI is not supported on go compiler so far |
| 4 | COMPATIBLE_HOST_linux-gnux32 = "null" |
| 5 | # ppc32 is not supported in go compilers |
| 6 | COMPATIBLE_HOST_powerpc = "null" |
| 7 | |
| 8 | GOROOT_class-native = "${STAGING_LIBDIR_NATIVE}/go" |
| 9 | GOROOT = "${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go" |
| 10 | GOBIN_FINAL_class-native = "${GOROOT_FINAL}/bin" |
| 11 | GOBIN_FINAL = "${GOROOT_FINAL}/bin/${GOOS}_${GOARCH}" |
| 12 | |
| 13 | export GOOS = "${TARGET_GOOS}" |
| 14 | export GOARCH = "${TARGET_GOARCH}" |
| 15 | export GOARM = "${TARGET_GOARM}" |
| 16 | export CGO_ENABLED = "1" |
| 17 | export GOROOT |
| 18 | export GOROOT_FINAL = "${libdir}/${TARGET_SYS}/go" |
| 19 | export GOBIN_FINAL |
| 20 | export GOPKG_FINAL = "${GOROOT_FINAL}/pkg/${GOOS}_${GOARCH}" |
| 21 | export GOSRC_FINAL = "${GOROOT_FINAL}/src" |
| 22 | export GO_GCFLAGS = "${TARGET_CFLAGS}" |
| 23 | export GO_LDFLAGS = "${TARGET_LDFLAGS}" |
| 24 | export CGO_CFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CFLAGS}" |
| 25 | export CGO_CPPFLAGS = "${TARGET_CPPFLAGS}" |
| 26 | export CGO_CXXFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CXXFLAGS}" |
| 27 | export CGO_LDFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_LDFLAGS}" |
| 28 | |
| 29 | DEPENDS += "go-cross-${TARGET_ARCH}" |
| 30 | DEPENDS_class-native += "go-native" |
| 31 | |
| 32 | FILES_${PN}-staticdev += "${GOSRC_FINAL}/${GO_IMPORT}" |
| 33 | FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*" |
| 34 | |
| 35 | GO_INSTALL ?= "${GO_IMPORT}/..." |
| 36 | |
| 37 | do_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 | |
| 44 | do_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 | |
| 71 | do_compile() { |
| 72 | do_go_compile |
| 73 | } |
| 74 | |
| 75 | do_install() { |
| 76 | do_go_install |
| 77 | } |