forked from grpc/grpc-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
123 lines (94 loc) · 3.82 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
# 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}
# 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}
.PHONY:
plugins: ${PROTOC_GEN_SWIFT} ${PROTOC_GEN_GRPC_SWIFT}
cp $^ .
${PROTOC_GEN_SWIFT}:
${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 and LinuxMain
.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."
# Generates LinuxMain.swift, only on macOS.
generate-linuxmain:
${SWIFT_TEST} --generate-linuxmain
### 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)
# 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}
### Testing ####################################################################
# Normal test suite.
.PHONY:
test:
${SWIFT_TEST}
# Checks that linuxmain has been updated: requires macOS.
.PHONY:
test-generate-linuxmain: generate-linuxmain
@git diff --exit-code Tests/LinuxMain.swift Tests/*/XCTestManifests.swift > /dev/null || \
{ echo "Generated tests are out-of-date; run 'swift test --generate-linuxmain' to update them!"; exit 1; }
# 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