-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathMakefile
284 lines (239 loc) · 10.9 KB
/
Makefile
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
PROJECT=ztf
VERSION:=$(shell head -n 1 VERSION)
ifeq ($(OS),Windows_NT)
PLATFORM="Windows"
else
ifeq ($(shell uname),Darwin)
PLATFORM="Mac"
else
PLATFORM="Unix"
endif
endif
QINIU_DIR="${HOME}/work/zentao/qiniu/"
QINIU_DIST_DIR=${QINIU_DIR}${PROJECT}/${VERSION}/
SERVER_MAIN_FILE=cmd/server/main.go
COMMAND_MAIN_DIR=cmd/command/
COMMAND_MAIN_FILE=${COMMAND_MAIN_DIR}main.go
COMMAND_BIN_DIR=bin/
CLIENT_BIN_DIR=client/bin/
CLIENT_OUT_DIR=client/out/
BUILD_TIME=`git show -s --format=%cd`
GO_VERSION=`go version`
GIT_HASH=`git show -s --format=%H`
BUILD_CMD=go build -ldflags "-X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'"
BUILD_CMD_WIN=go build -ldflags "-s -w -X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'"
default: win64 linux linux_arm64 mac
server: server_win64 server_linux server_linux_arm64 server_mac
server_win64: prepare compile_server_win64 copy_files_win64 zip_server_win64
server_linux: prepare compile_server_linux copy_files_linux zip_server_linux
server_linux_arm64: prepare compile_server_linux_arm64 copy_files_linux_arm64 zip_server_linux_arm64
server_mac: prepare compile_server_mac copy_files_mac zip_server_mac
win64: prepare compile_server_win64 package_gui_win64_client compile_launcher_win64 compile_command_win64 copy_files_win64 zip_server_win64 zip_client_win64
linux: prepare compile_server_linux package_gui_linux_client compile_command_linux copy_files_linux zip_server_linux zip_client_linux
linux_arm64: prepare compile_server_linux_arm64 package_gui_linux_client_arm64 compile_command_linux_arm64 copy_files_linux_arm64 zip_server_linux_arm64 zip_client_linux_arm64
mac: prepare compile_server_mac package_gui_mac_client compile_command_mac copy_files_mac zip_server_mac zip_client_mac
prepare: update_version prepare_res
# update_version: update_version_in_config gen_version_file
update_version: gen_version_file
update_version_in_config:
ifeq ($(PLATFORM),"Mac")
@gsed -i "s/Version.*/Version = ${VERSION}/" conf/ztf.conf
else
@sed -i "s/Version.*/Version = ${VERSION}/" conf/ztf.conf
endif
gen_version_file:
@echo 'gen version'
@mkdir -p ${QINIU_DIR}/${PROJECT}/
@echo ${VERSION} > ${QINIU_DIR}/${PROJECT}/version.txt
compile_ui:
@cd ui && yarn install && yarn build && cd ..
prepare_res:
@echo 'start prepare res'
@rm -rf res/res.go
@go-bindata -o=res/res.go -pkg=res res/...
@mkdir -p ${QINIU_DIR}
# launcher
compile_launcher_win64:
@echo 'start compile win64 launcher'
@cd cmd/launcher && \
GOOS=windows GOARCH=amd64 \
${BUILD_CMD} -x -v \
-o ../../${COMMAND_BIN_DIR}win64/${PROJECT}-gui.exe && \
cd ..
# server
compile_server_win64:
@echo 'start compile server win64'
@rm -rf ${COMMAND_BIN_DIR}win64/${PROJECT}-server.exe
@GOOS=windows GOARCH=amd64 \
${BUILD_CMD_WIN} -x -v \
-o ${COMMAND_BIN_DIR}win64/${PROJECT}-server.exe ${SERVER_MAIN_FILE}
compile_server_linux:
@echo 'start compile server linux'
@rm -rf ${COMMAND_BIN_DIR}linux/${PROJECT}-server
ifeq ($(PLATFORM),"Mac")
GOOS=linux GOARCH=amd64 \
${BUILD_CMD} \
-o ${COMMAND_BIN_DIR}linux/${PROJECT}-server ${SERVER_MAIN_FILE}
else
GOOS=linux GOARCH=amd64 \
${BUILD_CMD} \
-o ${COMMAND_BIN_DIR}linux/${PROJECT}-server ${SERVER_MAIN_FILE}
endif
compile_server_linux_arm64:
@echo 'start compile server linux for arm64'
@rm -rf ${COMMAND_BIN_DIR}linux_arm64/${PROJECT}-server
@GOOS=linux GOARCH=arm64 GOARM=7 \
${BUILD_CMD} \
-o ${COMMAND_BIN_DIR}linux_arm64/${PROJECT}-server ${SERVER_MAIN_FILE}
compile_server_mac:
@echo 'start compile mac'
@rm -rf ${COMMAND_BIN_DIR}darwin/${PROJECT}-server
@GOOS=darwin GOARCH=amd64 \
${BUILD_CMD} \
-o ${COMMAND_BIN_DIR}darwin/${PROJECT}-server ${SERVER_MAIN_FILE}
# gui
package_gui_win64_client:
@echo 'start package gui win64'
@rm -rf ${CLIENT_BIN_DIR}/* && mkdir -p ${CLIENT_BIN_DIR}win32
@cp -rf ${COMMAND_BIN_DIR}win64/${PROJECT}-server.exe ${CLIENT_BIN_DIR}win32/${PROJECT}.exe
@cd client && npm run package-windows-amd64 && cd ..
@rm -rf ${CLIENT_OUT_DIR}win64 && mkdir -p ${CLIENT_OUT_DIR}win64 && \
mv ${CLIENT_OUT_DIR}${PROJECT}-win32-x64 ${CLIENT_OUT_DIR}win64/gui
package_gui_linux_client:
@echo 'start package gui linux'
@rm -rf ${CLIENT_BIN_DIR}/* && mkdir -p ${CLIENT_BIN_DIR}linux
@cp -rf ${COMMAND_BIN_DIR}linux/${PROJECT}-server ${CLIENT_BIN_DIR}linux/${PROJECT}
@cd client && npm run package-linux-amd64 && cd ..
@rm -rf ${CLIENT_OUT_DIR}linux && mkdir -p ${CLIENT_OUT_DIR}linux && \
mv ${CLIENT_OUT_DIR}${PROJECT}-linux-x64 ${CLIENT_OUT_DIR}linux/gui
package_gui_linux_client_arm64:
@echo 'start package gui linux for arm64'
@rm -rf ${CLIENT_BIN_DIR}/* && mkdir -p ${CLIENT_BIN_DIR}linux
@cp -rf ${COMMAND_BIN_DIR}linux_arm64/${PROJECT}-server ${CLIENT_BIN_DIR}linux/${PROJECT}
@cd client && npm run package-linux-arm64 && cd ..
@rm -rf ${CLIENT_OUT_DIR}linux_arm64 && mkdir -p ${CLIENT_OUT_DIR}linux_arm64 && \
mv ${CLIENT_OUT_DIR}${PROJECT}-linux-arm64 ${CLIENT_OUT_DIR}linux_arm64/gui
package_gui_mac_client:
@echo 'start package gui mac'
@rm -rf ${CLIENT_BIN_DIR}/* && mkdir -p ${CLIENT_BIN_DIR}darwin
@cp -rf ${COMMAND_BIN_DIR}darwin/${PROJECT}-server ${CLIENT_BIN_DIR}darwin/${PROJECT}
@cd client && npm install && npm run package-darwin-amd64 && cd ..
@rm -rf ${CLIENT_OUT_DIR}darwin && mkdir -p ${CLIENT_OUT_DIR}darwin && \
mv ${CLIENT_OUT_DIR}${PROJECT}-darwin-x64 ${CLIENT_OUT_DIR}darwin/gui && \
mv ${CLIENT_OUT_DIR}darwin/gui/ztf.app ${CLIENT_OUT_DIR}darwin/ztf.app && rm -rf ${CLIENT_OUT_DIR}darwin/gui
# command line
compile_command_win64:
@echo 'start compile win64'
@GOOS=windows GOARCH=amd64 \
${BUILD_CMD} -x -v \
-o ${COMMAND_BIN_DIR}win64/${PROJECT}.exe ${COMMAND_MAIN_FILE}
compile_command_linux:
@echo 'start compile linux'
ifeq ($(PLATFORM),"Mac")
@GOOS=linux GOARCH=amd64 \
${BUILD_CMD} \
-o ${COMMAND_BIN_DIR}linux/${PROJECT} ${COMMAND_MAIN_FILE}
else
GOOS=linux GOARCH=amd64 CC=gcc CXX=g++ \
${BUILD_CMD} \
-o ${COMMAND_BIN_DIR}linux/${PROJECT} ${COMMAND_MAIN_FILE}
endif
compile_command_linux_arm64:
@echo 'start compile linux for arm64'
GOOS=linux GOARCH=arm64 GOARM=7 CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ AR=aarch64-linux-gnu-ar \
${BUILD_CMD} \
-o ${COMMAND_BIN_DIR}linux_arm64/${PROJECT} ${COMMAND_MAIN_FILE}
compile_command_mac:
@echo 'start compile darwin'
@GOOS=darwin GOARCH=amd64 \
${BUILD_CMD} \
-o ${COMMAND_BIN_DIR}darwin/${PROJECT} ${COMMAND_MAIN_FILE}
copy_files_win64:
@echo 'start copy files win64'
@cp -r demo "${CLIENT_OUT_DIR}win64"
@cp -r demo "${COMMAND_BIN_DIR}win64"
@cp ${COMMAND_BIN_DIR}win64/ztf.exe "${CLIENT_OUT_DIR}win64"
@cp ${COMMAND_BIN_DIR}win64/ztf-gui.exe "${CLIENT_OUT_DIR}win64"
copy_files_linux:
@echo 'start copy files linux'
@cp -r demo "${CLIENT_OUT_DIR}linux"
@cp -r demo "${COMMAND_BIN_DIR}linux"
@cp ${COMMAND_BIN_DIR}linux/ztf "${CLIENT_OUT_DIR}linux"
copy_files_linux_arm64:
@echo 'start copy files linux for arm64'
@mkdir -p "${CLIENT_OUT_DIR}linux_arm64"
@cp -r demo "${CLIENT_OUT_DIR}linux_arm64"
@cp -r demo "${COMMAND_BIN_DIR}linux_arm64"
@cp ${COMMAND_BIN_DIR}linux_arm64/ztf "${CLIENT_OUT_DIR}linux_arm64"
copy_files_mac:
@echo 'start copy files darwin'
@cp -r demo "${CLIENT_OUT_DIR}darwin"
@cp -r demo "${COMMAND_BIN_DIR}darwin"
@cp ${COMMAND_BIN_DIR}darwin/ztf "${CLIENT_OUT_DIR}darwin"
# zip server
zip_server_win64:
@mkdir -p ${QINIU_DIST_DIR}win64
@cd ${COMMAND_BIN_DIR}win64 && zip -ry ${QINIU_DIST_DIR}win64/${PROJECT}-server.zip ./demo ./${PROJECT}-server.exe && cd ../..
@md5sum ${QINIU_DIST_DIR}win64/${PROJECT}-server.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}win64/${PROJECT}-server.zip.md5
zip_server_linux:
@mkdir -p ${QINIU_DIST_DIR}linux
@cd ${COMMAND_BIN_DIR}linux && \
zip -ry ${QINIU_DIST_DIR}linux/${PROJECT}-server.zip ./demo ./${PROJECT}-server && \
md5sum ${QINIU_DIST_DIR}linux/${PROJECT}-server.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}linux/${PROJECT}-server.zip.md5 && \
cd ../..; \
zip_server_linux_arm64:
@mkdir -p ${QINIU_DIST_DIR}linux_arm64
@cd ${COMMAND_BIN_DIR}linux_arm64 && \
zip -ry ${QINIU_DIST_DIR}linux_arm64/${PROJECT}-server.zip ./demo ./${PROJECT}-server && \
md5sum ${QINIU_DIST_DIR}linux_arm64/${PROJECT}-server.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}linux_arm64/${PROJECT}-server.zip.md5 && \
cd ../..; \
zip_server_mac:
@mkdir -p ${QINIU_DIST_DIR}darwin
@cd ${COMMAND_BIN_DIR}darwin && zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}-server.zip ./demo ./${PROJECT}-server && cd ../..
@md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}-server.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}-server.zip.md5
# zip client
zip_client_win64:
@echo 'start zip win64'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}win64 && rm -rf ${QINIU_DIST_DIR}win64/${PROJECT}.zip
@cd ${CLIENT_OUT_DIR}win64 && \
zip -ry ${QINIU_DIST_DIR}win64/${PROJECT}.zip ./* && \
md5sum ${QINIU_DIST_DIR}win64/${PROJECT}.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}win64/${PROJECT}.zip.md5 && \
cd ../..; \
zip_client_linux:
@echo 'start zip linux'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}linux && rm -rf ${QINIU_DIST_DIR}linux/${PROJECT}.zip
@cd ${CLIENT_OUT_DIR}linux && \
zip -ry ${QINIU_DIST_DIR}linux/${PROJECT}.zip ./* && \
md5sum ${QINIU_DIST_DIR}linux/${PROJECT}.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}linux/${PROJECT}.zip.md5 && \
cd ../..; \
zip_client_linux_arm64:
@echo 'start zip linux for arm64'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}linux_arm64 && rm -rf ${QINIU_DIST_DIR}linux_arm64/${PROJECT}.zip
@cd ${CLIENT_OUT_DIR}linux_arm64 && \
zip -ry ${QINIU_DIST_DIR}linux_arm64/${PROJECT}.zip ./* && \
md5sum ${QINIU_DIST_DIR}linux_arm64/${PROJECT}.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}linux_arm64/${PROJECT}.zip.md5 && \
cd ../..; \
zip_client_mac:
@echo 'start zip darwin'
@find . -name .DS_Store -print0 | xargs -0 rm -f
@mkdir -p ${QINIU_DIST_DIR}darwin && rm -rf ${QINIU_DIST_DIR}darwin/${PROJECT}.zip
@cd ${CLIENT_OUT_DIR}darwin && \
zip -ry ${QINIU_DIST_DIR}darwin/${PROJECT}.zip ./* && \
md5sum ${QINIU_DIST_DIR}darwin/${PROJECT}.zip | awk '{print $$1}' | \
xargs echo > ${QINIU_DIST_DIR}darwin/${PROJECT}.zip.md5 && \
cd ../..; \
upload_to:
@echo 'upload ${QINIU_DIR} ...'
@find ${QINIU_DIR} -name ".DS_Store" -type f -delete
@qshell qupload2 --src-dir=${QINIU_DIR} --bucket=download --thread-count=10 --log-file=qshell.log \
--skip-path-prefixes=zd,zv,zmanager,driver,deeptest --rescan-local --overwrite --check-hash