blob: 95db1c2b7c5a2ce6353f8053edc10cb428f6aeb6 [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 Bishopd7bf8c12018-02-25 22:55:05 -05007SRC_URI_append = " http://golang.org/dl/go1.4.3.src.tar.gz;name=bootstrap;subdir=go1.4"
8SRC_URI[bootstrap.md5sum] = "dfb604511115dd402a77a553a5923a04"
9SRC_URI[bootstrap.sha256sum] = "9947fc705b0b841b5938c48b22dc33e9647ec0752bae66e50278df4f23f64959"
10
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 Bishop6e60e8b2018-02-01 10:27:11 -050015export CGO_ENABLED = "1"
16
Brad Bishopd7bf8c12018-02-25 22:55:05 -050017do_configure() {
18 cd ${WORKDIR}/go1.4/go/src
19 CGO_ENABLED=0 GOROOT=${WORKDIR}/go1.4/go ./make.bash
20}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021
22do_compile() {
23 export GOBIN="${B}/bin"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050024 export GOROOT_FINAL="${nonstaging_libdir}/go"
25 export GOROOT_BOOTSTRAP="${WORKDIR}/go1.4/go"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026 rm -rf ${GOBIN}
27 mkdir ${GOBIN}
28
29 export TMPDIR=${WORKDIR}/build-tmp
30 mkdir -p ${WORKDIR}/build-tmp
31
32 cd src
Brad Bishopd7bf8c12018-02-25 22:55:05 -050033 ./make.bash --host-only
Brad Bishop6e60e8b2018-02-01 10:27:11 -050034}
35
36make_wrapper() {
37 rm -f ${D}${bindir}/$2$3
38 cat <<END >${D}${bindir}/$2$3
39#!/bin/bash
40here=\`dirname \$0\`
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041export GOROOT="${GOROOT:-\`readlink -f \$here/../lib/go\`}"
42\$here/../lib/go/bin/$1 "\$@"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043END
Brad Bishopd7bf8c12018-02-25 22:55:05 -050044 chmod +x ${D}${bindir}/$2
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045}
46
47do_install() {
Brad Bishopd7bf8c12018-02-25 22:55:05 -050048 install -d ${D}${libdir}/go
49 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
50 install -d ${D}${libdir}/go/src
Brad Bishop6e60e8b2018-02-01 10:27:11 -050051 (cd ${S}/src; for d in *; do \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050052 [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050053 done)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050054 rm -rf ${D}${libdir}/go/src/runtime/pprof/testdata
55 install -d ${D}${bindir} ${D}${libdir}/go/bin
Brad Bishop6e60e8b2018-02-01 10:27:11 -050056 for f in ${B}/bin/*
57 do
58 base=`basename $f`
Brad Bishopd7bf8c12018-02-25 22:55:05 -050059 install -m755 $f ${D}${libdir}/go/bin
60 make_wrapper $base $base
Brad Bishop6e60e8b2018-02-01 10:27:11 -050061 done
62}