Makefile 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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}
  7. SWIFT_BUILD:=${SWIFT} build ${SWIFT_FLAGS}
  8. SWIFT_TEST:=${SWIFT} test ${SWIFT_FLAGS}
  9. SWIFT_PACKAGE:=${SWIFT} package ${SWIFT_FLAGS}
  10. # Name of generated xcodeproj
  11. XCODEPROJ:=GRPC.xcodeproj
  12. ### Package and plugin build targets ###########################################
  13. all:
  14. ${SWIFT_BUILD}
  15. plugins: protoc-gen-swift protoc-gen-grpc-swift
  16. protoc-gen-swift:
  17. ${SWIFT_BUILD} --product protoc-gen-swift
  18. protoc-gen-grpc-swift:
  19. ${SWIFT_BUILD} --product protoc-gen-grpc-swift
  20. interop-test-runner:
  21. ${SWIFT_BUILD} --product GRPCInteroperabilityTests
  22. interop-backoff-test-runner:
  23. ${SWIFT_BUILD} --product GRPCConnectionBackoffInteropTest
  24. ### Xcodeproj and LinuxMain
  25. project: ${XCODEPROJ}
  26. ${XCODEPROJ}:
  27. ${SWIFT_PACKAGE} generate-xcodeproj --output $@
  28. @-ruby fix-project-settings.rb GRPC.xcodeproj || \
  29. echo "Consider running 'sudo gem install xcodeproj' to automatically set correct indentation settings for the generated project."
  30. # Generates LinuxMain.swift, only on macOS.
  31. generate-linuxmain:
  32. ${SWIFT_TEST} --generate-linuxmain
  33. ### Protobuf Generation ########################################################
  34. # Generates protobufs and gRPC client and server for the Echo example
  35. generate-echo: plugins
  36. protoc Sources/Examples/Echo/Model/echo.proto \
  37. --proto_path=Sources/Examples/Echo/Model \
  38. --plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swift \
  39. --plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-grpc-swift \
  40. --swift_opt=Visibility=Public \
  41. --swift_out=Sources/Examples/Echo/Model/Generated \
  42. --grpc-swift_opt=Visibility=Public \
  43. --grpc-swift_out=Sources/Examples/Echo/Model/Generated
  44. ### Testing ####################################################################
  45. # Normal test suite.
  46. test:
  47. ${SWIFT_TEST}
  48. # Checks that linuxmain has been updated: requires macOS.
  49. test-generate-linuxmain: generate-linuxmain
  50. @git diff --exit-code Tests/LinuxMain.swift Tests/*/XCTestManifests.swift > /dev/null || \
  51. { echo "Generated tests are out-of-date; run 'swift test --generate-linuxmain' to update them!"; exit 1; }
  52. # Generates code for the Echo server and client and tests them against 'golden' data.
  53. test-plugin: plugins
  54. protoc Sources/Examples/Echo/Model/echo.proto \
  55. --proto_path=Sources/Examples/Echo/Model \
  56. --plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swift \
  57. --plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-grpc-swift \
  58. --grpc-swift_opt=Visibility=Public \
  59. --grpc-swift_out=/tmp
  60. diff -u /tmp/echo.grpc.swift Sources/Examples/Echo/Model/Generated/echo.grpc.swift
  61. ### Misc. ######################################################################
  62. clean:
  63. -rm -rf Packages
  64. -rm -rf ${SWIFT_BUILD_PATH}
  65. -rm -rf ${XCODEPROJ}
  66. -rm -f Package.pins Package.resolved
  67. -cd Examples/Google/Datastore && make clean
  68. -cd Examples/Google/NaturalLanguage && make clean
  69. -cd Examples/Google/Spanner && make clean