blob: b76fb0825e404d411b94a992b539e629d6c3aba2 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001# Use immediate assingment here to get the original (/usr/lib)
2# instead of the one rewritten by native.bbclass.
3nonstaging_libdir := "${libdir}"
4
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005inherit native
6
Brad Bishop316dfdd2018-06-25 12:45:53 -04007SRC_URI_append = " https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz;name=bootstrap;subdir=go1.4"
8SRC_URI[bootstrap.md5sum] = "dbf727a4b0e365bf88d97cbfde590016"
9SRC_URI[bootstrap.sha256sum] = "f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050010
Brad Bishop6e60e8b2018-02-01 10:27:11 -050011export GOOS = "${BUILD_GOOS}"
12export GOARCH = "${BUILD_GOARCH}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050013CC = "${@d.getVar('BUILD_CC').strip()}"
14
Brad Bishop316dfdd2018-06-25 12:45:53 -040015GOMAKEARGS ?= "--no-banner"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050016
Brad Bishopd7bf8c12018-02-25 22:55:05 -050017do_configure() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040018 cd ${WORKDIR}/go1.4/go/src
19 CGO_ENABLED=0 GOROOT=${WORKDIR}/go1.4/go ./make.bash
Brad Bishopd7bf8c12018-02-25 22:55:05 -050020}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021
22do_compile() {
Brad Bishopd7bf8c12018-02-25 22:55:05 -050023 export GOROOT_FINAL="${nonstaging_libdir}/go"
24 export GOROOT_BOOTSTRAP="${WORKDIR}/go1.4/go"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025
26 cd src
Brad Bishop316dfdd2018-06-25 12:45:53 -040027 ./make.bash ${GOMAKEARGS}
28 cd ${B}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050029}
Brad Bishop316dfdd2018-06-25 12:45:53 -040030do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin"
31do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032
33make_wrapper() {
34 rm -f ${D}${bindir}/$2$3
35 cat <<END >${D}${bindir}/$2$3
36#!/bin/bash
37here=\`dirname \$0\`
Brad Bishopd7bf8c12018-02-25 22:55:05 -050038export GOROOT="${GOROOT:-\`readlink -f \$here/../lib/go\`}"
39\$here/../lib/go/bin/$1 "\$@"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050040END
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041 chmod +x ${D}${bindir}/$2
Brad Bishop6e60e8b2018-02-01 10:27:11 -050042}
43
44do_install() {
Brad Bishopd7bf8c12018-02-25 22:55:05 -050045 install -d ${D}${libdir}/go
46 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
47 install -d ${D}${libdir}/go/src
Brad Bishop6e60e8b2018-02-01 10:27:11 -050048 (cd ${S}/src; for d in *; do \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050049 [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050050 done)
Brad Bishop316dfdd2018-06-25 12:45:53 -040051 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
Brad Bishopd7bf8c12018-02-25 22:55:05 -050052 install -d ${D}${bindir} ${D}${libdir}/go/bin
Brad Bishop6e60e8b2018-02-01 10:27:11 -050053 for f in ${B}/bin/*
54 do
55 base=`basename $f`
Brad Bishopd7bf8c12018-02-25 22:55:05 -050056 install -m755 $f ${D}${libdir}/go/bin
57 make_wrapper $base $base
Brad Bishop6e60e8b2018-02-01 10:27:11 -050058 done
59}