gRPC.podspec.template 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <%!
  2. bad_header_names = ('time.h', 'string.h')
  3. def fix_header_name(name):
  4. split_name = name.split('/')
  5. if split_name[-1] in bad_header_names:
  6. return '/'.join(split_name[:-1] + ['grpc_' + split_name[-1]])
  7. else:
  8. return name
  9. %>
  10. Pod::Spec.new do |s|
  11. s.name = 'gRPC'
  12. s.version = '0.6.0'
  13. s.summary = 'gRPC client library for iOS/OSX'
  14. s.homepage = 'http://www.grpc.io'
  15. s.license = 'New BSD'
  16. s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
  17. # s.source = { :git => 'https://github.com/grpc/grpc.git',
  18. # :tag => 'release-0_9_1-objectivec-0.5.1' }
  19. s.ios.deployment_target = '6.0'
  20. s.osx.deployment_target = '10.8'
  21. s.requires_arc = true
  22. # Reactive Extensions library for iOS.
  23. s.subspec 'RxLibrary' do |rs|
  24. rs.source_files = 'src/objective-c/RxLibrary/*.{h,m}',
  25. 'src/objective-c/RxLibrary/transformations/*.{h,m}',
  26. 'src/objective-c/RxLibrary/private/*.{h,m}'
  27. rs.private_header_files = 'src/objective-c/RxLibrary/private/*.h'
  28. end
  29. # Core cross-platform gRPC library, written in C.
  30. s.subspec 'C-Core' do |cs|
  31. cs.source_files = \
  32. % for lib in libs:
  33. % if lib.name in ("grpc", "gpr"):
  34. % for hdr in lib.get("headers", []):
  35. '${fix_header_name(hdr)}', \
  36. % endfor
  37. % for hdr in lib.get("public_headers", []):
  38. '${fix_header_name(hdr)}', \
  39. % endfor
  40. % for src in lib.src:
  41. '${src}', \
  42. % endfor
  43. % endif
  44. % endfor
  45. cs.private_header_files = \
  46. % for lib in libs:
  47. % if lib.name in ("grpc", "gpr"):
  48. % for hdr in lib.get("headers", []):
  49. '${hdr}', \
  50. % endfor
  51. % endif
  52. % endfor
  53. cs.header_mappings_dir = '.'
  54. # The core library includes its headers as either "src/core/..." or "grpc/...", meaning we have
  55. # to tell XCode to look for headers under the "include" subdirectory too.
  56. #
  57. # TODO(jcanizales): Instead of doing this, during installation move everything under
  58. # "include/grpc" one directory up. The directory names under PODS_ROOT are implementation
  59. # details of Cocoapods, and have changed in the past, breaking this podspec.
  60. cs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Private/gRPC" ' +
  61. '"$(PODS_ROOT)/Headers/Private/gRPC/include"' }
  62. cs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
  63. cs.requires_arc = false
  64. cs.libraries = 'z'
  65. cs.dependency 'OpenSSL', '~> 1.0.200'
  66. end
  67. # This is a workaround for Cocoapods Issue #1437.
  68. # It renames time.h and string.h to grpc_time.h and grpc_string.h.
  69. # It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run
  70. # prepare_command's of subspecs.
  71. #
  72. # TODO(jcanizales): Try out Todd Reed's solution at Issue #1437.
  73. s.prepare_command = <<-CMD
  74. DIR_TIME="grpc/support"
  75. BAD_TIME="$DIR_TIME/time.h"
  76. GOOD_TIME="$DIR_TIME/grpc_time.h"
  77. grep -rl "$BAD_TIME" include/grpc src/core | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
  78. if [ -f "include/$BAD_TIME" ];
  79. then
  80. mv -f "include/$BAD_TIME" "include/$GOOD_TIME"
  81. fi
  82. DIR_STRING="src/core/support"
  83. BAD_STRING="$DIR_STRING/string.h"
  84. GOOD_STRING="$DIR_STRING/grpc_string.h"
  85. grep -rl "$BAD_STRING" include/grpc src/core | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
  86. if [ -f "$BAD_STRING" ];
  87. then
  88. mv -f "$BAD_STRING" "$GOOD_STRING"
  89. fi
  90. CMD
  91. # Objective-C wrapper around the core gRPC library.
  92. s.subspec 'GRPCClient' do |gs|
  93. gs.source_files = 'src/objective-c/GRPCClient/*.{h,m}',
  94. 'src/objective-c/GRPCClient/private/*.{h,m}'
  95. gs.private_header_files = 'src/objective-c/GRPCClient/private/*.h'
  96. gs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
  97. gs.dependency 'gRPC/C-Core'
  98. # TODO(jcanizales): Remove this when the prepare_command moves everything under "include/grpc"
  99. # one directory up.
  100. gs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Public/gRPC/include"' }
  101. gs.dependency 'gRPC/RxLibrary'
  102. # Certificates, to be able to establish TLS connections:
  103. gs.resource_bundles = { 'gRPC' => ['etc/roots.pem'] }
  104. end
  105. # RPC library for ProtocolBuffers, based on gRPC
  106. s.subspec 'ProtoRPC' do |ps|
  107. ps.source_files = 'src/objective-c/ProtoRPC/*.{h,m}'
  108. ps.dependency 'gRPC/GRPCClient'
  109. ps.dependency 'gRPC/RxLibrary'
  110. ps.dependency 'Protobuf', '~> 3.0.0-alpha-3'
  111. end
  112. end