diff options
author | Timo Teräs <timo.teras@iki.fi> | 2017-02-23 14:49:19 +0000 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2017-02-27 06:23:05 +0000 |
commit | f5c4b298918ba1d5ff85861cdeed9eff2cbcd5b9 (patch) | |
tree | 19e3047a9452bbbe6128e68e0dd54290e77abd65 /community/go | |
parent | fb8794efbe6d82492a0adaec70c880e10c1e67f0 (diff) | |
download | aports-f5c4b298918ba1d5ff85861cdeed9eff2cbcd5b9.tar.bz2 aports-f5c4b298918ba1d5ff85861cdeed9eff2cbcd5b9.tar.xz |
community/go: cross-build support
Diffstat (limited to 'community/go')
-rw-r--r-- | community/go/APKBUILD | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/community/go/APKBUILD b/community/go/APKBUILD index 5de082af39..afdaa0cbc5 100644 --- a/community/go/APKBUILD +++ b/community/go/APKBUILD @@ -15,24 +15,37 @@ makedepends="bash go-bootstrap" options="!strip" provides="go-bootstrap=$pkgver-r$pkgrel" install="" -subpackages="$pkgname-doc $pkgname-tools" +subpackages="$pkgname-doc" source="http://golang.org/dl/go${pkgver/_/}.src.tar.gz - $pkgname-tools-${pkgver/_/}.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz + go-tools-${pkgver/_/}.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz default-buildmode-pie.patch " # NOTE: building go for x86 with grsec kernel requires: # sysctl -w kernel.modify_ldt=1 -_gotools="cover godoc stringer" -_tooldir="$srcdir"/tools-${_toolsver} +if [ "$CBUILD" = "$CTARGET" ]; then + makedepends="go-bootstrap $makedepends" + provides="go-bootstrap=$pkgver-r$pkgrel" + subpackages="$subpackages $pkgname-tools" + _gotools="cover godoc stringer" + _gocross="darwin freebsd openbsd windows" +else + pkgname="go-bootstrap" + makedepends="go $makedepends" + # Go expect host linker instead of the cross-compiler + export CC_FOR_TARGET="$CC" + export CC="${HOSTLD:-gcc}" + export CXX="${HOSTLD:-g++}" + export LD="${HOSTLD:-ld}" +fi -_gocross="darwin freebsd openbsd windows" +_tooldir="$srcdir"/tools-${_toolsver} for os in $_gocross; do subpackages="$subpackages $pkgname-cross-${os}:_crosspkg" done -builddir="$srcdir"/$pkgname +builddir="$srcdir"/go build() { cd "$builddir/src" @@ -46,6 +59,7 @@ build() { *) die "Unsupported arch" ;; esac + export GOOS="linux" export GOPATH="$srcdir" export GOROOT="$builddir" export GOBIN="$GOROOT"/bin @@ -64,6 +78,16 @@ build() { done done + # copied from bootstrap.bash to fixup cross-built bootstrap go + if [ "$CBUILD" != "$CTARGET" ]; then + local gohostos="$(../bin/go env GOHOSTOS)" + local gohostarch="$(../bin/go env GOHOSTARCH)" + mv ../bin/*_*/* ../bin + rmdir ../bin/*_* + rm -rf "../pkg/${gohostos}_${gohostarch}"* "../pkg/tool/${gohostos}_${gohostarch}"* + rm -rf ../pkg/bootstrap ../pkg/obj + fi + # FIXME some tests fail: # PATH="$GOROOT/bin:$PATH" ./run.bash -no-rebuild || return 1 |