gRPC.podspec.template 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. cs.requires_arc = false
  55. cs.libraries = 'z'
  56. cs.dependency 'OpenSSL', '~> 1.0.200'
  57. end
  58. # This is a workaround for Cocoapods Issue #1437.
  59. # It renames time.h and string.h to grpc_time.h and grpc_string.h.
  60. # It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run
  61. # prepare_command's of subspecs.
  62. #
  63. # TODO(jcanizales): Try out Todd Reed's solution at Issue #1437.
  64. s.prepare_command = <<-CMD
  65. DIR_TIME="grpc/support"
  66. BAD_TIME="$DIR_TIME/time.h"
  67. GOOD_TIME="$DIR_TIME/grpc_time.h"
  68. grep -rl "$BAD_TIME" include/grpc src/core | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
  69. if [ -f "include/$BAD_TIME" ];
  70. then
  71. mv -f "include/$BAD_TIME" "include/$GOOD_TIME"
  72. fi
  73. DIR_STRING="src/core/support"
  74. BAD_STRING="$DIR_STRING/string.h"
  75. GOOD_STRING="$DIR_STRING/grpc_string.h"
  76. grep -rl "$BAD_STRING" include/grpc src/core | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
  77. if [ -f "$BAD_STRING" ];
  78. then
  79. mv -f "$BAD_STRING" "$GOOD_STRING"
  80. fi
  81. CMD
  82. # Objective-C wrapper around the core gRPC library.
  83. s.subspec 'GRPCClient' do |gs|
  84. gs.source_files = 'src/objective-c/GRPCClient/*.{h,m}',
  85. 'src/objective-c/GRPCClient/private/*.{h,m}'
  86. gs.private_header_files = 'src/objective-c/GRPCClient/private/*.h'
  87. gs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
  88. gs.dependency 'gRPC/C-Core'
  89. # TODO(jcanizales): Remove this when the prepare_command moves everything under "include/grpc"
  90. # one directory up.
  91. gs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Public/gRPC/include"' }
  92. gs.dependency 'gRPC/RxLibrary'
  93. # Certificates, to be able to establish TLS connections:
  94. gs.resource_bundles = { 'gRPC' => ['etc/roots.pem'] }
  95. end
  96. # RPC library for ProtocolBuffers, based on gRPC
  97. s.subspec 'ProtoRPC' do |ps|
  98. ps.source_files = 'src/objective-c/ProtoRPC/*.{h,m}'
  99. ps.dependency 'gRPC/GRPCClient'
  100. ps.dependency 'gRPC/RxLibrary'
  101. ps.dependency 'Protobuf', '~> 3.0.0-alpha-3'
  102. end
  103. end