This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
make.bash
executable file
·152 lines (136 loc) · 4.51 KB
/
make.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
set -ex
REVSION=$(git rev-list --count HEAD)
LDFLAGS="-s -w -X main.version=r${REVSION}"
GOOS=${GOOS:-$(go env GOOS)}
GOARCH=${GOARCH:-$(go env GOARCH)}
CGO_ENABLED=${CGO_ENABLED:-$(go env CGO_ENABLED)}
REPO=$(git rev-parse --show-toplevel)
PACKAGE=$(basename ${REPO})
if [ "${CGO_ENABLED}" = "0" ]; then
BUILDROOT=${REPO}/build/${GOOS}_${GOARCH}
else
BUILDROOT=${REPO}/build/${GOOS}_${GOARCH}_cgo
fi
STAGEDIR=${BUILDROOT}/stage
OBJECTDIR=${BUILDROOT}/obj
DISTDIR=${BUILDROOT}/dist
if [ "${GOOS}" == "windows" ]; then
GOPROXY_EXE="${PACKAGE}.exe"
GOPROXY_STAGEDIR="${STAGEDIR}"
GOPROXY_DISTCMD="7za a -y -mx=9 -m0=lzma -mfb=128 -md=64m -ms=on"
GOPROXY_DISTEXT=".7z"
elif [ "${GOOS}" == "darwin" ]; then
GOPROXY_EXE="${PACKAGE}"
GOPROXY_STAGEDIR="${STAGEDIR}"
GOPROXY_DISTCMD="env BZIP=-9 tar cvjpf"
GOPROXY_DISTEXT=".tar.bz2"
elif [ "${GOARCH:0:3}" == "arm" ]; then
GOPROXY_EXE="${PACKAGE}"
GOPROXY_STAGEDIR="${STAGEDIR}"
GOPROXY_DISTCMD="env BZIP=-9 tar cvjpf"
GOPROXY_DISTEXT=".tar.bz2"
elif [ "${GOARCH:0:4}" == "mips" ]; then
GOPROXY_EXE="${PACKAGE}"
GOPROXY_STAGEDIR="${STAGEDIR}"
GOPROXY_DISTCMD="env GZIP=-9 tar cvzpf"
GOPROXY_DISTEXT=".tar.gz"
else
GOPROXY_EXE="${PACKAGE}"
GOPROXY_STAGEDIR="${STAGEDIR}/${PACKAGE}"
GOPROXY_DISTCMD="env XZ_OPT=-9 tar cvJpf"
GOPROXY_DISTEXT=".tar.xz"
fi
GOPROXY_DIST=${DISTDIR}/${PACKAGE}_${GOOS}_${GOARCH}-r${REVSION}${GOPROXY_DISTEXT}
if [ "${CGO_ENABLED}" = "1" ]; then
GOPROXY_DIST=${DISTDIR}/${PACKAGE}_${GOOS}_${GOARCH}_cgo-r${REVSION}${GOPROXY_DISTEXT}
fi
GOPROXY_GUI_EXE=${REPO}/assets/taskbar/${GOARCH}/goproxy-gui.exe
if [ ! -f "${GOPROXY_GUI_EXE}" ]; then
GOPROXY_GUI_EXE=${REPO}/assets/packaging/goproxy-gui.exe
fi
OBJECTS=${OBJECTDIR}/${GOPROXY_EXE}
SOURCES="${REPO}/README.md \
${REPO}/assets/packaging/gae.user.json.example \
${REPO}/httpproxy/filters/auth/auth.json \
${REPO}/httpproxy/filters/autoproxy/17monipdb.dat \
${REPO}/httpproxy/filters/autoproxy/autoproxy.json \
${REPO}/httpproxy/filters/autoproxy/gfwlist.txt \
${REPO}/httpproxy/filters/autoproxy/ip.html \
${REPO}/httpproxy/filters/autorange/autorange.json \
${REPO}/httpproxy/filters/direct/direct.json \
${REPO}/httpproxy/filters/gae/gae.json \
${REPO}/httpproxy/filters/php/php.json \
${REPO}/httpproxy/filters/rewrite/rewrite.json \
${REPO}/httpproxy/filters/stripssl/stripssl.json \
${REPO}/httpproxy/httpproxy.json \
${REPO}/httpproxy/filters/gae/gscan.conf \
${REPO}/httpproxy/filters/gae/iprange.conf"
if [ "${GOOS}" = "windows" ]; then
SOURCES="${SOURCES} \
${GOPROXY_GUI_EXE} \
${REPO}/assets/packaging/addto-startup.vbs \
${REPO}/assets/packaging/get-latest-goproxy.cmd"
elif [ "${GOOS}_${GOARCH}_${CGO_ENABLED}" = "linux_arm_0" ]; then
SOURCES="${SOURCES} \
${REPO}/assets/packaging/goproxy.sh \
${REPO}/assets/packaging/get-latest-goproxy.sh"
GOARM=${GORAM:-5}
elif [ "${GOOS}_${GOARCH}_${CGO_ENABLED}" = "linux_arm_1" ]; then
SOURCES="${SOURCES} \
${REPO}/assets/packaging/goproxy.sh \
${REPO}/assets/packaging/get-latest-goproxy.sh"
CC=${ARM_CC:-arm-linux-gnueabihf-gcc}
GOARM=${GORAM:-5}
elif [ "${GOOS}" = "darwin" ]; then
SOURCES="${SOURCES} \
${REPO}/assets/packaging/goproxy-macos.command \
${REPO}/assets/packaging/get-latest-goproxy.sh"
else
SOURCES="${SOURCES} \
${REPO}/assets/packaging/get-latest-goproxy.sh \
${REPO}/assets/packaging/goproxy-gtk.desktop \
${REPO}/assets/packaging/goproxy-gtk.png \
${REPO}/assets/packaging/goproxy-gtk.py \
${REPO}/assets/packaging/goproxy.sh"
fi
build () {
mkdir -p ${OBJECTDIR}
env GOOS=${GOOS} \
GOARCH=${GOARCH} \
GOARM=${GOARM} \
CGO_ENABLED=${CGO_ENABLED} \
CC=${CC} \
go build -v -ldflags="${LDFLAGS}" -o ${OBJECTDIR}/${GOPROXY_EXE} .
}
dist () {
mkdir -p ${DISTDIR} ${STAGEDIR} ${GOPROXY_STAGEDIR}
cp ${OBJECTS} ${SOURCES} ${GOPROXY_STAGEDIR}
pushd ${STAGEDIR}
${GOPROXY_DISTCMD} ${GOPROXY_DIST} *
popd
}
check () {
GOPROXY_WAIT_SECONDS=0 ${GOPROXY_STAGEDIR}/${GOPROXY_EXE}
}
clean () {
rm -rf ${BUILDROOT}
}
case $1 in
build)
build
;;
dist)
dist
;;
check)
check
;;
clean)
clean
;;
*)
build
dist
;;
esac