blob: 3d344a74d3ddfbf65c9244f1f0be6a84090333a7 [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 Bishopc8f47122019-06-24 09:36:18 -040017export GOCACHE = "${B}/.cache"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050018CC = "${@d.getVar('BUILD_CC').strip()}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050019
Brad Bishopd7bf8c12018-02-25 22:55:05 -050020do_configure[noexec] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021
Brad Bishopd7bf8c12018-02-25 22:55:05 -050022do_compile() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040023 export CC_FOR_${GOOS}_${GOARCH}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
24 export CXX_FOR_${GOOS}_${GOARCh}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
25 cd src
26 ./make.bash --host-only --no-banner
27 cd ${B}
Brad Bishopd7bf8c12018-02-25 22:55:05 -050028}
Brad Bishop316dfdd2018-06-25 12:45:53 -040029do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg"
30do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050031
32make_wrapper() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040033 rm -f ${D}${bindir}/$2
34 cat <<END >${D}${bindir}/$2
Brad Bishopd7bf8c12018-02-25 22:55:05 -050035#!/bin/bash
36here=\`dirname \$0\`
37export GOARCH="${TARGET_GOARCH}"
38export GOOS="${TARGET_GOOS}"
39export GOARM="\${GOARM:-${TARGET_GOARM}}"
40export GO386="\${GO386:-${TARGET_GO386}}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040041export GOMIPS="\${GOMIPS:-${TARGET_GOMIPS}}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050042\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
43END
Brad Bishop316dfdd2018-06-25 12:45:53 -040044 chmod +x ${D}${bindir}/$2
Brad Bishopd7bf8c12018-02-25 22:55:05 -050045}
46
47do_install() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040048 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 find ${D}${libdir}/go/src -depth -type d -name testdata -exec rm -rf {} \;
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
Brad Bishopd7bf8c12018-02-25 22:55:05 -050062}