aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/gRPC.podspec.template
diff options
context:
space:
mode:
Diffstat (limited to 'templates/gRPC.podspec.template')
-rw-r--r--templates/gRPC.podspec.template128
1 files changed, 60 insertions, 68 deletions
diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template
index 03c303b414..02e90d7180 100644
--- a/templates/gRPC.podspec.template
+++ b/templates/gRPC.podspec.template
@@ -38,11 +38,27 @@ bad_header_names = ('time.h', 'string.h')
def fix_header_name(name):
split_name = name.split('/')
if split_name[-1] in bad_header_names:
- return '/'.join(split_name[:-1] + ['grpc_' + split_name[-1]])
- else:
- return name
+ split_name[-1] = 'grpc_' + split_name[-1]
+ if split_name[0] == 'include':
+ split_name = split_name[1:]
+ return '/'.join(split_name)
+
+def grpc_files(libs):
+ out = []
+ for lib in libs:
+ if lib.name in ("grpc", "gpr"):
+ out.extend(fix_header_name(h) for h in lib.get('headers', []))
+ out.extend(fix_header_name(h) for h in lib.get('public_headers', []))
+ out.extend(lib.get('src', []))
+ return out;
+
+def grpc_private_headers(libs):
+ out = []
+ for lib in libs:
+ if lib.name in ("grpc", "gpr"):
+ out.extend(lib.get('headers', []))
+ return out
%>
-
Pod::Spec.new do |s|
s.name = 'gRPC'
s.version = '0.6.0'
@@ -58,53 +74,27 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.8'
s.requires_arc = true
+ objc_dir = 'src/objective-c'
+
# Reactive Extensions library for iOS.
- s.subspec 'RxLibrary' do |rs|
- rs.source_files = 'src/objective-c/RxLibrary/*.{h,m}',
- 'src/objective-c/RxLibrary/transformations/*.{h,m}',
- 'src/objective-c/RxLibrary/private/*.{h,m}'
- rs.private_header_files = 'src/objective-c/RxLibrary/private/*.h'
+ s.subspec 'RxLibrary' do |ss|
+ src_dir = "#{objc_dir}/RxLibrary"
+ ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}"
+ ss.private_header_files = "#{src_dir}/private/*.h"
+ ss.header_mappings_dir = "#{objc_dir}"
end
# Core cross-platform gRPC library, written in C.
- s.subspec 'C-Core' do |cs|
- cs.source_files = \
-% for lib in libs:
-% if lib.name in ("grpc", "gpr"):
-% for hdr in lib.get("headers", []):
-'${fix_header_name(hdr)}', \
-% endfor
-% for hdr in lib.get("public_headers", []):
-'${fix_header_name(hdr)}', \
-% endfor
-% for src in lib.src:
-'${src}', \
-% endfor
-% endif
-% endfor
-
- cs.private_header_files = \
-% for lib in libs:
-% if lib.name in ("grpc", "gpr"):
-% for hdr in lib.get("headers", []):
-'${hdr}', \
-% endfor
-% endif
-% endfor
-
- cs.header_mappings_dir = '.'
- # The core library includes its headers as either "src/core/..." or "grpc/...", meaning we have
- # to tell XCode to look for headers under the "include" subdirectory too.
- #
- # TODO(jcanizales): Instead of doing this, during installation move everything under
- # "include/grpc" one directory up. The directory names under PODS_ROOT are implementation
- # details of Cocoapods, and have changed in the past, breaking this podspec.
- cs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Private/gRPC" ' +
- '"$(PODS_ROOT)/Headers/Private/gRPC/include"' }
-
- cs.requires_arc = false
- cs.libraries = 'z'
- cs.dependency 'OpenSSL', '~> 1.0.200'
+ s.subspec 'C-Core' do |ss|
+ ss.source_files = ${(',\n' + 22*' ').join('\'%s\'' % f for f in grpc_files(libs))}
+
+ ss.private_header_files = ${(',\n' + 30*' ').join('\'%s\'' % f for f in grpc_private_headers(libs))}
+
+ ss.header_mappings_dir = '.'
+
+ ss.requires_arc = false
+ ss.libraries = 'z'
+ ss.dependency 'OpenSSL', '~> 1.0.200'
end
# This is a workaround for Cocoapods Issue #1437.
@@ -112,12 +102,15 @@ Pod::Spec.new do |s|
# It needs to be here (top-level) instead of in the C-Core subspec because Cocoapods doesn't run
# prepare_command's of subspecs.
#
- # TODO(jcanizales): Try out Todd Reed's solution at Issue #1437.
+ # TODO(jcanizales): Try out others' solutions at Issue #1437.
s.prepare_command = <<-CMD
+ # Move contents of include up a level to avoid manually specifying include paths
+ cp -r "include/grpc" "."
+
DIR_TIME="grpc/support"
BAD_TIME="$DIR_TIME/time.h"
GOOD_TIME="$DIR_TIME/grpc_time.h"
- grep -rl "$BAD_TIME" include/grpc src/core | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
+ grep -rl "$BAD_TIME" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_TIME@$GOOD_TIME@g
if [ -f "include/$BAD_TIME" ];
then
mv -f "include/$BAD_TIME" "include/$GOOD_TIME"
@@ -126,7 +119,7 @@ Pod::Spec.new do |s|
DIR_STRING="src/core/support"
BAD_STRING="$DIR_STRING/string.h"
GOOD_STRING="$DIR_STRING/grpc_string.h"
- grep -rl "$BAD_STRING" include/grpc src/core | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
+ grep -rl "$BAD_STRING" grpc src/core src/objective-c/GRPCClient | xargs sed -i '' -e s@$BAD_STRING@$GOOD_STRING@g
if [ -f "$BAD_STRING" ];
then
mv -f "$BAD_STRING" "$GOOD_STRING"
@@ -134,28 +127,27 @@ Pod::Spec.new do |s|
CMD
# Objective-C wrapper around the core gRPC library.
- s.subspec 'GRPCClient' do |gs|
- gs.source_files = 'src/objective-c/GRPCClient/*.{h,m}',
- 'src/objective-c/GRPCClient/private/*.{h,m}'
- gs.private_header_files = 'src/objective-c/GRPCClient/private/*.h'
- gs.compiler_flags = '-GCC_WARN_INHIBIT_ALL_WARNINGS', '-w'
-
- gs.dependency 'gRPC/C-Core'
- # TODO(jcanizales): Remove this when the prepare_command moves everything under "include/grpc"
- # one directory up.
- gs.xcconfig = { 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers/Public/gRPC/include"' }
- gs.dependency 'gRPC/RxLibrary'
+ s.subspec 'GRPCClient' do |ss|
+ src_dir = "#{objc_dir}/GRPCClient"
+ ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}"
+ ss.private_header_files = "#{src_dir}/private/*.h"
+ ss.header_mappings_dir = "#{objc_dir}"
+
+ ss.dependency 'gRPC/C-Core'
+ ss.dependency 'gRPC/RxLibrary'
# Certificates, to be able to establish TLS connections:
- gs.resource_bundles = { 'gRPC' => ['etc/roots.pem'] }
+ ss.resource_bundles = { 'gRPC' => ['etc/roots.pem'] }
end
# RPC library for ProtocolBuffers, based on gRPC
- s.subspec 'ProtoRPC' do |ps|
- ps.source_files = 'src/objective-c/ProtoRPC/*.{h,m}'
-
- ps.dependency 'gRPC/GRPCClient'
- ps.dependency 'gRPC/RxLibrary'
- ps.dependency 'Protobuf', '~> 3.0.0-alpha-3'
+ s.subspec 'ProtoRPC' do |ss|
+ src_dir = "#{objc_dir}/ProtoRPC"
+ ss.source_files = "#{src_dir}/*.{h,m}"
+ ss.header_mappings_dir = "#{objc_dir}"
+
+ ss.dependency 'gRPC/GRPCClient'
+ ss.dependency 'gRPC/RxLibrary'
+ ss.dependency 'Protobuf', '~> 3.0.0-alpha-3'
end
end