Makefile 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. UNAME_S = $(shell uname -s)
  2. ifeq ($(UNAME_S),Linux)
  3. else
  4. CFLAGS = -Xcc -ISources/BoringSSL/include -Xlinker -lz
  5. endif
  6. all:
  7. swift build $(CFLAGS)
  8. cp .build/debug/protoc-gen-swift .
  9. cp .build/debug/protoc-gen-swiftgrpc .
  10. plugin:
  11. swift build $(CFLAGS) --product protoc-gen-swift -c release -Xswiftc -static-stdlib
  12. swift build $(CFLAGS) --product protoc-gen-swiftgrpc -c release -Xswiftc -static-stdlib
  13. cp .build/release/protoc-gen-swift .
  14. cp .build/release/protoc-gen-swiftgrpc .
  15. project:
  16. swift package $(CFLAGS) generate-xcodeproj --output SwiftGRPC.xcodeproj
  17. @-ruby fix-project-settings.rb SwiftGRPC.xcodeproj || echo "Consider running 'sudo gem install xcodeproj' to automatically set correct indentation settings for the generated project."
  18. project-carthage:
  19. swift package generate-xcodeproj --output SwiftGRPC-Carthage.xcodeproj
  20. @sed -i '' -e "s|$(PWD)|..|g" SwiftGRPC-Carthage.xcodeproj/project.pbxproj
  21. @sed -i '' -e "s|$(PWD)|../../..|g" SwiftGRPC-Carthage.xcodeproj/GeneratedModuleMap/BoringSSL/module.modulemap
  22. @ruby fix-project-settings.rb SwiftGRPC-Carthage.xcodeproj || echo "xcodeproj ('sudo gem install xcodeproj') is required in order to generate the Carthage-compatible project!"
  23. @ruby patch-carthage-project.rb SwiftGRPC-Carthage.xcodeproj || echo "xcodeproj ('sudo gem install xcodeproj') is required in order to generate the Carthage-compatible project!"
  24. test: all
  25. swift test $(CFLAGS)
  26. test-echo: all
  27. cp .build/debug/Echo .
  28. ./Echo serve & /bin/echo $$! > echo.pid
  29. ./Echo get | tee test.out
  30. ./Echo expand | tee -a test.out
  31. ./Echo collect | tee -a test.out
  32. ./Echo update | tee -a test.out
  33. kill -9 `cat echo.pid`
  34. diff -u test.out Sources/Examples/Echo/test.gold
  35. test-echo-nio: all
  36. cp .build/debug/EchoNIO .
  37. cp .build/debug/Echo .
  38. ./EchoNIO serve & /bin/echo $$! > echo.pid
  39. ./Echo get | tee test.out
  40. ./Echo expand | tee -a test.out
  41. ./Echo collect | tee -a test.out
  42. ./Echo update | tee -a test.out
  43. kill -9 `cat echo.pid`
  44. diff -u test.out Sources/Examples/Echo/test.gold
  45. test-plugin:
  46. swift build $(CFLAGS) --product protoc-gen-swiftgrpc
  47. protoc Sources/Examples/Echo/echo.proto --proto_path=Sources/Examples/Echo --plugin=.build/debug/protoc-gen-swift --plugin=.build/debug/protoc-gen-swiftgrpc --swiftgrpc_out=/tmp --swiftgrpc_opt=TestStubs=true
  48. diff -u /tmp/echo.grpc.swift Sources/Examples/Echo/Generated/echo.grpc.swift
  49. test-plugin-nio:
  50. swift build $(CFLAGS) --product protoc-gen-swiftgrpc
  51. protoc Sources/Examples/Echo/echo.proto --proto_path=Sources/Examples/Echo --plugin=.build/debug/protoc-gen-swift --plugin=.build/debug/protoc-gen-swiftgrpc --swiftgrpc_out=/tmp --swiftgrpc_opt=NIO=true
  52. diff -u /tmp/echo.grpc.swift Sources/Examples/EchoNIO/Generated/echo.grpc.swift
  53. test-generate-linuxmain:
  54. ifeq ($(UNAME_S), Darwin)
  55. swift test --generate-linuxmain
  56. @git diff --exit-code */LinuxMain.swift */XCTestManifests.swift > /dev/null || { echo "Generated tests are out-of-date; run 'swift test --generate-linuxmain' to update them!"; exit 1; }
  57. else
  58. echo "test-generate-linuxmain is only available on Darwin"
  59. endif
  60. xcodebuild: project
  61. xcodebuild -project SwiftGRPC.xcodeproj -configuration "Debug" -parallelizeTargets -target SwiftGRPC -target Echo -target Simple -target protoc-gen-swiftgrpc build
  62. build-carthage:
  63. carthage build -project SwiftGRPC-Carthage.xcodeproj --no-skip-current
  64. build-carthage-debug:
  65. carthage build -project SwiftGRPC-Carthage.xcodeproj --no-skip-current --configuration Debug --platform iOS, macOS
  66. clean:
  67. -rm -rf Packages
  68. -rm -rf .build build
  69. -rm -rf SwiftGRPC.xcodeproj
  70. -rm -rf Package.pins Package.resolved
  71. -rm -rf protoc-gen-swift protoc-gen-swiftgrpc
  72. -cd Examples/Google/Datastore && make clean
  73. -cd Examples/Google/NaturalLanguage && make clean
  74. -cd Examples/Google/Spanner && make clean