forked from syncthing/syncthing-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-go.bash
executable file
·96 lines (76 loc) · 1.78 KB
/
make-go.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
set -e
MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export CGO_ENABLED=0
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)
export GOOS=linux
export GOARCH=arm
export GOARM=5
;;
arm64)
export GOOS=linux
export GOARCH=arm64
unset GOARM
;;
386)
export GOOS=linux
export GOARCH=386
export GO386=387
;;
*)
echo "Invalid architecture"
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
git reset --hard HEAD
# Apply patches to Golang
for PATCH in $MYDIR/patches/golang/all/*.patch; do
echo "Applying $PATCH"
patch -p1 <$PATCH
done
set +e
./clean.bash
rm -r ../bin
rm -r ../pkg
set -e
if [ ! -e ../VERSION ]; then
echo "$(git describe --tags)" > ../VERSION
fi
BUILDER_EXT=bash
case "$(uname)" in
*MINGW* | *WIN32* | *CYGWIN*)
BUILDER_EXT=bat
;;
esac
./make.${BUILDER_EXT} --no-banner
cp -a ../bin "${GOROOT_FINAL}"/
cp -a ../pkg "${GOROOT_FINAL}"/
cp -a ../src "${GOROOT_FINAL}"/
if [[ -e ./make.${BUILDER_EXT} ]]; then
pushd ../
git clean -f
popd
fi
popd
echo "Complete"