blob: 29ce7f6e84555875bf8888013b3629be64e4a2b1 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001inherit cross
2
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08003PROVIDES = "virtual/${TUNE_PKGARCH}-go"
Brad Bishop316dfdd2018-06-25 12:45:53 -04004DEPENDS = "go-native"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08006PN = "go-cross-${TUNE_PKGARCH}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -05007
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}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040014export GOMIPS = "${TARGET_GOMIPS}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050015export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
16export GOROOT_FINAL = "${libdir}/go"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050017CC = "${@d.getVar('BUILD_CC').strip()}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050018
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019do_configure[noexec] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050020
Brad Bishopd7bf8c12018-02-25 22:55:05 -050021do_compile() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040022 export CC_FOR_${GOOS}_${GOARCH}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
23 export CXX_FOR_${GOOS}_${GOARCh}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
24 cd src
25 ./make.bash --host-only --no-banner
26 cd ${B}
Brad Bishopd7bf8c12018-02-25 22:55:05 -050027}
Brad Bishop316dfdd2018-06-25 12:45:53 -040028do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg"
29do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050030
31make_wrapper() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040032 rm -f ${D}${bindir}/$2
33 cat <<END >${D}${bindir}/$2
Brad Bishopd7bf8c12018-02-25 22:55:05 -050034#!/bin/bash
35here=\`dirname \$0\`
36export GOARCH="${TARGET_GOARCH}"
37export GOOS="${TARGET_GOOS}"
38export GOARM="\${GOARM:-${TARGET_GOARM}}"
39export GO386="\${GO386:-${TARGET_GO386}}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040040export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050041\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
42END
Brad Bishop316dfdd2018-06-25 12:45:53 -040043 chmod +x ${D}${bindir}/$2
Brad Bishopd7bf8c12018-02-25 22:55:05 -050044}
45
46do_install() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040047 install -d ${D}${libdir}/go
48 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
49 install -d ${D}${libdir}/go/src
50 (cd ${S}/src; for d in *; do \
51 [ ! -d $d ] || cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \
52 done)
53 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
54 install -d ${D}${bindir} ${D}${libdir}/go/bin
55 for f in ${B}/bin/*
56 do
57 base=`basename $f`
58 install -m755 $f ${D}${libdir}/go/bin
59 make_wrapper $base ${TARGET_PREFIX}$base
60 done
Brad Bishopd7bf8c12018-02-25 22:55:05 -050061}