blob: 3ac7211bc3cf211bd1f2d73762dd060a8e70fd91 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001inherit cross
2
Brad Bishopd7bf8c12018-02-25 22:55:05 -05003PROVIDES = "virtual/${TARGET_PREFIX}go"
4DEPENDS += "go-native"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005
6PN = "go-cross-${TARGET_ARCH}"
7
Brad Bishopd7bf8c12018-02-25 22:55:05 -05008export GOHOSTOS = "${BUILD_GOOS}"
9export GOHOSTARCH = "${BUILD_GOARCH}"
10export GOOS = "${TARGET_GOOS}"
11export GOARCH = "${TARGET_GOARCH}"
12export GOARM = "${TARGET_GOARM}"
13export GO386 = "${TARGET_GO386}"
14export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
15export GOROOT_FINAL = "${libdir}/go"
16export CGO_ENABLED = "1"
17export CC_FOR_TARGET="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
18export CXX_FOR_TARGET="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
19CC = "${@d.getVar('BUILD_CC').strip()}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050020
Brad Bishopd7bf8c12018-02-25 22:55:05 -050021do_configure[noexec] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050022
Brad Bishopd7bf8c12018-02-25 22:55:05 -050023do_compile() {
24 export GOBIN="${B}/bin"
25 rm -rf ${GOBIN} ${B}/pkg
26 mkdir ${GOBIN}
27 cd src
28 ./make.bash --host-only
29 cd ${B}
30}
Brad Bishop6e60e8b2018-02-01 10:27:11 -050031
Brad Bishopd7bf8c12018-02-25 22:55:05 -050032
33make_wrapper() {
34 rm -f ${D}${bindir}/$2
35 cat <<END >${D}${bindir}/$2
36#!/bin/bash
37here=\`dirname \$0\`
38export GOARCH="${TARGET_GOARCH}"
39export GOOS="${TARGET_GOOS}"
40export GOARM="\${GOARM:-${TARGET_GOARM}}"
41export GO386="\${GO386:-${TARGET_GO386}}"
42\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
43END
44 chmod +x ${D}${bindir}/$2
45}
46
47do_install() {
48 install -d ${D}${libdir}/go
49 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
50 install -d ${D}${libdir}/go/src
51 (cd ${S}/src; for d in *; do \
52 [ ! -d $d ] || cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \
53 done)
54 rm -rf ${D}${libdir}/go/src/runtime/pprof/testdata
55 install -d ${D}${bindir} ${D}${libdir}/go/bin
56 for f in ${B}/bin/*
57 do
58 base=`basename $f`
59 install -m755 $f ${D}${libdir}/go/bin
60 make_wrapper $base ${TARGET_PREFIX}$base
61 done
62}