-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (79 loc) · 2.3 KB
/
Copy pathMakefile
File metadata and controls
91 lines (79 loc) · 2.3 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
87
88
89
90
91
GOHOSTOS:=$(shell go env GOHOSTOS)
GOPATH:=$(shell go env GOPATH)
VERSION=$(shell git describe --tags --always)
.PHONY: sqlc
sqlc:
sqlc generate
.PHONY: new_migration
new_migration:
migrate create -ext sql -dir internal/data/migration -digits 2 -seq $(name)
.PHONY: init
# init env
init:
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@v2.8.4
go install github.com/google/wire/cmd/wire@latest
go install github.com/sqlc-dev/sqlc/cmd/sqlc@v1.29.0
go install github.com/bufbuild/buf/cmd/buf@v1.54.0
go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.6
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1
go install -tags 'mysql' github.com/golang-migrate/migrate/v4/cmd/migrate@v4.18.3
.PHONY: config
# generate internal proto
config:
cd internal/conf && buf generate
# protoc --proto_path=./internal \
# --proto_path=./third_party \
# --go_out=paths=source_relative:./internal \
# $(INTERNAL_PROTO_FILES)
.PHONY: api
# generate api proto
api:
buf dep update&&buf generate
# api:
# protoc --proto_path=./api \
# --proto_path=./third_party \
# --go_out=paths=source_relative:./api \
# --go-http_out=paths=source_relative:./api \
# --go-grpc_out=paths=source_relative:./api \
# --openapi_out=fq_schema_naming=true,default_response=false:. \
# $(API_PROTO_FILES)
.PHONY: build
# build
build:
mkdir -p bin/ && go build -ldflags "-X main.Version=$(VERSION)" -o ./bin/ ./...
.PHONY: generate
# generate
generate:
go generate ./...
go mod tidy
.PHONY: all
# generate all
all:
make api;
make config;
make generate;
.PHONY: server
server:
go run cmd/server/main.go cmd/server/wire_gen.go -conf config.yaml
.PHONY: wire
wire:
wire ./cmd/server
# show help
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help