gRPC.podspec.template 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # GRPC CocoaPods podspec
  2. # This file has been automatically generated from a template file.
  3. # Please look at the templates directory instead.
  4. # This file can be regenerated from the template by running
  5. # tools/buildgen/generate_projects.sh
  6. # Copyright 2015, Google Inc.
  7. # All rights reserved.
  8. #
  9. # Redistribution and use in source and binary forms, with or without
  10. # modification, are permitted provided that the following conditions are
  11. # met:
  12. #
  13. # * Redistributions of source code must retain the above copyright
  14. # notice, this list of conditions and the following disclaimer.
  15. # * Redistributions in binary form must reproduce the above
  16. # copyright notice, this list of conditions and the following disclaimer
  17. # in the documentation and/or other materials provided with the
  18. # distribution.
  19. # * Neither the name of Google Inc. nor the names of its
  20. # contributors may be used to endorse or promote products derived from
  21. # this software without specific prior written permission.
  22. #
  23. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  24. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  25. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  26. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  27. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  28. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  29. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  30. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  32. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. <%!
  35. bad_header_names = ('time.h', 'string.h')
  36. def fix_header_name(name):
  37. split_name = name.split('/')
  38. if split_name[-1] in bad_header_names:
  39. return '/'.join(split_name[:-1] + ['grpc_' + split_name[-1]])
  40. else:
  41. return name
  42. def grpc_files(libs):
  43. out = []
  44. for lib in libs:
  45. if lib.name in ("grpc", "gpr"):
  46. out.extend(fix_header_name(h) for h in lib.get('headers', []))
  47. out.extend(fix_header_name(h) for h in lib.get('public_headers', []))
  48. out.extend(lib.get('src', []))
  49. return out;
  50. def grpc_private_headers(libs):
  51. out = []
  52. for lib in libs:
  53. if lib.name in ("grpc", "gpr"):
  54. out.extend(lib.get('headers', []))
  55. return out
  56. %>
  57. Pod::Spec.new do |s|
  58. s.name = 'gRPC'
  59. s.version = '0.6.0'
  60. s.summary = 'gRPC client library for iOS/OSX'
  61. s.homepage = 'http://www.grpc.io'
  62. s.license = 'New BSD'
  63. s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
  64. # s.source = { :git => 'https://github.com/grpc/grpc.git',
  65. # :tag => 'release-0_9_1-objectivec-0.5.1' }
  66. s.ios.deployment_target = '6.0'
  67. s.osx.deployment_target = '10.8'
  68. s.requires_arc = true
  69. # Reactive Extensions library for iOS.
  70. s.subspec 'RxLibrary' do |rs|
  71. rs.source_files = 'src/objective-c/RxLibrary/*.{h,m}',
  72. 'src/objective-c/RxLibrary/transformations/*.{h,m}',
  73. 'src/objective-c/RxLibrary/private/*.{h,m}'
  74. rs.private_header_files = 'src/objective-c/RxLibrary/private/*.h'
  75. end
  76. # Core cross-platform gRPC library, written in C.
  77. s.subspec 'C-Core' do |cs|
  78. cs.source_files = ${(',\n' + 22*' ').join('\'%s\'' % f for f in grpc_files(libs))}
  79. cs.private_header_files = ${(',\n' + 30*' ').join('\'%s\'' % f for f in grpc_private_headers(libs))}
  80. cs.header_mappings_dir = '.'
  81. # The core library includes its headers as either "src/core/..." or "grpc/...", meaning we have
  82. # to tell XCode to look for headers under the "include" subdirectory too.
  83. #
  84. # TODO(jcanizales): Instead of doing this, during installation move everything under
  85. # "include/grpc" one directory up. The directory names under PODS_ROOT are implementation
  86. # details of Cocoapods, and have changed in the past, breaking this podspec.
  87. cs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Private/gRPC" ' +
  88. '"$(PODS_ROOT)/Headers/Private/gRPC/include"' }
  89. cs.requires_arc = false
  90. cs.libraries = 'z'
  91. cs.dependency 'OpenSSL', '~> 1.0.200'
  92. end
  93. # This is a workaround for Cocoapods Issue #1437.
  94. # It renames time.h and string.h to grpc_time.h and grpc_string.h.
  95. # It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run
  96. # prepare_command's of subspecs.
  97. #
  98. # TODO(jcanizales): Try out Todd Reed's solution at Issue #1437.
  99. s.prepare_command = <<-CMD
  100. DIR_TIME="grpc/support"
  101. BAD_TIME="$DIR_TIME/time.h"
  102. GOOD_TIME="$DIR_TIME/grpc_time.h"
  103. grep -rl "$BAD_TIME" include/grpc src/core | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
  104. if [ -f "include/$BAD_TIME" ];
  105. then
  106. mv -f "include/$BAD_TIME" "include/$GOOD_TIME"
  107. fi
  108. DIR_STRING="src/core/support"
  109. BAD_STRING="$DIR_STRING/string.h"
  110. GOOD_STRING="$DIR_STRING/grpc_string.h"
  111. grep -rl "$BAD_STRING" include/grpc src/core | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
  112. if [ -f "$BAD_STRING" ];
  113. then
  114. mv -f "$BAD_STRING" "$GOOD_STRING"
  115. fi
  116. CMD
  117. # Objective-C wrapper around the core gRPC library.
  118. s.subspec 'GRPCClient' do |gs|
  119. gs.source_files = 'src/objective-c/GRPCClient/*.{h,m}',
  120. 'src/objective-c/GRPCClient/private/*.{h,m}'
  121. gs.private_header_files = 'src/objective-c/GRPCClient/private/*.h'
  122. gs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
  123. gs.dependency 'gRPC/C-Core'
  124. # TODO(jcanizales): Remove this when the prepare_command moves everything under "include/grpc"
  125. # one directory up.
  126. gs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Public/gRPC/include"' }
  127. gs.dependency 'gRPC/RxLibrary'
  128. # Certificates, to be able to establish TLS connections:
  129. gs.resource_bundles = { 'gRPC' => ['etc/roots.pem'] }
  130. end
  131. # RPC library for ProtocolBuffers, based on gRPC
  132. s.subspec 'ProtoRPC' do |ps|
  133. ps.source_files = 'src/objective-c/ProtoRPC/*.{h,m}'
  134. ps.dependency 'gRPC/GRPCClient'
  135. ps.dependency 'gRPC/RxLibrary'
  136. ps.dependency 'Protobuf', '~> 3.0.0-alpha-3'
  137. end
  138. end