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