forked from gzydong/go-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (68 loc) · 2.93 KB
/
Makefile
File metadata and controls
86 lines (68 loc) · 2.93 KB
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
PROTO_FILES := $(shell find api -iname *.proto)
.PHONY: install
install:
go install github.com/google/wire/cmd/wire@latest \
&& go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest \
&& go install google.golang.org/protobuf/cmd/protoc-gen-go@latest \
&& go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest \
&& go install github.com/envoyproxy/protoc-gen-validate@latest \
&& go install github.com/srikrsna/protoc-gen-gotag@latest \
.PHONY: conf
conf:
cp config.example.yaml config.yaml
.PHONY: generate
generate:
go generate ./...
lint:
golangci-lint run --timeout=5m --config ./.golangci.yml
test:
go test -v ./...
http: generate
go run ./internal/http
im_server: generate
go run ./internal/gateway
cmd: generate
go run ./internal/cmd
migrate:
go run ./internal/cmd other migrate
.PHONY: build
build:generate
go build -o ./bin/http-server ./internal/http
go build -o ./bin/im-server ./internal/gateway
go build -o ./bin/cmd ./internal/cmd
.PHONY: build-all
build-all:generate lint
# 构建 windows
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ./build/windows/bin/http-server.exe ./internal/http
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ./build/windows/bin/im-server.exe ./internal/gateway
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ./build/windows/bin/cmd.exe ./internal/cmd
cp ./config.example.yaml ./build/windows/config.yaml
# 构建 linux
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./build/linux/bin/http-server ./internal/http
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./build/linux/bin/im-server ./internal/gateway
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./build/linux/bin/cmd ./internal/cmd
cp ./config.example.yaml ./build/linux/config.yaml
# 构建 mac amd
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./build/mac/bin/http-server ./internal/http
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./build/mac/bin/im-server ./internal/gateway
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./build/mac/bin/cmd ./internal/cmd
cp ./config.example.yaml ./build/mac/config.yaml
# 构建 mac m1
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ./build/macm1/bin/http-server ./internal/http
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ./build/macm1/bin/im-server ./internal/gateway
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ./build/macm1/bin/cmd ./internal/cmd
cp ./config.example.yaml ./build/macm1/config.yaml
.PHONY: proto
proto:
@if [ -n "$(PROTO_FILES)" ]; then \
protoc --proto_path=./api/proto \
--proto_path=./third_party \
--go_out=paths=source_relative:./api/pb/ \
--validate_out=paths=source_relative,lang=go:./api/pb/ $(PROTO_FILES) \
&& protoc --proto_path=./third_party --proto_path=./api/proto --gotag_out=outdir="./api/pb/":./ $(PROTO_FILES) \
&& echo "protoc generate success"; \
fi
.PHONY: deploy
deploy:
git pull && make build && supervisorctl reload
#--go-grpc_out=paths=source_relative:./api/pb/ \