blob: 25437ddfe3485ba5056fdbe39e8e2ceb21710e04 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001inherit goarch
2DEPENDS += "go-bootstrap-native"
3
4# libgcc is required for the target specific libraries to build
5# properly, but apparently not for go-cross and, more importantly,
6# also can't be used there because go-cross cannot depend on
7# the tune-specific libgcc. Otherwise go-cross also would have
8# to be tune-specific.
9DEPENDS += "${@ 'libgcc' if not oe.utils.inherits(d, 'cross') else ''}"
10
11# Prevent runstrip from running because you get errors when the host arch != target arch
12INHIBIT_PACKAGE_STRIP = "1"
13INHIBIT_SYSROOT_STRIP = "1"
14
15# x32 ABI is not supported on go compiler so far
16COMPATIBLE_HOST_linux-gnux32 = "null"
17# ppc32 is not supported in go compilers
18COMPATIBLE_HOST_powerpc = "null"
19
20export GOHOSTOS = "${BUILD_GOOS}"
21export GOHOSTARCH = "${BUILD_GOARCH}"
22export GOOS = "${TARGET_GOOS}"
23export GOARCH = "${TARGET_GOARCH}"
24export GOARM = "${TARGET_GOARM}"
25export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go1.4"
26export GOROOT_FINAL = "${libdir}/go"
27export CGO_ENABLED = "1"
28export CC_FOR_TARGET = "${CC}"
29export CXX_FOR_TARGET = "${CXX}"
30
31do_configure[noexec] = "1"
32
33do_compile_prepend_class-cross() {
34 export CGO_ENABLED=0
35}
36
37do_compile() {
38 export GOBIN="${B}/bin"
39 export CC="${@d.getVar('BUILD_CC', True).strip()}"
40 rm -rf ${GOBIN} ${B}/pkg
41 mkdir ${GOBIN}
42
43 export TMPDIR=${WORKDIR}/build-tmp
44 mkdir -p ${WORKDIR}/build-tmp
45
46 cd src
47 ./make.bash --host-only
48 # Ensure cgo.a is built with the target toolchain
49 export GOBIN="${B}/target/bin"
50 rm -rf ${GOBIN}
51 mkdir -p ${GOBIN}
52 GO_FLAGS="-a" ./make.bash
53}
54
55do_install_class-target() {
56 install -d ${D}${libdir}/go
57 cp -a ${B}/pkg ${D}${libdir}/go/
58 install -d ${D}${libdir}/go/src
59 (cd ${S}/src; for d in *; do \
60 [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \
61 done)
62 install -d ${D}${bindir}
63 if [ -d ${B}/bin/${GOOS}_${GOARCH} ]
64 then
65 install -m 0755 ${B}/bin/${GOOS}_${GOARCH}/* ${D}${bindir}
66 else
67 install -m 0755 ${B}/bin/* ${D}${bindir}
68 fi
69}
70
71do_install_class-cross() {
72 install -d ${D}${libdir}/go
73 cp -a ${B}/pkg ${D}${libdir}/go/
74 install -d ${D}${libdir}/go/src
75 (cd ${S}/src; for d in *; do \
76 [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \
77 done)
78 install -d ${D}${bindir}
79 for f in ${B}/bin/go*
80 do
81 install -m755 $f ${D}${bindir}
82 done
83}
84do_package_qa[noexec] = "1"
85
86RDEPENDS_${PN} += "perl"