blob: 94f6fb8eb767d967a7af2dfc619cef79690a5645 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001inherit crosssdk
2
3DEPENDS = "go-native virtual/${TARGET_PREFIX}gcc-crosssdk virtual/nativesdk-${TARGET_PREFIX}compilerlibs virtual/${TARGET_PREFIX}binutils-crosssdk"
Brad Bishop19323692019-04-05 15:28:33 -04004PN = "go-crosssdk-${SDK_SYS}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005PROVIDES = "virtual/${TARGET_PREFIX}go-crosssdk"
6
7export GOHOSTOS = "${BUILD_GOOS}"
8export GOHOSTARCH = "${BUILD_GOARCH}"
9export GOOS = "${TARGET_GOOS}"
10export GOARCH = "${TARGET_GOARCH}"
11export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
12export GOROOT_FINAL = "${libdir}/go"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050013
14do_configure[noexec] = "1"
15
16do_compile() {
Brad Bishop316dfdd2018-06-25 12:45:53 -040017 export CC_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}"
18 export CXX_FOR_${TARGET_GOOS}_${TARGET_GOARCH}="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}${SDKPATHNATIVE}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019 cd src
Brad Bishop316dfdd2018-06-25 12:45:53 -040020 ./make.bash --host-only --no-banner
Brad Bishopd7bf8c12018-02-25 22:55:05 -050021 cd ${B}
22}
Brad Bishop316dfdd2018-06-25 12:45:53 -040023do_compile[dirs] =+ "${GOTMPDIR} ${B}/bin ${B}/pkg"
24do_compile[cleandirs] += "${GOTMPDIR} ${B}/bin ${B}/pkg"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050025
26make_wrapper() {
27 rm -f ${D}${bindir}/$2
28 cat <<END >${D}${bindir}/$2
29#!/bin/bash
30here=\`dirname \$0\`
31export GOARCH="${TARGET_GOARCH}"
32export GOOS="${TARGET_GOOS}"
33\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
34END
35 chmod +x ${D}${bindir}/$2
36}
37
38do_install() {
39 install -d ${D}${libdir}/go
40 install -d ${D}${libdir}/go/bin
41 install -d ${D}${libdir}/go/pkg/tool
42 install -d ${D}${bindir}
43 cp --preserve=mode,timestamps -R ${S}/pkg/tool/${BUILD_GOTUPLE} ${D}${libdir}/go/pkg/tool/
44 for f in ${B}/bin/*
45 do
46 base=`basename $f`
47 install -m755 $f ${D}${libdir}/go/bin
48 make_wrapper $base ${TARGET_PREFIX}$base
49 done
50}