Makefile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # How to run a 'swift' executable that supports the 'swift build', 'swift test', etc commands.
  2. SWIFT=swift
  3. # How to run a working version of protoc
  4. PROTOC=protoc
  5. # How to run awk on your system
  6. AWK=awk
  7. # Protos from Google's source tree that are used for testing purposes
  8. GOOGLE_TEST_PROTOS= \
  9. any_test \
  10. descriptor \
  11. map_unittest \
  12. map_unittest_proto3 \
  13. unittest \
  14. unittest_arena \
  15. unittest_custom_options \
  16. unittest_drop_unknown_fields \
  17. unittest_embed_optimize_for \
  18. unittest_empty \
  19. unittest_import \
  20. unittest_import_lite \
  21. unittest_import_proto3 \
  22. unittest_import_public \
  23. unittest_import_public_lite \
  24. unittest_import_public_proto3 \
  25. unittest_lite_imports_nonlite \
  26. unittest_lite \
  27. unittest_mset \
  28. unittest_mset_wire_format \
  29. unittest_no_arena \
  30. unittest_no_arena_import \
  31. unittest_no_arena_lite \
  32. unittest_no_field_presence \
  33. unittest_no_generic_services \
  34. unittest_optimize_for \
  35. unittest_preserve_unknown_enum \
  36. unittest_preserve_unknown_enum2 \
  37. unittest_proto3 \
  38. unittest_proto3_arena \
  39. unittest_well_known_types
  40. # Protos from Google's source tree that are embedded into
  41. # the Protobuf library module
  42. GOOGLE_LIBRARY_PROTOS= api duration empty field_mask source_context timestamp type
  43. .PHONY: default all build check clean test regenerate regenerate-library-protos regenerate-test-protos regenerate-test-protos-local regenerate-test-protos-google
  44. default: build
  45. all: build
  46. # This also rebuilds LinuxMain.swift to include all of the test cases
  47. # (The awk script is very fast, so re-running it on every build is reasonable.)
  48. build:
  49. ${AWK} -f CollectTests.awk Tests/ProtobufTests/Test_*.swift > Tests/LinuxMain.swift
  50. ${SWIFT} build
  51. check test: build
  52. ${SWIFT} test
  53. clean:
  54. swift build --clean
  55. rm -rf .build
  56. #
  57. # Rebuild the generated .pb.swift test files by running
  58. # protoc over all the relevant inputs.
  59. #
  60. # Before running this, ensure that:
  61. # * protoc-gen-swift is built and installed somewhere in your system PATH
  62. # * protoc is built and installed
  63. # * PROTOC at the top of this file is set correctly
  64. #
  65. regenerate: regenerate-library-protos regenerate-test-protos
  66. # Rebuild just the protos included in the runtime library
  67. regenerate-library-protos:
  68. for t in ${GOOGLE_LIBRARY_PROTOS}; do \
  69. echo google/protobuf/$$t.proto; \
  70. ${PROTOC} --swift_out=Sources/Protobuf -I Protos Protos/google/protobuf/$$t.proto; \
  71. sed -i~ -e 's/^import Protobuf$$//' Sources/Protobuf/$$t.pb.swift; \
  72. done
  73. # Rebuild just the protos used by the test suite
  74. regenerate-test-protos: regenerate-test-protos-google regenerate-test-protos-local
  75. # Rebuild just the protos used by the test suite that come from Google's sources
  76. regenerate-test-protos-google:
  77. for t in ${GOOGLE_TEST_PROTOS}; do \
  78. echo google/protobuf/$$t.proto; \
  79. ${PROTOC} --swift_out=Tests/ProtobufTests -I Protos Protos/google/protobuf/$$t.proto; \
  80. done; \
  81. echo conformance/conformance.proto; \
  82. ${PROTOC} --swift_out=Tests/ProtobufTests -I Protos/conformance -I Protos Protos/conformance/conformance.proto; \
  83. # Rebuild just the protos used by the test suite that come from local sources
  84. regenerate-test-protos-local:
  85. for t in Protos/*.proto; do \
  86. echo $$t; \
  87. ${PROTOC} --swift_out=Tests/ProtobufTests -IProtos $$t; \
  88. done