-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (58 loc) · 1.65 KB
/
Makefile
File metadata and controls
70 lines (58 loc) · 1.65 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
PROTO_FILES := $(shell find api -name *.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 github.com/google/gnostic/cmd/protoc-gen-openapi@latest
.PHONY: conf
conf:
cp config.example.yaml config.yaml
.PHONY: generate
generate:
go generate ./...
lint:
golangci-lint run --config ./.golangci.yml
test:
go test -v ./...
.PHONY: run
run:
@go run ./cmd/lumenim $(filter-out run,$(MAKECMDGOALS))
.PHONY: build
build:
go build -o ./bin/lumenim ./cmd/lumenim
.PHONY: protoc-gen-bff
protoc-gen-bff:
go build -o protoc-gen-bff ./cmd/protoc-gen-bff
.PHONY: proto
proto: protoc-gen-bff
@if [ -n "$(PROTO_FILES)" ]; then \
protoc \
--plugin=protoc-gen-bff=./protoc-gen-bff \
--proto_path=./api/proto \
--proto_path=./third_party \
--go_out=paths=source_relative:./api/pb/ \
--bff_out=./api/pb/ \
$(PROTO_FILES) \
&& echo "protoc generate success"; \
fi
make proto-openapi
@if [ -f ./protoc-gen-bff ]; then \
rm -f ./protoc-gen-bff; \
fi
.PHONY: proto-openapi # 生成 OpenApi 文档
proto-openapi:
@for dir in $$(find api/proto -type d -mindepth 1 -maxdepth 1); do \
echo "Processing directory: $$dir"; \
proto_files=$$(find $$dir -name "*.proto"); \
if [ -n "$$proto_files" ]; then \
protoc \
--proto_path=./api/proto \
--proto_path=./third_party \
--openapi_out=version=3:./$$dir \
$$proto_files; \
fi; \
echo "Generated OpenAPI spec for directory: $$dir";\
done
## 自定义命令
-include custom.mk