2
0

Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # Which Swift to use.
  2. SWIFT:=swift
  3. # Where products will be built; this is the SPM default.
  4. SWIFT_BUILD_PATH:=./.build
  5. SWIFT_BUILD_CONFIGURATION=debug
  6. SWIFT_FLAGS=--build-path=${SWIFT_BUILD_PATH} --configuration=${SWIFT_BUILD_CONFIGURATION} --enable-test-discovery
  7. # Force release configuration (for plugins)
  8. SWIFT_FLAGS_RELEASE=$(patsubst --configuration=%,--configuration=release,$(SWIFT_FLAGS))
  9. # protoc plugins.
  10. PROTOC_GEN_SWIFT=${SWIFT_BUILD_PATH}/release/protoc-gen-swift
  11. PROTOC_GEN_GRPC_SWIFT=${SWIFT_BUILD_PATH}/release/protoc-gen-grpc-swift
  12. SWIFT_BUILD:=${SWIFT} build ${SWIFT_FLAGS}
  13. SWIFT_BUILD_RELEASE:=${SWIFT} build ${SWIFT_FLAGS_RELEASE}
  14. SWIFT_TEST:=${SWIFT} test ${SWIFT_FLAGS}
  15. SWIFT_PACKAGE:=${SWIFT} package ${SWIFT_FLAGS}
  16. # Name of generated xcodeproj
  17. XCODEPROJ:=GRPC.xcodeproj
  18. ### Package and plugin build targets ###########################################
  19. all:
  20. ${SWIFT_BUILD}
  21. Package.resolved:
  22. ${SWIFT_PACKAGE} resolve
  23. .PHONY:
  24. plugins: ${PROTOC_GEN_SWIFT} ${PROTOC_GEN_GRPC_SWIFT}
  25. cp $^ .
  26. ${PROTOC_GEN_SWIFT}: Package.resolved
  27. ${SWIFT_BUILD_RELEASE} --product protoc-gen-swift
  28. ${PROTOC_GEN_GRPC_SWIFT}: Sources/protoc-gen-grpc-swift/*.swift
  29. ${SWIFT_BUILD_RELEASE} --product protoc-gen-grpc-swift
  30. interop-test-runner:
  31. ${SWIFT_BUILD} --product GRPCInteroperabilityTests
  32. interop-backoff-test-runner:
  33. ${SWIFT_BUILD} --product GRPCConnectionBackoffInteropTest
  34. ### Xcodeproj
  35. .PHONY:
  36. project: ${XCODEPROJ}
  37. ${XCODEPROJ}:
  38. ${SWIFT_PACKAGE} generate-xcodeproj --output $@
  39. @-ruby scripts/fix-project-settings.rb GRPC.xcodeproj || \
  40. echo "Consider running 'sudo gem install xcodeproj' to automatically set correct indentation settings for the generated project."
  41. ### Protobuf Generation ########################################################
  42. %.pb.swift: %.proto ${PROTOC_GEN_SWIFT}
  43. protoc $< \
  44. --proto_path=$(dir $<) \
  45. --plugin=${PROTOC_GEN_SWIFT} \
  46. --swift_opt=Visibility=Public \
  47. --swift_out=$(dir $<)
  48. %.grpc.swift: %.proto ${PROTOC_GEN_GRPC_SWIFT}
  49. protoc $< \
  50. --proto_path=$(dir $<) \
  51. --plugin=${PROTOC_GEN_GRPC_SWIFT} \
  52. --grpc-swift_opt=Visibility=Public \
  53. --grpc-swift_out=$(dir $<)
  54. ECHO_PROTO=Sources/Examples/Echo/Model/echo.proto
  55. ECHO_PB=$(ECHO_PROTO:.proto=.pb.swift)
  56. ECHO_GRPC=$(ECHO_PROTO:.proto=.grpc.swift)
  57. # For Echo we'll generate the test client as well.
  58. ${ECHO_GRPC}: ${ECHO_PROTO} ${PROTOC_GEN_GRPC_SWIFT}
  59. protoc $< \
  60. --proto_path=$(dir $<) \
  61. --plugin=${PROTOC_GEN_GRPC_SWIFT} \
  62. --grpc-swift_opt=Visibility=Public,TestClient=true \
  63. --grpc-swift_out=$(dir $<)
  64. # Generates protobufs and gRPC client and server for the Echo example
  65. .PHONY:
  66. generate-echo: ${ECHO_PB} ${ECHO_GRPC}
  67. HELLOWORLD_PROTO=Sources/Examples/HelloWorld/Model/helloworld.proto
  68. HELLOWORLD_PB=$(HELLOWORLD_PROTO:.proto=.pb.swift)
  69. HELLOWORLD_GRPC=$(HELLOWORLD_PROTO:.proto=.grpc.swift)
  70. # Generates protobufs and gRPC client and server for the Hello World example
  71. .PHONY:
  72. generate-helloworld: ${HELLOWORLD_PB} ${HELLOWORLD_GRPC}
  73. ROUTE_GUIDE_PROTO=Sources/Examples/RouteGuide/Model/route_guide.proto
  74. ROUTE_GUIDE_PB=$(ROUTE_GUIDE_PROTO:.proto=.pb.swift)
  75. ROUTE_GUIDE_GRPC=$(ROUTE_GUIDE_PROTO:.proto=.grpc.swift)
  76. # Generates protobufs and gRPC client and server for the Route Guide example
  77. .PHONY:
  78. generate-route-guide: ${ROUTE_GUIDE_PB} ${ROUTE_GUIDE_GRPC}
  79. ### Testing ####################################################################
  80. # Normal test suite.
  81. .PHONY:
  82. test:
  83. ${SWIFT_TEST}
  84. # Normal test suite with TSAN enabled.
  85. .PHONY:
  86. test-tsan:
  87. ${SWIFT_TEST} --sanitize=thread
  88. # Runs codegen tests.
  89. .PHONY:
  90. test-plugin: ${PROTOC_GEN_GRPC_SWIFT}
  91. PROTOC_GEN_GRPC_SWIFT=${PROTOC_GEN_GRPC_SWIFT} ./dev/codegen-tests/run-tests.sh
  92. ### Misc. ######################################################################
  93. .PHONY:
  94. clean:
  95. -rm -rf Packages
  96. -rm -rf ${SWIFT_BUILD_PATH}
  97. -rm -rf ${XCODEPROJ}
  98. -rm -f Package.resolved
  99. -cd Examples/Google/NaturalLanguage && make clean