From f6a562876bc2e99eaf787cf564fe4bb02c699301 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sun, 10 Jan 2016 19:45:41 -0500 Subject: [PATCH] Remove duplication of golang setup --- build-package.sh | 18 ++++++++++++++++++ packages/asciinema/build.sh | 20 +------------------- packages/golang/build.sh | 20 +------------------- 3 files changed, 20 insertions(+), 38 deletions(-) diff --git a/build-package.sh b/build-package.sh index 62da1df80..c1aea3cca 100755 --- a/build-package.sh +++ b/build-package.sh @@ -545,6 +545,24 @@ termux_step_create_debscripts () { } termux_setup_golang () { + export GOOS=android + export CGO_ENABLED=1 + export GO_LDFLAGS="-extldflags=-pie" + if [ "$TERMUX_ARCH" = "arm" ]; then + export GOARCH=arm + export GOARM=7 + elif [ "$TERMUX_ARCH" = "i686" ]; then + export GOARCH=386 + export GO386=sse2 + elif [ "$TERMUX_ARCH" = "aarch64" ]; then + export GOARCH=arm64 + elif [ "$TERMUX_ARCH" = "x86_64" ]; then + export GOARCH=amd64 + else + echo "ERROR: Unsupported arch: $TERMUX_ARCH" + exit 1 + fi + local TERMUX_GO_VERSION=go1.6beta1 local TERMUX_GO_PLATFORM=linux-amd64 test `uname` = "Darwin" && TERMUX_GO_PLATFORM=darwin-amd64 diff --git a/packages/asciinema/build.sh b/packages/asciinema/build.sh index 7acadeb81..6e4219fce 100644 --- a/packages/asciinema/build.sh +++ b/packages/asciinema/build.sh @@ -7,24 +7,7 @@ TERMUX_PKG_FOLDERNAME=asciinema-${TERMUX_PKG_VERSION} TERMUX_PKG_BUILD_IN_SRC=yes termux_step_make () { - export GOOS=android - export GO_LDFLAGS="-extldflags=-pie" - export CGO_ENABLED=1 - if [ "$TERMUX_ARCH" = "arm" ]; then - export GOARCH=arm - export GOARM=7 - elif [ "$TERMUX_ARCH" = "i686" ]; then - export GOARCH=386 - export GO386=sse2 - elif [ "$TERMUX_ARCH" = "aarch64" ]; then - export GOARCH=arm64 - elif [ "$TERMUX_ARCH" = "x86_64" ]; then - export GOARCH=amd64 - else - echo "ERROR: Unsupported arch: $TERMUX_ARCH" - exit 1 - fi - + termux_setup_golang export GOPATH=$TERMUX_PKG_TMPDIR cd $GOPATH mkdir -p src/github.com/asciinema/asciinema/ @@ -33,7 +16,6 @@ termux_step_make () { termux_step_make_install () { cd $GOPATH/src/github.com/asciinema/asciinema - termux_setup_golang PREFIX=$TERMUX_PREFIX make build PREFIX=$TERMUX_PREFIX make install } diff --git a/packages/golang/build.sh b/packages/golang/build.sh index 311757b2e..a26dc16b6 100644 --- a/packages/golang/build.sh +++ b/packages/golang/build.sh @@ -8,31 +8,13 @@ TERMUX_PKG_FOLDERNAME=go TERMUX_PKG_KEEP_STATIC_LIBRARIES=true termux_step_make_install () { - export GOOS=android - export CGO_ENABLED=1 - if [ "$TERMUX_ARCH" = "arm" ]; then - export GOARCH=arm - export GOARM=7 - elif [ "$TERMUX_ARCH" = "i686" ]; then - export GOARCH=386 - export GO386=sse2 - elif [ "$TERMUX_ARCH" = "aarch64" ]; then - export GOARCH=arm64 - elif [ "$TERMUX_ARCH" = "x86_64" ]; then - export GOARCH=amd64 - else - echo "ERROR: Unsupported arch: $TERMUX_ARCH" - exit 1 - fi + termux_setup_golang TERMUX_GOLANG_DIRNAME=${GOOS}_$GOARCH - TERMUX_GODIR=$TERMUX_PREFIX/lib/go rm -Rf $TERMUX_GODIR mkdir -p $TERMUX_GODIR/{src,pkg/tool/$TERMUX_GOLANG_DIRNAME,pkg/include,pkg/${TERMUX_GOLANG_DIRNAME}_shared} - termux_setup_golang - cd $TERMUX_PKG_SRCDIR/src env CC_FOR_TARGET=$CC \ CXX_FOR_TARGET=$CXX \