forked from enfein/mieru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
451 lines (408 loc) · 18.8 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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# Copyright (C) 2022 mieru authors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
ROOT=$(shell git rev-parse --show-toplevel)
SHORT_SHA=$(shell git rev-parse --short HEAD)
PROJECT_NAME=$(shell basename "${ROOT}")
LDFLAGS = -s -w
# If this version is changed, also change the version in
#
# - build/package/mieru/amd64/debian/DEBIAN/control
# - build/package/mieru/amd64/rpm/mieru.spec
# - build/package/mieru/arm64/debian/DEBIAN/control
# - build/package/mieru/arm64/rpm/mieru.spec
# - build/package/mita/amd64/debian/DEBIAN/control
# - build/package/mita/amd64/rpm/mita.spec
# - build/package/mita/arm64/debian/DEBIAN/control
# - build/package/mita/arm64/rpm/mita.spec
# - docs/server-install.md
# - docs/server-install.zh_CN.md
# - pkg/version/current.go
#
# Use `tools/bump_version.sh` script to change all those files at one shot.
VERSION="2.4.0"
# Build binaries and installation packages.
.PHONY: build
build: bin deb rpm
# Build binaries.
.PHONY: bin
bin: lib client-android client-linux client-mac client-windows-amd64
# Compile go libraries and run unit tests.
.PHONY: lib
lib: fmt
CGO_ENABLED=0 go build -v ./...
CGO_ENABLED=0 go test -timeout=1m0s -coverprofile coverage.out ./...
go tool cover -html coverage.out -o coverage.html
# Build Android clients.
.PHONY: client-android
client-android: client-android-amd64 client-android-arm64 client-android-386 client-android-arm
# Build Android amd64 client.
.PHONY: client-android-amd64
client-android-amd64:
if [ ! -z $$(command -v gcc) ]; then\
mkdir -p release/android/amd64;\
env GOOS=android GOARCH=amd64 CGO_ENABLED=1 go build -ldflags="-s -w" -o release/android/amd64/mieru cmd/mieru/mieru.go;\
cd release/android/amd64;\
sha256sum mieru > mieru_${VERSION}_android_amd64.sha256.txt;\
tar -zcvf mieru_${VERSION}_android_amd64.tar.gz mieru;\
sha256sum mieru_${VERSION}_android_amd64.tar.gz > mieru_${VERSION}_android_amd64.tar.gz.sha256.txt;\
cd "${ROOT}";\
mv release/android/amd64/mieru_${VERSION}_android_amd64.tar.gz release/;\
mv release/android/amd64/mieru_${VERSION}_android_amd64.tar.gz.sha256.txt release/;\
fi
# Build Android 386 client.
.PHONY: client-android-386
client-android-386:
if [ ! -z $$(command -v gcc) ]; then\
mkdir -p release/android/386;\
env GOOS=android GOARCH=386 CGO_ENABLED=1 go build -ldflags="-s -w" -o release/android/386/mieru cmd/mieru/mieru.go;\
cd release/android/386;\
sha256sum mieru > mieru_${VERSION}_android_386.sha256.txt;\
tar -zcvf mieru_${VERSION}_android_386.tar.gz mieru;\
sha256sum mieru_${VERSION}_android_386.tar.gz > mieru_${VERSION}_android_386.tar.gz.sha256.txt;\
cd "${ROOT}";\
mv release/android/386/mieru_${VERSION}_android_386.tar.gz release/;\
mv release/android/386/mieru_${VERSION}_android_386.tar.gz.sha256.txt release/;\
fi
# Build Android arm64 client.
.PHONY: client-android-arm64
client-android-arm64:
if [ ! -z $$(command -v gcc) ]; then\
mkdir -p release/android/arm64;\
env GOOS=android GOARCH=arm64 CGO_ENABLED=1 go build -ldflags="-s -w" -o release/android/arm64/mieru cmd/mieru/mieru.go;\
cd release/android/arm64;\
sha256sum mieru > mieru_${VERSION}_android_arm64.sha256.txt;\
tar -zcvf mieru_${VERSION}_android_arm64.tar.gz mieru;\
sha256sum mieru_${VERSION}_android_arm64.tar.gz > mieru_${VERSION}_android_arm64.tar.gz.sha256.txt;\
cd "${ROOT}";\
mv release/android/arm64/mieru_${VERSION}_android_arm64.tar.gz release/;\
mv release/android/arm64/mieru_${VERSION}_android_arm64.tar.gz.sha256.txt release/;\
fi
# Build Android arm client.
.PHONY: client-android-arm
client-android-arm:
if [ ! -z $$(command -v gcc) ]; then\
mkdir -p release/android/arm;\
env GOOS=android GOARCH=arm CGO_ENABLED=1 go build -ldflags="-s -w" -o release/android/arm/mieru cmd/mieru/mieru.go;\
cd release/android/arm;\
sha256sum mieru > mieru_${VERSION}_android_arm.sha256.txt;\
tar -zcvf mieru_${VERSION}_android_arm.tar.gz mieru;\
sha256sum mieru_${VERSION}_android_arm.tar.gz > mieru_${VERSION}_android_arm.tar.gz.sha256.txt;\
cd "${ROOT}";\
mv release/android/arm/mieru_${VERSION}_android_arm.tar.gz release/;\
mv release/android/arm/mieru_${VERSION}_android_arm.tar.gz.sha256.txt release/;\
fi
# Build linux clients.
.PHONY: client-linux
client-linux: client-linux-amd64 client-linux-arm64 client-linux-armv7 client-linux-riscv64
# Build linux amd64 client.
.PHONY: client-linux-amd64
client-linux-amd64:
mkdir -p release/linux/amd64
env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o release/linux/amd64/mieru cmd/mieru/mieru.go
cd release/linux/amd64;\
sha256sum mieru > mieru_${VERSION}_linux_amd64.sha256.txt;\
tar -zcvf mieru_${VERSION}_linux_amd64.tar.gz mieru;\
sha256sum mieru_${VERSION}_linux_amd64.tar.gz > mieru_${VERSION}_linux_amd64.tar.gz.sha256.txt
mv release/linux/amd64/mieru_${VERSION}_linux_amd64.tar.gz release/
mv release/linux/amd64/mieru_${VERSION}_linux_amd64.tar.gz.sha256.txt release/
# Build linux arm64 client.
.PHONY: client-linux-arm64
client-linux-arm64:
mkdir -p release/linux/arm64
env GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w" -o release/linux/arm64/mieru cmd/mieru/mieru.go
cd release/linux/arm64;\
sha256sum mieru > mieru_${VERSION}_linux_arm64.sha256.txt;\
tar -zcvf mieru_${VERSION}_linux_arm64.tar.gz mieru;\
sha256sum mieru_${VERSION}_linux_arm64.tar.gz > mieru_${VERSION}_linux_arm64.tar.gz.sha256.txt
mv release/linux/arm64/mieru_${VERSION}_linux_arm64.tar.gz release/
mv release/linux/arm64/mieru_${VERSION}_linux_arm64.tar.gz.sha256.txt release/
# Build linux armv7 client.
.PHONY: client-linux-armv7
client-linux-armv7:
mkdir -p release/linux/armv7
env GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=0 go build -ldflags="-s -w" -o release/linux/armv7/mieru cmd/mieru/mieru.go
cd release/linux/armv7;\
sha256sum mieru > mieru_${VERSION}_linux_armv7.sha256.txt;\
tar -zcvf mieru_${VERSION}_linux_armv7.tar.gz mieru;\
sha256sum mieru_${VERSION}_linux_armv7.tar.gz > mieru_${VERSION}_linux_armv7.tar.gz.sha256.txt
mv release/linux/armv7/mieru_${VERSION}_linux_armv7.tar.gz release/
mv release/linux/armv7/mieru_${VERSION}_linux_armv7.tar.gz.sha256.txt release/
# Build linux riscv64 client.
.PHONY: client-linux-riscv64
client-linux-riscv64:
mkdir -p release/linux/riscv64
env GOOS=linux GOARCH=riscv64 CGO_ENABLED=0 go build -ldflags="-s -w" -o release/linux/riscv64/mieru cmd/mieru/mieru.go
cd release/linux/riscv64;\
sha256sum mieru > mieru_${VERSION}_linux_riscv64.sha256.txt;\
tar -zcvf mieru_${VERSION}_linux_riscv64.tar.gz mieru;\
sha256sum mieru_${VERSION}_linux_riscv64.tar.gz > mieru_${VERSION}_linux_riscv64.tar.gz.sha256.txt
mv release/linux/riscv64/mieru_${VERSION}_linux_riscv64.tar.gz release/
mv release/linux/riscv64/mieru_${VERSION}_linux_riscv64.tar.gz.sha256.txt release/
# Build MacOS clients.
.PHONY: client-mac
client-mac: client-mac-amd64 client-mac-arm64
# Build MacOS amd64 client.
.PHONY: client-mac-amd64
client-mac-amd64:
mkdir -p release/macos/amd64
env GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o release/macos/amd64/mieru cmd/mieru/mieru.go
cd release/macos/amd64;\
sha256sum mieru > mieru_${VERSION}_macos_amd64.sha256.txt;\
tar -zcvf mieru_${VERSION}_macos_amd64.tar.gz mieru;\
sha256sum mieru_${VERSION}_macos_amd64.tar.gz > mieru_${VERSION}_macos_amd64.tar.gz.sha256.txt
mv release/macos/amd64/mieru_${VERSION}_macos_amd64.tar.gz release/
mv release/macos/amd64/mieru_${VERSION}_macos_amd64.tar.gz.sha256.txt release/
# Build MacOS arm64 client.
.PHONY: client-mac-arm64
client-mac-arm64:
mkdir -p release/macos/arm64
env GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w" -o release/macos/arm64/mieru cmd/mieru/mieru.go
cd release/macos/arm64;\
sha256sum mieru > mieru_${VERSION}_macos_arm64.sha256.txt;\
tar -zcvf mieru_${VERSION}_macos_arm64.tar.gz mieru;\
sha256sum mieru_${VERSION}_macos_arm64.tar.gz > mieru_${VERSION}_macos_arm64.tar.gz.sha256.txt
mv release/macos/arm64/mieru_${VERSION}_macos_arm64.tar.gz release/
mv release/macos/arm64/mieru_${VERSION}_macos_arm64.tar.gz.sha256.txt release/
# Build windows amd64 client.
.PHONY: client-windows-amd64
client-windows-amd64:
mkdir -p release/windows
env GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o release/windows/mieru.exe cmd/mieru/mieru.go
cd release/windows;\
sha256sum mieru.exe > mieru_${VERSION}_windows.exe.sha256.txt;\
zip -r mieru_${VERSION}_windows_amd64.zip mieru.exe;\
sha256sum mieru_${VERSION}_windows_amd64.zip > mieru_${VERSION}_windows_amd64.zip.sha256.txt
mv release/windows/mieru_${VERSION}_windows_amd64.zip release/
mv release/windows/mieru_${VERSION}_windows_amd64.zip.sha256.txt release/
# Build linux servers.
.PHONY: server-linux
server-linux: server-linux-amd64 server-linux-arm64
# Build linux amd64 server.
.PHONY: server-linux-amd64
server-linux-amd64:
mkdir -p release/linux/amd64
env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w" -o release/linux/amd64/mita cmd/mita/mita.go
cd release/linux/amd64;\
sha256sum mita > mita_${VERSION}_linux_amd64.sha256.txt
# Build linux arm64 server.
.PHONY: server-linux-arm64
server-linux-arm64:
mkdir -p release/linux/arm64
env GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w" -o release/linux/arm64/mita cmd/mita/mita.go
cd release/linux/arm64;\
sha256sum mita > mita_${VERSION}_linux_arm64.sha256.txt
# Build debian installation packages.
.PHONY: deb
deb: deb-client-amd64 deb-client-arm64 deb-server-amd64 deb-server-arm64
# Build debian client amd64 installation package.
.PHONY: deb-client-amd64
deb-client-amd64: client-linux-amd64
if [ ! -z $$(command -v dpkg-deb) ] && [ ! -z $$(command -v fakeroot) ]; then\
rm -rf build/package/mieru/amd64/debian/usr/bin;\
mkdir -p build/package/mieru/amd64/debian/usr/bin;\
cp release/linux/amd64/mieru build/package/mieru/amd64/debian/usr/bin/;\
cd build/package/mieru/amd64;\
fakeroot dpkg-deb --build debian .;\
cd "${ROOT}";\
mv build/package/mieru/amd64/mieru_${VERSION}_amd64.deb release/;\
cd release;\
sha256sum mieru_${VERSION}_amd64.deb > mieru_${VERSION}_amd64.deb.sha256.txt;\
fi
# Build debian client arm64 installation package.
.PHONY: deb-client-arm64
deb-client-arm64: client-linux-arm64
if [ ! -z $$(command -v dpkg-deb) ] && [ ! -z $$(command -v fakeroot) ]; then\
rm -rf build/package/mieru/arm64/debian/usr/bin;\
mkdir -p build/package/mieru/arm64/debian/usr/bin;\
cp release/linux/arm64/mieru build/package/mieru/arm64/debian/usr/bin/;\
cd build/package/mieru/arm64;\
fakeroot dpkg-deb --build debian .;\
cd "${ROOT}";\
mv build/package/mieru/arm64/mieru_${VERSION}_arm64.deb release/;\
cd release;\
sha256sum mieru_${VERSION}_arm64.deb > mieru_${VERSION}_arm64.deb.sha256.txt;\
fi
# Build debian server amd64 installation package.
.PHONY: deb-server-amd64
deb-server-amd64: server-linux-amd64
if [ ! -z $$(command -v dpkg-deb) ] && [ ! -z $$(command -v fakeroot) ]; then\
rm -rf build/package/mita/amd64/debian/usr/bin;\
mkdir -p build/package/mita/amd64/debian/usr/bin;\
cp release/linux/amd64/mita build/package/mita/amd64/debian/usr/bin/;\
cd build/package/mita/amd64;\
fakeroot dpkg-deb --build debian .;\
cd "${ROOT}";\
mv build/package/mita/amd64/mita_${VERSION}_amd64.deb release/;\
cd release;\
sha256sum mita_${VERSION}_amd64.deb > mita_${VERSION}_amd64.deb.sha256.txt;\
fi
# Build debian server arm64 installation package.
.PHONY: deb-server-arm64
deb-server-arm64: server-linux-arm64
if [ ! -z $$(command -v dpkg-deb) ] && [ ! -z $$(command -v fakeroot) ]; then\
rm -rf build/package/mita/arm64/debian/usr/bin;\
mkdir -p build/package/mita/arm64/debian/usr/bin;\
cp release/linux/arm64/mita build/package/mita/arm64/debian/usr/bin/;\
cd build/package/mita/arm64;\
fakeroot dpkg-deb --build debian .;\
cd "${ROOT}";\
mv build/package/mita/arm64/mita_${VERSION}_arm64.deb release/;\
cd release;\
sha256sum mita_${VERSION}_arm64.deb > mita_${VERSION}_arm64.deb.sha256.txt;\
fi
# Build RPM installation packages.
.PHONY: rpm
rpm: rpm-client-amd64 rpm-client-arm64
# Build RPM client amd64 installation package.
.PHONY: rpm-client-amd64
rpm-client-amd64: client-linux-amd64
if [ ! -z $$(command -v rpmbuild) ]; then\
rm -rf build/package/mieru/amd64/rpm/mieru;\
cp release/linux/amd64/mieru build/package/mieru/amd64/rpm/;\
cd build/package/mieru/amd64/rpm;\
rpmbuild -bb --target x86_64 --build-in-place --define "_topdir $$(pwd)" mieru.spec;\
cd "${ROOT}";\
mv build/package/mieru/amd64/rpm/RPMS/x86_64/mieru-${VERSION}-1.x86_64.rpm release/;\
cd release;\
sha256sum mieru-${VERSION}-1.x86_64.rpm > mieru-${VERSION}-1.x86_64.rpm.sha256.txt;\
fi
# Build RPM client arm64 installation package.
.PHONY: rpm-client-arm64
rpm-client-arm64: client-linux-arm64
if [ ! -z $$(command -v rpmbuild) ]; then\
rm -rf build/package/mieru/arm64/rpm/mieru;\
cp release/linux/arm64/mieru build/package/mieru/arm64/rpm/;\
cd build/package/mieru/arm64/rpm;\
rpmbuild -bb --target aarch64 --build-in-place --define "_topdir $$(pwd)" mieru.spec;\
cd "${ROOT}";\
mv build/package/mieru/arm64/rpm/RPMS/aarch64/mieru-${VERSION}-1.aarch64.rpm release/;\
cd release;\
sha256sum mieru-${VERSION}-1.aarch64.rpm > mieru-${VERSION}-1.aarch64.rpm.sha256.txt;\
fi
# Build RPM server amd64 installation package.
.PHONY: rpm-server-amd64
rpm-server-amd64: server-linux-amd64
if [ ! -z $$(command -v rpmbuild) ]; then\
rm -rf build/package/mita/amd64/rpm/mita;\
cp release/linux/amd64/mita build/package/mita/amd64/rpm/;\
cd build/package/mita/amd64/rpm;\
rpmbuild -bb --target x86_64 --build-in-place --define "_topdir $$(pwd)" mita.spec;\
cd "${ROOT}";\
mv build/package/mita/amd64/rpm/RPMS/x86_64/mita-${VERSION}-1.x86_64.rpm release/;\
cd release;\
sha256sum mita-${VERSION}-1.x86_64.rpm > mita-${VERSION}-1.x86_64.rpm.sha256.txt;\
fi
# Build RPM server arm64 installation package.
.PHONY: rpm-server-arm64
rpm-server-arm64: server-linux-arm64
if [ ! -z $$(command -v rpmbuild) ]; then\
rm -rf build/package/mita/arm64/rpm/mita;\
cp release/linux/arm64/mita build/package/mita/arm64/rpm/;\
cd build/package/mita/arm64/rpm;\
rpmbuild -bb --target aarch64 --build-in-place --define "_topdir $$(pwd)" mita.spec;\
cd "${ROOT}";\
mv build/package/mita/arm64/rpm/RPMS/aarch64/mita-${VERSION}-1.aarch64.rpm release/;\
cd release;\
sha256sum mita-${VERSION}-1.aarch64.rpm > mita-${VERSION}-1.aarch64.rpm.sha256.txt;\
fi
# Build binaries used in integration tests.
.PHONY: test-binary
test-binary:
CGO_ENABLED=0 go build -ldflags="-X 'github.com/enfein/mieru/pkg/log.LogPrefix=C'" -o mieru cmd/mieru/mieru.go
CGO_ENABLED=0 go build -ldflags="-X 'github.com/enfein/mieru/pkg/log.LogPrefix=S'" -o mita cmd/mita/mita.go
CGO_ENABLED=1 go build -race -ldflags="-X 'github.com/enfein/mieru/pkg/log.LogPrefix=C2'" -o mieru2 cmd/mieru/mieru.go
CGO_ENABLED=1 go build -race -ldflags="-X 'github.com/enfein/mieru/pkg/log.LogPrefix=S2'" -o mita2 cmd/mita/mita.go
CGO_ENABLED=0 go build test/cmd/httpserver/httpserver.go
CGO_ENABLED=0 go build test/cmd/sockshttpclient/sockshttpclient.go
CGO_ENABLED=0 go build test/cmd/socksudpclient/socksudpclient.go
CGO_ENABLED=0 go build test/cmd/udpserver/udpserver.go
# Build a docker image to run integration tests.
.PHONY: test-container
test-container: test-binary
if [ ! -z $$(command -v docker) ]; then\
docker build -t mieru_httptest:${SHORT_SHA} -f test/deploy/httptest/Dockerfile .;\
docker build -t mieru_proxychain:${SHORT_SHA} -f test/deploy/proxychain/Dockerfile .;\
fi
rm -f mieru mieru2 mita mita2 httpserver sockshttpclient socksudpclient udpserver
# Run docker integration tests.
.PHONY: run-container-test
run-container-test: test-container
if [ ! -z $$(command -v docker) ]; then\
docker run mieru_proxychain:${SHORT_SHA};\
docker run mieru_httptest:${SHORT_SHA};\
fi
# Format source code.
.PHONY: fmt
fmt:
CGO_ENABLED=0 go fmt ./...
# Run go vet.
.PHONY: vet
vet:
CGO_ENABLED=0 go vet ./...
# Generate source code from protobuf.
# Call this after proto files are changed.
PROTOC_ARCH =
ifeq ($(shell uname -m), x86_64)
PROTOC_ARCH = amd64
endif
ifeq ($(shell uname -m), arm64)
PROTOC_ARCH = arm64
endif
.PHONY: protobuf
protobuf:
# Download location: https://github.com/protocolbuffers/protobuf/releases
if [ ! -x "${ROOT}/tools/build/protoc" ]; then\
curl -o "${ROOT}/tools/build/protoc" https://raw.githubusercontent.com/enfein/buildtools/main/protoc/22.3/linux_${PROTOC_ARCH}/bin/protoc;\
chmod 755 "${ROOT}/tools/build/protoc";\
fi
# Download location: https://github.com/protocolbuffers/protobuf-go/releases
if [ ! -x "${ROOT}/tools/build/protoc-gen-go" ]; then\
curl -o "${ROOT}/tools/build/protoc-gen-go" https://raw.githubusercontent.com/enfein/buildtools/main/protoc-gen-go/1.30.0/linux_${PROTOC_ARCH}/protoc-gen-go;\
chmod 755 "${ROOT}/tools/build/protoc-gen-go";\
fi
# Download location: https://github.com/grpc/grpc-go/releases
if [ ! -x "${ROOT}/tools/build/protoc-gen-go-grpc" ]; then\
curl -o "${ROOT}/tools/build/protoc-gen-go-grpc" https://raw.githubusercontent.com/enfein/buildtools/main/protoc-gen-go-grpc/1.3.0/linux_${PROTOC_ARCH}/protoc-gen-go-grpc;\
chmod 755 "${ROOT}/tools/build/protoc-gen-go-grpc";\
fi
PATH=${PATH}:"${ROOT}/tools/build" ${ROOT}/tools/build/protoc -I="${ROOT}/pkg/appctl/proto" \
--go_out="${ROOT}/pkg/appctl" --go_opt=module="github.com/enfein/mieru/pkg/appctl" \
--go-grpc_out="${ROOT}/pkg/appctl" --go-grpc_opt=module="github.com/enfein/mieru/pkg/appctl" \
--proto_path="${ROOT}/pkg" \
"${ROOT}/pkg/appctl/proto/clientcfg.proto" \
"${ROOT}/pkg/appctl/proto/debug.proto" \
"${ROOT}/pkg/appctl/proto/egress.proto" \
"${ROOT}/pkg/appctl/proto/empty.proto" \
"${ROOT}/pkg/appctl/proto/endpoint.proto" \
"${ROOT}/pkg/appctl/proto/lifecycle.proto" \
"${ROOT}/pkg/appctl/proto/logging.proto" \
"${ROOT}/pkg/appctl/proto/metrics.proto" \
"${ROOT}/pkg/appctl/proto/multiplexing.proto" \
"${ROOT}/pkg/appctl/proto/servercfg.proto" \
"${ROOT}/pkg/appctl/proto/user.proto"
# Package source code.
.PHONY: src
src: clean
cd ..; tar --exclude="${PROJECT_NAME}/.git" -zcvf source.tar.gz "${PROJECT_NAME}"; zip -r source.zip "${PROJECT_NAME}" -x \*.git\*
mkdir -p release; mv ../source.tar.gz release; mv ../source.zip release
# Clean all the files outside the git repository.
.PHONY: clean
clean:
git clean -fxd
# Clean go build cache.
.PHONY: clean-cache
clean-cache:
go clean -cache
go clean -testcache