| Patrick Williams | d849ec7 | 2016-08-17 14:59:38 -0500 | [diff] [blame] | 1 | inherit cross | 
|  | 2 |  | 
| Patrick Williams | e69d235 | 2017-02-23 20:56:04 -0600 | [diff] [blame] | 3 | # libgcc is required for the target specific libraries to build properly | 
|  | 4 | DEPENDS += "go-native libgcc" | 
|  | 5 |  | 
|  | 6 | # Prevent runstrip from running because you get errors when the host arch != target arch | 
|  | 7 | #INHIBIT_PACKAGE_STRIP = "1" | 
|  | 8 | STRIP = "echo" | 
| Patrick Williams | d849ec7 | 2016-08-17 14:59:38 -0500 | [diff] [blame] | 9 |  | 
|  | 10 | export GOHOSTOS = "${BUILD_GOOS}" | 
|  | 11 | export GOHOSTARCH = "${BUILD_GOARCH}" | 
|  | 12 | export GOOS = "${TARGET_GOOS}" | 
|  | 13 | export GOARCH = "${TARGET_GOARCH}" | 
|  | 14 | export GOARM = "${TARGET_GOARM}" | 
|  | 15 | export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go" | 
|  | 16 | export GOROOT_FINAL = "${libdir}/go" | 
|  | 17 | export CGO_ENABLED = "1" | 
|  | 18 | export CC_FOR_TARGET="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" | 
|  | 19 | export CXX_FOR_TARGET="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}" | 
|  | 20 | CC = "${@d.getVar('BUILD_CC', True).strip()}" | 
|  | 21 |  | 
|  | 22 | do_configure[noexec] = "1" | 
|  | 23 |  | 
|  | 24 | do_compile() { | 
|  | 25 | export GOBIN="${B}/bin" | 
|  | 26 | rm -rf ${GOBIN} ${B}/pkg | 
|  | 27 | mkdir ${GOBIN} | 
|  | 28 |  | 
|  | 29 | export TMPDIR=${WORKDIR}/build-tmp | 
|  | 30 | mkdir -p ${WORKDIR}/build-tmp | 
|  | 31 |  | 
|  | 32 | cd src | 
|  | 33 | ./make.bash --host-only | 
| Patrick Williams | e69d235 | 2017-02-23 20:56:04 -0600 | [diff] [blame] | 34 | # Ensure cgo.a is built with the target toolchain | 
|  | 35 | export GOBIN="${B}/target/bin" | 
|  | 36 | rm -rf ${GOBIN} | 
|  | 37 | mkdir -p ${GOBIN} | 
|  | 38 | GO_FLAGS="-a" ./make.bash | 
| Patrick Williams | d849ec7 | 2016-08-17 14:59:38 -0500 | [diff] [blame] | 39 | } | 
|  | 40 |  | 
|  | 41 | do_install() { | 
|  | 42 | install -d ${D}${libdir}/go | 
|  | 43 | cp -a ${B}/pkg ${D}${libdir}/go/ | 
|  | 44 | install -d ${D}${libdir}/go/src | 
|  | 45 | (cd ${S}/src; for d in *; do \ | 
|  | 46 | [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \ | 
|  | 47 | done) | 
|  | 48 | install -d ${D}${bindir} | 
|  | 49 | for f in ${B}/bin/* | 
|  | 50 | do | 
|  | 51 | install -m755 $f ${D}${bindir} | 
|  | 52 | done | 
|  | 53 | } | 
|  | 54 |  | 
|  | 55 | do_package[noexec] = "1" | 
|  | 56 | do_packagedata[noexec] = "1" | 
|  | 57 | do_package_write_ipk[noexec] = "1" | 
|  | 58 | do_package_write_deb[noexec] = "1" | 
|  | 59 | do_package_write_rpm[noexec] = "1" |