-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
69 lines (47 loc) · 2.08 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
PROG=protoc-gen-mock
DEMOPB=demopb
TESTPB=pkg/pb/testpb
SCENARIOPB=pkg/pb/scenariopb
MOCKPB=pkg/pb/mockpb
PROTOINCLUDE=-I ./protobuf/google -I ./protobuf/grpc/src/proto -I ./pkg/pb
LDFLAGS=-ldflags="-s -w"
.PHONY: build
build: $(PROG)
$(PROG): ./cmd/$(PROG)/*.go ./pkg/*/*.go $(SCENARIOPB)/scenario.pb.go $(MOCKPB)/mockoptions.pb.go
go build $(LDFLAGS) ./cmd/$(PROG)/
$(SCENARIOPB)/scenario.pb.go: $(SCENARIOPB)/scenario.proto
protoc -I $(SCENARIOPB) $(PROTOINCLUDE) --go_out=$(SCENARIOPB) --go_opt=paths=source_relative scenario.proto
$(TESTPB)/test.pb.go: $(TESTPB)/test.proto
protoc -I $(TESTPB) $(PROTOINCLUDE) --go_out=$(TESTPB) --go_opt=paths=source_relative test.proto
$(MOCKPB)/mockoptions.pb.go: $(MOCKPB)/mockoptions.proto
protoc -I $(MOCKPB) $(PROTOINCLUDE) --go_out=$(MOCKPB) --go_opt=paths=source_relative mockoptions.proto
.PHONY: test
test: $(TESTPB)/test.pb.go
go test ./cmd/... ./pkg/...
.PHONY: proto
proto: $(DEMOPB)/demo.pb.go $(DEMOPB)/demo_grpc.pb.go $(DEMOPB)/demo.pb.gw.go $(DEMOPB)/demo.mock.go
$(DEMOPB)/demo.pb.go: $(DEMOPB)/demo.proto
protoc -I $(DEMOPB) $(PROTOINCLUDE) --go_out=$(DEMOPB) --go_opt=paths=source_relative demo.proto
$(DEMOPB)/demo_grpc.pb.go: $(DEMOPB)/demo.proto
protoc -I $(DEMOPB) $(PROTOINCLUDE) --go-grpc_out=$(DEMOPB) --go-grpc_opt=paths=source_relative demo.proto
$(DEMOPB)/demo.pb.gw.go: $(DEMOPB)/demo.proto
protoc -I $(DEMOPB) $(PROTOINCLUDE) --grpc-gateway_out=$(DEMOPB) --grpc-gateway_opt=paths=source_relative demo.proto
$(DEMOPB)/demo.mock.go: $(DEMOPB)/demo.proto $(PROG)
protoc -I $(DEMOPB) $(PROTOINCLUDE) --mock_out=$(DEMOPB) --plugin $(PROG)=$(PROG) --mock_opt=paths=source_relative demo.proto
@echo "-----"
@cat $(DEMOPB)/demo.mock.go
@echo "-----"
.PHONY: rundemo
rundemo: proto
go run ./cmd/demo -scenario ./scenarios/demo1.yaml
.PHONY: rundemogw
rundemogw: proto
go run ./cmd/demogw
.PHONY: clean
clean:
rm -f $(PROG)
.PHONY: protoclean
protoclean:
rm -f $(DEMOPB)/demo.pb.go $(DEMOPB)/demo.mock.go $(DEMOPB)/demo.pb.gw.go $(DEMOPB)/demo_grpc.pb.go
rm -f $(SCENARIOPB)/scenario.pb.go
rm -f $(MOCKPB)/annotations.pb.go