forked from grpc/grpc-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (112 loc) · 4.45 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
# Which Swift to use.
SWIFT:=swift
# Where products will be built; this is the SPM default.
SWIFT_BUILD_PATH:=./.build
SWIFT_BUILD_CONFIGURATION=debug
SWIFT_FLAGS=--build-path=${SWIFT_BUILD_PATH} --configuration=${SWIFT_BUILD_CONFIGURATION} --enable-test-discovery
# Force release configuration (for plugins)
SWIFT_FLAGS_RELEASE=$(patsubst --configuration=%,--configuration=release,$(SWIFT_FLAGS))
# protoc plugins.
PROTOC_GEN_SWIFT=${SWIFT_BUILD_PATH}/release/protoc-gen-swift
PROTOC_GEN_GRPC_SWIFT=${SWIFT_BUILD_PATH}/release/protoc-gen-grpc-swift
SWIFT_BUILD:=${SWIFT} build ${SWIFT_FLAGS}
SWIFT_BUILD_RELEASE:=${SWIFT} build ${SWIFT_FLAGS_RELEASE}
SWIFT_TEST:=${SWIFT} test ${SWIFT_FLAGS}
SWIFT_PACKAGE:=${SWIFT} package ${SWIFT_FLAGS}
# Name of generated xcodeproj
XCODEPROJ:=GRPC.xcodeproj
### Package and plugin build targets ###########################################
all:
${SWIFT_BUILD}
Package.resolved:
${SWIFT_PACKAGE} resolve
.PHONY:
plugins: ${PROTOC_GEN_SWIFT} ${PROTOC_GEN_GRPC_SWIFT}
cp $^ .
${PROTOC_GEN_SWIFT}: Package.resolved
${SWIFT_BUILD_RELEASE} --product protoc-gen-swift
${PROTOC_GEN_GRPC_SWIFT}: Sources/protoc-gen-grpc-swift/*.swift
${SWIFT_BUILD_RELEASE} --product protoc-gen-grpc-swift
interop-test-runner:
${SWIFT_BUILD} --product GRPCInteroperabilityTests
interop-backoff-test-runner:
${SWIFT_BUILD} --product GRPCConnectionBackoffInteropTest
### Xcodeproj
.PHONY:
project: ${XCODEPROJ}
${XCODEPROJ}:
${SWIFT_PACKAGE} generate-xcodeproj --output $@
@-ruby scripts/fix-project-settings.rb GRPC.xcodeproj || \
echo "Consider running 'sudo gem install xcodeproj' to automatically set correct indentation settings for the generated project."
### Protobuf Generation ########################################################
%.pb.swift: %.proto ${PROTOC_GEN_SWIFT}
protoc $< \
--proto_path=$(dir $<) \
--plugin=${PROTOC_GEN_SWIFT} \
--swift_opt=Visibility=Public \
--swift_out=$(dir $<)
%.grpc.swift: %.proto ${PROTOC_GEN_GRPC_SWIFT}
protoc $< \
--proto_path=$(dir $<) \
--plugin=${PROTOC_GEN_GRPC_SWIFT} \
--grpc-swift_opt=Visibility=Public \
--grpc-swift_out=$(dir $<)
ECHO_PROTO=Sources/Examples/Echo/Model/echo.proto
ECHO_PB=$(ECHO_PROTO:.proto=.pb.swift)
ECHO_GRPC=$(ECHO_PROTO:.proto=.grpc.swift)
# For Echo we'll generate the test client as well.
${ECHO_GRPC}: ${ECHO_PROTO} ${PROTOC_GEN_GRPC_SWIFT}
protoc $< \
--proto_path=$(dir $<) \
--plugin=${PROTOC_GEN_GRPC_SWIFT} \
--grpc-swift_opt=Visibility=Public,TestClient=true \
--grpc-swift_out=$(dir $<)
# Generates protobufs and gRPC client and server for the Echo example
.PHONY:
generate-echo: ${ECHO_PB} ${ECHO_GRPC}
HELLOWORLD_PROTO=Sources/Examples/HelloWorld/Model/helloworld.proto
HELLOWORLD_PB=$(HELLOWORLD_PROTO:.proto=.pb.swift)
HELLOWORLD_GRPC=$(HELLOWORLD_PROTO:.proto=.grpc.swift)
# Generates protobufs and gRPC client and server for the Hello World example
.PHONY:
generate-helloworld: ${HELLOWORLD_PB} ${HELLOWORLD_GRPC}
ROUTE_GUIDE_PROTO=Sources/Examples/RouteGuide/Model/route_guide.proto
ROUTE_GUIDE_PB=$(ROUTE_GUIDE_PROTO:.proto=.pb.swift)
ROUTE_GUIDE_GRPC=$(ROUTE_GUIDE_PROTO:.proto=.grpc.swift)
# Generates protobufs and gRPC client and server for the Route Guide example
.PHONY:
generate-route-guide: ${ROUTE_GUIDE_PB} ${ROUTE_GUIDE_GRPC}
NORMALIZATION_PROTO=Tests/GRPCTests/Codegen/Normalization/normalization.proto
NORMALIZATION_PB=$(NORMALIZATION_PROTO:.proto=.pb.swift)
NORMALIZATION_GRPC=$(NORMALIZATION_PROTO:.proto=.grpc.swift)
# For normalization we'll explicitly keep the method casing.
${NORMALIZATION_GRPC}: ${NORMALIZATION_PROTO} ${PROTOC_GEN_GRPC_SWIFT}
protoc $< \
--proto_path=$(dir $<) \
--plugin=${PROTOC_GEN_GRPC_SWIFT} \
--grpc-swift_opt=KeepMethodCasing=true \
--grpc-swift_out=$(dir $<)
# Generates protobufs and gRPC client and server for the Route Guide example
.PHONY:
generate-normalization: ${NORMALIZATION_PB} ${NORMALIZATION_GRPC}
### Testing ####################################################################
# Normal test suite.
.PHONY:
test:
${SWIFT_TEST}
# Normal test suite with TSAN enabled.
.PHONY:
test-tsan:
${SWIFT_TEST} --sanitize=thread
# Runs codegen tests.
.PHONY:
test-plugin: ${PROTOC_GEN_GRPC_SWIFT}
PROTOC_GEN_GRPC_SWIFT=${PROTOC_GEN_GRPC_SWIFT} ./dev/codegen-tests/run-tests.sh
### Misc. ######################################################################
.PHONY:
clean:
-rm -rf Packages
-rm -rf ${SWIFT_BUILD_PATH}
-rm -rf ${XCODEPROJ}
-rm -f Package.resolved
-cd Examples/Google/NaturalLanguage && make clean