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