Makefile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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-swiftgrpc
  16. protoc-gen-swift:
  17. ${SWIFT_BUILD} --product protoc-gen-swift
  18. protoc-gen-swiftgrpc:
  19. ${SWIFT_BUILD} --product protoc-gen-swiftgrpc
  20. interop-test-runner:
  21. ${SWIFT_BUILD} --product InteroperabilityTestRunner
  22. interop-backoff-test-runner:
  23. ${SWIFT_BUILD} --product ConnectionBackoffInteropTestRunner
  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/echo.proto \
  37. --proto_path=Sources/Examples/Echo \
  38. --plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swift \
  39. --plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swiftgrpc \
  40. --swift_out=Sources/Examples/Echo/Generated \
  41. --swiftgrpc_out=Sources/Examples/Echo/Generated
  42. ### Testing ####################################################################
  43. # Normal test suite.
  44. test:
  45. ${SWIFT_TEST}
  46. # Checks that linuxmain has been updated: requires macOS.
  47. test-generate-linuxmain: generate-linuxmain
  48. @git diff --exit-code Tests/LinuxMain.swift Tests/*/XCTestManifests.swift > /dev/null || \
  49. { echo "Generated tests are out-of-date; run 'swift test --generate-linuxmain' to update them!"; exit 1; }
  50. # Generates code for the Echo server and client and tests them against 'golden' data.
  51. test-plugin: plugins
  52. protoc Sources/Examples/Echo/echo.proto \
  53. --proto_path=Sources/Examples/Echo \
  54. --plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swift \
  55. --plugin=${SWIFT_BUILD_PATH}/${SWIFT_BUILD_CONFIGURATION}/protoc-gen-swiftgrpc \
  56. --swiftgrpc_out=/tmp
  57. diff -u /tmp/echo.grpc.swift Sources/Examples/Echo/Generated/echo.grpc.swift
  58. ### Misc. ######################################################################
  59. clean:
  60. -rm -rf Packages
  61. -rm -rf ${SWIFT_BUILD_PATH}
  62. -rm -rf ${XCODEPROJ}
  63. -rm -f Package.pins Package.resolved
  64. -cd Examples/Google/Datastore && make clean
  65. -cd Examples/Google/NaturalLanguage && make clean
  66. -cd Examples/Google/Spanner && make clean