diff options
Diffstat (limited to 'meta/recipes-devtools/go/go-cross.inc')
-rw-r--r-- | meta/recipes-devtools/go/go-cross.inc | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/meta/recipes-devtools/go/go-cross.inc b/meta/recipes-devtools/go/go-cross.inc index 1c2d9e3a3d..df3e4ea914 100644 --- a/meta/recipes-devtools/go/go-cross.inc +++ b/meta/recipes-devtools/go/go-cross.inc | |||
@@ -1,15 +1,60 @@ | |||
1 | inherit cross | 1 | inherit cross |
2 | 2 | ||
3 | DEPENDS += "gcc-cross-${TARGET_ARCH}" | 3 | PROVIDES = "virtual/${TARGET_PREFIX}go" |
4 | DEPENDS += "go-native" | ||
4 | 5 | ||
5 | PN = "go-cross-${TARGET_ARCH}" | 6 | PN = "go-cross-${TARGET_ARCH}" |
6 | 7 | ||
7 | # Ignore how TARGET_ARCH is computed. | 8 | export GOHOSTOS = "${BUILD_GOOS}" |
8 | TARGET_ARCH[vardepvalue] = "${TARGET_ARCH}" | 9 | export GOHOSTARCH = "${BUILD_GOARCH}" |
9 | # Ignore target os libc for cross compiler | 10 | export GOOS = "${TARGET_GOOS}" |
10 | #TARGET_OS[vardepexclude] = "LIBCEXTENSION" | 11 | export GOARCH = "${TARGET_GOARCH}" |
11 | FILESEXTRAPATHS =. "${FILE_DIRNAME}/go-cross:" | 12 | export GOARM = "${TARGET_GOARM}" |
13 | export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" | ||
14 | export GOROOT_FINAL = "${libdir}/go" | ||
15 | export CGO_ENABLED = "1" | ||
16 | export CC_FOR_TARGET="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" | ||
17 | export CXX_FOR_TARGET="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" | ||
18 | CC = "${@d.getVar('BUILD_CC', True).strip()}" | ||
12 | 19 | ||
13 | GOROOT_FINAL = "${libdir}/go" | 20 | do_configure[noexec] = "1" |
14 | export GOROOT_FINAL | ||
15 | 21 | ||
22 | do_compile() { | ||
23 | export GOBIN="${B}/bin" | ||
24 | rm -rf ${GOBIN} ${B}/pkg | ||
25 | mkdir ${GOBIN} | ||
26 | cd src | ||
27 | ./make.bash --host-only | ||
28 | cd ${B} | ||
29 | } | ||
30 | |||
31 | |||
32 | make_wrapper() { | ||
33 | rm -f ${D}${bindir}/$2 | ||
34 | cat <<END >${D}${bindir}/$2 | ||
35 | #!/bin/bash | ||
36 | here=\`dirname \$0\` | ||
37 | export GOARCH="${TARGET_GOARCH}" | ||
38 | export GOOS="${TARGET_GOOS}" | ||
39 | export GOARM="${TARGET_GOARM}" | ||
40 | \$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@" | ||
41 | END | ||
42 | chmod +x ${D}${bindir}/$2 | ||
43 | } | ||
44 | |||
45 | do_install() { | ||
46 | install -d ${D}${libdir}/go | ||
47 | cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/ | ||
48 | install -d ${D}${libdir}/go/src | ||
49 | (cd ${S}/src; for d in *; do \ | ||
50 | [ ! -d $d ] || cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \ | ||
51 | done) | ||
52 | |||
53 | install -d ${D}${bindir} ${D}${libdir}/go/bin | ||
54 | for f in ${B}/bin/* | ||
55 | do | ||
56 | base=`basename $f` | ||
57 | install -m755 $f ${D}${libdir}/go/bin | ||
58 | make_wrapper $base ${TARGET_PREFIX}$base | ||
59 | done | ||
60 | } | ||