Mail archive
alpine-aports

[alpine-aports] [PATCH] main/go: add cross subpackage

From: Sören Tempel <soeren+git_at_soeren-tempel.net>
Date: Fri, 14 Aug 2015 22:51:31 +0200

The cross subpackages ships cross compilers for Darwin, FreeBSD, OpenBSD
and Microsoft Windows. Those are not all platforms theoretically
supported by go but I guess those are the most relevant once.

In the future it might be a good idea to add cross compilers for other
platforms and architectures as well but before doing so you probably
want to create one subpackage for each platform otherwise the cross
subpackage gets too big.

My computer is too slow to compile go for all these platforms and
architectures in a timely manner so I only compiled the go cross
compiler for OpenBSD amd64 and OpenBSD i386. In addition to that the
OpenBSD amd64 cross compiler was successfully used to cross compile a
small program.

If you have access to a faster computer then please test this on other
architectures (Darwin, FreeBSD and Microsoft Windows).
---
 main/go/APKBUILD | 43 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 36 insertions(+), 7 deletions(-)
diff --git a/main/go/APKBUILD b/main/go/APKBUILD
index d875802..46a829c 100644
--- a/main/go/APKBUILD
+++ b/main/go/APKBUILD
_at_@ -4,7 +4,7 @@ pkgname=go
 pkgver=1.4.2
 # This should be the latest commit on the corresponding release branch
 _toolsver="abf43428cc239218424c7a44dc9b5987cd351c3e"
-pkgrel=1
+pkgrel=2
 pkgdesc="Go programming language compiler"
 url="http://www.golang.org/"
 arch="x86 x86_64 armhf"
_at_@ -14,7 +14,7 @@ depends_dev=""
 makedepends="bash perl"
 options="!strip"
 install=""
-subpackages="$pkgname-tools:tools"
+subpackages="$pkgname-tools:tools $pkgname-cross:cross"
 source="
 	http://golang.org/dl/go${pkgver}.src.tar.gz
 	tools.tar.gz::https://github.com/golang/tools/archive/${_toolsver}.tar.gz
_at_@ -44,20 +44,31 @@ build() {
 	export GOROOT="$_builddir"
 	export GOBIN="$GOROOT"/bin
 	export GOROOT_FINAL=/usr/lib/go
+
 	# ccache breaks build for some reason
 	unset CC
 
 	case "$CARCH" in
-	x86) GOARCH=386;;
-	x86_64) GOARCH=amd64;;
-	arm*) GOARCH=arm; export GOARM=6;;
-	*) return 1;;
+	x86)
+		export GOARCH="386" ;;
+	x86_64)
+		export GOARCH="amd64" ;;
+	arm*)
+		export GOARCH="arm"
+		export GOARM="6" ;;
+	*)
+		return 1 ;;
 	esac
-	export GOARCH
 
 	cd "$_builddir/src"
 	./make.bash || return 1
 
+	for os in darwin freebsd openbsd windows; do
+		for arch in "386" "amd64"; do
+			GOARCH=$arch GOOS=$os ./make.bash --no-clean || return 1
+		done
+	done
+
 	# FIXME: race and bench tests fail:
 	#PATH="$GOROOT/bin:$PATH" ./run.bash --no-rebuild --banner || return 1
 
_at_@ -116,6 +127,24 @@ tools() {
 	done
 }
 
+cross() {
+	pkgdesk="Go cross compilers"
+	depends="$pkgname"
+
+	mkdir -p "$subpkgdir"/usr/lib/go/pkg/tool \
+		"$subpkgdir"/usr/lib/go/src/runtime
+
+	for os in darwin freebsd openbsd windows; do
+		mv "$pkgdir"/usr/lib/go/pkg/tool/${os}_* \
+			"$subpkgdir"/usr/lib/go/pkg/tool || return 1
+		mv "$pkgdir"/usr/lib/go/pkg/${os}_* \
+			"$subpkgdir"/usr/lib/go/pkg || return 1
+		mv "$pkgdir"/usr/lib/go/src/runtime/zasm_${os}*.h \
+			"$subpkgdir"/usr/lib/go/src/runtime || return 1
+	done
+
+}
+
 md5sums="907f85c8fa765d31f7f955836fec4049  go1.4.2.src.tar.gz
 a8bc7ad3d0deff01bd45e4938cc3adb6  tools.tar.gz
 65330c61f6d6c881033b0a95ca228edb  no-werror.patch
-- 
2.5.0
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Fri Aug 14 2015 - 22:51:31 GMT