2015-11-13 22:38:17 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2016-04-26 19:35:03 +00:00
|
|
|
export CGO_ENABLED=0
|
|
|
|
|
2015-11-13 22:38:17 +00:00
|
|
|
if [ -z "$GOROOT_BOOTSTRAP" ]; then
|
|
|
|
# We need Go 1.4 to bootstrap Go 1.5
|
|
|
|
if [ -z $GOROOT ] || [[ $(go version) != go\ version\ go1.4* ]] ; then
|
|
|
|
git submodule update --init ext/golang/go1.4
|
|
|
|
# Build Go 1.4 for host
|
|
|
|
pushd ext/golang/go1.4/src
|
|
|
|
./make.bash --no-clean
|
|
|
|
popd
|
|
|
|
# Add Go 1.4 to the environment
|
|
|
|
export GOROOT="$(pwd)/ext/golang/go1.4"
|
|
|
|
fi
|
|
|
|
# Add Go 1.4 compiler to PATH
|
|
|
|
export GOROOT_BOOTSTRAP=$GOROOT
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
arm)
|
2016-02-10 18:21:39 +00:00
|
|
|
export GOOS=linux
|
2015-11-13 22:38:17 +00:00
|
|
|
export GOARCH=arm
|
|
|
|
export GOARM=5
|
|
|
|
;;
|
2016-09-06 15:44:09 +00:00
|
|
|
arm64)
|
|
|
|
export GOOS=linux
|
|
|
|
export GOARCH=arm64
|
2017-03-10 12:34:19 +00:00
|
|
|
unset GOARM
|
2016-09-06 15:44:09 +00:00
|
|
|
;;
|
2015-11-13 22:38:17 +00:00
|
|
|
386)
|
2016-02-10 18:21:39 +00:00
|
|
|
export GOOS=linux
|
2015-11-13 22:38:17 +00:00
|
|
|
export GOARCH=386
|
|
|
|
export GO386=387
|
|
|
|
;;
|
|
|
|
*)
|
2016-09-06 15:44:09 +00:00
|
|
|
echo "Invalid architecture"
|
2015-11-13 22:38:17 +00:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
unset GOPATH
|
|
|
|
|
|
|
|
export GOROOT_FINAL=${MYDIR}/ext/golang/dist/go-${GOOS}-${GOARCH}
|
|
|
|
|
|
|
|
if [ -d "$GOROOT_FINAL" ]; then
|
|
|
|
rm -r "$GOROOT_FINAL"
|
|
|
|
fi
|
|
|
|
mkdir -p "$GOROOT_FINAL"
|
|
|
|
|
|
|
|
pushd ext/golang/go/src
|
|
|
|
|
2016-04-02 00:42:50 +00:00
|
|
|
git reset --hard HEAD
|
|
|
|
|
2016-03-28 14:57:42 +00:00
|
|
|
# Apply patches to Golang
|
|
|
|
for PATCH in $MYDIR/patches/golang/all/*.patch; do
|
2016-04-02 00:42:50 +00:00
|
|
|
echo "Applying $PATCH"
|
|
|
|
patch -p1 <$PATCH
|
2016-03-28 14:57:42 +00:00
|
|
|
done
|
|
|
|
|
2015-11-13 22:38:17 +00:00
|
|
|
set +e
|
|
|
|
./clean.bash
|
|
|
|
rm -r ../bin
|
|
|
|
rm -r ../pkg
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ ! -e ../VERSION ]; then
|
|
|
|
echo "$(git describe --tags)" > ../VERSION
|
|
|
|
fi
|
|
|
|
|
2016-11-30 21:42:23 +00:00
|
|
|
BUILDER_EXT=bash
|
|
|
|
case "$(uname)" in
|
|
|
|
*MINGW* | *WIN32* | *CYGWIN*)
|
|
|
|
BUILDER_EXT=bat
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
./make.${BUILDER_EXT} --no-banner
|
|
|
|
|
2015-11-13 22:38:17 +00:00
|
|
|
cp -a ../bin "${GOROOT_FINAL}"/
|
|
|
|
cp -a ../pkg "${GOROOT_FINAL}"/
|
|
|
|
cp -a ../src "${GOROOT_FINAL}"/
|
|
|
|
|
2016-11-30 21:42:23 +00:00
|
|
|
if [[ -e ./make.${BUILDER_EXT} ]]; then
|
2015-11-13 22:38:17 +00:00
|
|
|
pushd ../
|
|
|
|
git clean -f
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
echo "Complete"
|
|
|
|
|