blob: d1b55adabf954d7ca1931c800376a58ae59c443b [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'
Jorge Canizales423f4122015-09-29 14:11:44 -070066 version = '0.11.1'
67 s.version = version
Craig Tiller1ebb7c82015-08-31 15:53:36 -070068 s.summary = 'gRPC client library for iOS/OSX'
69 s.homepage = 'http://www.grpc.io'
70 s.license = 'New BSD'
71 s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
Jorge Canizales423f4122015-09-29 14:11:44 -070072
73 s.source = { :git => 'https://github.com/grpc/grpc.git',
74 :tag => "release-#{version.gsub(/\./, '_')}-objectivec-#{version}" }
75
Craig Tiller1ebb7c82015-08-31 15:53:36 -070076
Craig Tillera32cd492015-09-11 12:28:10 -070077 s.ios.deployment_target = '7.1'
78 s.osx.deployment_target = '10.9'
Craig Tiller1ebb7c82015-08-31 15:53:36 -070079 s.requires_arc = true
80
81 objc_dir = 'src/objective-c'
82
83 # Reactive Extensions library for iOS.
84 s.subspec 'RxLibrary' do |ss|
85 src_dir = "#{objc_dir}/RxLibrary"
86 ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}"
87 ss.private_header_files = "#{src_dir}/private/*.h"
88 ss.header_mappings_dir = "#{objc_dir}"
89 end
90
91 # Core cross-platform gRPC library, written in C.
92 s.subspec 'C-Core' do |ss|
93 ss.source_files = ${(',\n' + 22*' ').join('\'%s\'' % f for f in grpc_files(libs))}
94
95 ss.private_header_files = ${(',\n' + 30*' ').join('\'%s\'' % f for f in grpc_private_headers(libs))}
96
97 ss.header_mappings_dir = '.'
98
99 ss.requires_arc = false
100 ss.libraries = 'z'
101 ss.dependency 'OpenSSL', '~> 1.0.200'
102
103 # ss.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
104 end
105
106 # This is a workaround for Cocoapods Issue #1437.
107 # It renames time.h and string.h to grpc_time.h and grpc_string.h.
108 # It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run
109 # prepare_command's of subspecs.
110 #
111 # TODO(jcanizales): Try out others' solutions at Issue #1437.
112 s.prepare_command = <<-CMD
113 # Move contents of include up a level to avoid manually specifying include paths
114 cp -r "include/grpc" "."
115
116 DIR_TIME="grpc/support"
117 BAD_TIME="$DIR_TIME/time.h"
118 GOOD_TIME="$DIR_TIME/grpc_time.h"
119 grep -rl "$BAD_TIME" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
120 if [ -f "$BAD_TIME" ];
121 then
122 mv -f "$BAD_TIME" "$GOOD_TIME"
123 fi
124
125 DIR_STRING="src/core/support"
126 BAD_STRING="$DIR_STRING/string.h"
127 GOOD_STRING="$DIR_STRING/grpc_string.h"
128 grep -rl "$BAD_STRING" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
129 if [ -f "$BAD_STRING" ];
130 then
131 mv -f "$BAD_STRING" "$GOOD_STRING"
132 fi
133 CMD
134
135 # Objective-C wrapper around the core gRPC library.
136 s.subspec 'GRPCClient' do |ss|
137 src_dir = "#{objc_dir}/GRPCClient"
138 ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}"
139 ss.private_header_files = "#{src_dir}/private/*.h"
140 ss.header_mappings_dir = "#{objc_dir}"
141
142 ss.dependency 'gRPC/C-Core'
143 ss.dependency 'gRPC/RxLibrary'
144
145 # Certificates, to be able to establish TLS connections:
146 ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] }
147 end
148
149 # RPC library for ProtocolBuffers, based on gRPC
150 s.subspec 'ProtoRPC' do |ss|
151 src_dir = "#{objc_dir}/ProtoRPC"
152 ss.source_files = "#{src_dir}/*.{h,m}"
153 ss.header_mappings_dir = "#{objc_dir}"
154
155 ss.dependency 'gRPC/GRPCClient'
156 ss.dependency 'gRPC/RxLibrary'
Craig Tillera32cd492015-09-11 12:28:10 -0700157 ss.dependency 'Protobuf', '~> 3.0.0-alpha-4'
Craig Tiller1ebb7c82015-08-31 15:53:36 -0700158 end
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200159 end