blob: 495ea49c9c229de4f1a2c9e2f1f9405962e4e182 [file] [log] [blame]
murgatroid99c525de82015-06-22 11:17:33 -07001# 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
7# Copyright 2015, Google Inc.
8# All rights reserved.
9#
10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions are
12# met:
13#
14# * Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer.
16# * Redistributions in binary form must reproduce the above
17# copyright notice, this list of conditions and the following disclaimer
18# in the documentation and/or other materials provided with the
19# distribution.
20# * Neither the name of Google Inc. nor the names of its
21# contributors may be used to endorse or promote products derived from
22# this software without specific prior written permission.
23#
24# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
murgatroid99f398d5c2015-06-16 14:07:36 -070036<%!
37bad_header_names = ('time.h', 'string.h')
38def fix_header_name(name):
39 split_name = name.split('/')
40 if split_name[-1] in bad_header_names:
murgatroid99df355772015-06-23 16:39:29 -070041 split_name[-1] = 'grpc_' + split_name[-1]
42 if split_name[0] == 'include':
43 split_name = split_name[1:]
44 return '/'.join(split_name)
Craig Tillereb327fb2015-06-23 16:51:38 -070045
46def grpc_files(libs):
47 out = []
48 for lib in libs:
49 if lib.name in ("grpc", "gpr"):
50 out.extend(fix_header_name(h) for h in lib.get('headers', []))
51 out.extend(fix_header_name(h) for h in lib.get('public_headers', []))
52 out.extend(lib.get('src', []))
53 return out;
54
55def grpc_private_headers(libs):
56 out = []
57 for lib in libs:
58 if lib.name in ("grpc", "gpr"):
59 out.extend(lib.get('headers', []))
60 return out
murgatroid99f398d5c2015-06-16 14:07:36 -070061%>
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +020062Pod::Spec.new do |s|
63 s.name = 'gRPC'
64 s.version = '0.6.0'
65 s.summary = 'gRPC client library for iOS/OSX'
66 s.homepage = 'http://www.grpc.io'
67 s.license = 'New BSD'
68 s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
69
70 # s.source = { :git => 'https://github.com/grpc/grpc.git',
71 # :tag => 'release-0_9_1-objectivec-0.5.1' }
72
73 s.ios.deployment_target = '6.0'
74 s.osx.deployment_target = '10.8'
75 s.requires_arc = true
76
Jorge Canizalesea9b4fd2015-06-21 13:37:28 -070077 objc_dir = 'src/objective-c'
78
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +020079 # Reactive Extensions library for iOS.
Jorge Canizalesea9b4fd2015-06-21 13:37:28 -070080 s.subspec 'RxLibrary' do |ss|
81 src_dir = "#{objc_dir}/RxLibrary"
82 ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}"
83 ss.private_header_files = "#{src_dir}/private/*.h"
84 ss.header_mappings_dir = "#{objc_dir}"
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +020085 end
86
87 # Core cross-platform gRPC library, written in C.
Jorge Canizalesea9b4fd2015-06-21 13:37:28 -070088 s.subspec 'C-Core' do |ss|
Craig Tiller9f903da2015-06-24 08:59:27 -070089 ss.source_files = ${(',\n' + 22*' ').join('\'%s\'' % f for f in grpc_files(libs))}
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +020090
Craig Tiller9f903da2015-06-24 08:59:27 -070091 ss.private_header_files = ${(',\n' + 30*' ').join('\'%s\'' % f for f in grpc_private_headers(libs))}
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +020092
Jorge Canizalesea9b4fd2015-06-21 13:37:28 -070093 ss.header_mappings_dir = '.'
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +020094
Jorge Canizalesea9b4fd2015-06-21 13:37:28 -070095 ss.requires_arc = false
96 ss.libraries = 'z'
97 ss.dependency 'OpenSSL', '~> 1.0.200'
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +020098 end
99
100 # This is a workaround for Cocoapods Issue #1437.
101 # It renames time.h and string.h to grpc_time.h and grpc_string.h.
102 # It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run
103 # prepare_command's of subspecs.
104 #
Jorge Canizalesea9b4fd2015-06-21 13:37:28 -0700105 # TODO(jcanizales): Try out others' solutions at Issue #1437.
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200106 s.prepare_command = <<-CMD
murgatroid99df355772015-06-23 16:39:29 -0700107 # Move contents of include up a level to avoid manually specifying include paths
108 cp -r "include/grpc" "."
109
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200110 DIR_TIME="grpc/support"
111 BAD_TIME="$DIR_TIME/time.h"
112 GOOD_TIME="$DIR_TIME/grpc_time.h"
Jorge Canizales59bb9d72015-06-22 19:04:15 -0700113 grep -rl "$BAD_TIME" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
Jorge Canizales951cd182015-07-02 20:48:50 -0700114 if [ -f "$BAD_TIME" ];
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200115 then
Jorge Canizales951cd182015-07-02 20:48:50 -0700116 mv -f "$BAD_TIME" "$GOOD_TIME"
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200117 fi
118
119 DIR_STRING="src/core/support"
120 BAD_STRING="$DIR_STRING/string.h"
121 GOOD_STRING="$DIR_STRING/grpc_string.h"
Jorge Canizales59bb9d72015-06-22 19:04:15 -0700122 grep -rl "$BAD_STRING" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200123 if [ -f "$BAD_STRING" ];
124 then
125 mv -f "$BAD_STRING" "$GOOD_STRING"
126 fi
127 CMD
128
129 # Objective-C wrapper around the core gRPC library.
Jorge Canizalesea9b4fd2015-06-21 13:37:28 -0700130 s.subspec 'GRPCClient' do |ss|
131 src_dir = "#{objc_dir}/GRPCClient"
132 ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}"
133 ss.private_header_files = "#{src_dir}/private/*.h"
134 ss.header_mappings_dir = "#{objc_dir}"
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200135
Jorge Canizalesea9b4fd2015-06-21 13:37:28 -0700136 ss.dependency 'gRPC/C-Core'
137 ss.dependency 'gRPC/RxLibrary'
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200138
139 # Certificates, to be able to establish TLS connections:
Jorge Canizalesbb54ae82015-06-28 06:50:58 -0700140 ss.resource_bundles = { 'gRPCCertificates' => ['etc/roots.pem'] }
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200141 end
142
143 # RPC library for ProtocolBuffers, based on gRPC
Jorge Canizalesea9b4fd2015-06-21 13:37:28 -0700144 s.subspec 'ProtoRPC' do |ss|
145 src_dir = "#{objc_dir}/ProtoRPC"
146 ss.source_files = "#{src_dir}/*.{h,m}"
147 ss.header_mappings_dir = "#{objc_dir}"
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200148
Jorge Canizalesea9b4fd2015-06-21 13:37:28 -0700149 ss.dependency 'gRPC/GRPCClient'
150 ss.dependency 'gRPC/RxLibrary'
151 ss.dependency 'Protobuf', '~> 3.0.0-alpha-3'
Nicolas "Pixel" Nobleb4f35c02015-06-15 22:32:00 +0200152 end
153end