3 # This file has been automatically generated from a template file.
4 # Please make modifications to `templates/gRPC-C++.podspec.template`
5 # instead. This file can be regenerated from the template by running
6 # `tools/buildgen/generate_projects.sh`.
8 # gRPC C++ CocoaPods podspec
10 # Copyright 2017 gRPC authors.
12 # Licensed under the Apache License, Version 2.0 (the "License");
13 # you may not use this file except in compliance with the License.
14 # You may obtain a copy of the License at
16 # http://www.apache.org/licenses/LICENSE-2.0
18 # Unless required by applicable law or agreed to in writing, software
19 # distributed under the License is distributed on an "AS IS" BASIS,
20 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 # See the License for the specific language governing permissions and
22 # limitations under the License.
24 lib_maps = {lib.name: lib for lib in libs}
25 filegroup_maps = {filegroup.name: filegroup for filegroup in filegroups}
27 def ruby_multiline_list(files, indent):
28 return (',\n' + indent*' ').join('\'%s\'' % f for f in files)
30 def is_absl_lib(target_name):
31 return target_name.startswith("absl/")
33 def get_absl_spec_name(label):
34 # e.g. absl/apple:banana -> abseil/apple/banana
35 return "abseil/" + label[5:].replace(":", "/")
37 def lib_and_transitive_deps(lib):
38 return list(sorted(set({lib} | set(lib_maps[lib].transitive_deps))))
40 def non_abseil_lib_and_transitive_deps(lib):
41 return [l for l in lib_and_transitive_deps(lib) if not is_absl_lib(l)]
43 def list_abseil_specs(lib):
44 # This returns a list of abseil specs which the given lib and
45 # its non-abseil transitive dependencies depend on.
46 # As a result, internal abseil libraries are excluded from the result.
48 for lib_name in lib_and_transitive_deps(lib):
49 if is_absl_lib(lib_name): continue
50 for dep in lib_maps[lib_name].deps:
52 absl_specs.add(get_absl_spec_name(dep))
53 return list(sorted(absl_specs))
55 def list_lib_files(lib, fields):
57 for lib_name in non_abseil_lib_and_transitive_deps(lib):
58 lib = lib_maps[lib_name]
60 files.update(lib.get(field, []))
61 return list(sorted(files))
63 def list_filegroup_files(expect_filegroups, groups):
65 for filegroup_name in expect_filegroups:
66 filegroup = filegroup_maps[filegroup_name]
68 out += filegroup.get(group, [])
69 return list(sorted(set(out)))
71 def filter_grpcpp(files):
72 return sorted([file for file in files if not file.startswith("include/grpc++")])
74 grpc_private_files = list_lib_files("grpc", ("headers", "src"))
75 grpc_public_headers = list_lib_files("grpc", ("public_headers",))
76 grpc_private_headers = list_lib_files("grpc", ("headers",))
78 grpcpp_proto_files = filter_grpcpp(
79 set(list_filegroup_files(("grpc++_codegen_proto", "grpc++_config_proto"), ("headers", "src", "public_headers")))
80 - set(list_filegroup_files(("grpc++_codegen_base",), ("headers", "src", "public_headers")))
82 grpcpp_private_files = filter_grpcpp(
83 set(list_lib_files("grpc++", ("headers", "src")))
84 - set(grpc_private_files)
85 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
86 - set(grpcpp_proto_files)
88 grpcpp_private_headers = filter_grpcpp(
89 set(list_lib_files("grpc++", ("headers",)))
90 - set(grpc_private_headers)
91 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
92 - set(grpcpp_proto_files)
94 grpcpp_public_headers = filter_grpcpp(
95 set(list_lib_files("grpc++", ("public_headers",)))
96 - set(grpc_public_headers)
97 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
98 - set(grpcpp_proto_files)
100 grpcpp_abseil_specs = list_abseil_specs("grpc++")
104 # TODO (mxyan): use version that match gRPC version when pod is stabilized
105 version = '${settings.version}'
107 s.summary = 'gRPC C++ library'
108 s.homepage = 'https://grpc.io'
109 s.license = 'Apache License, Version 2.0'
110 s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
113 :git => 'https://github.com/grpc/grpc.git',
114 :tag => "v#{version}",
117 s.ios.deployment_target = '7.0'
118 s.osx.deployment_target = '10.9'
119 s.tvos.deployment_target = '10.0'
121 s.requires_arc = false
124 # Use `grpcpp` as framework name so that `#include <grpcpp/xxx.h>` works when built as
128 # Add include prefix `grpcpp` so that `#include <grpcpp/xxx.h>` works when built as static
132 s.pod_target_xcconfig = {
133 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"',
134 'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"',
135 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1"',
136 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
137 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
139 # If we don't set these two settings, `include/grpc/support/time.h` and
140 # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
142 'USE_HEADERMAP' => 'NO',
143 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
147 s.compiler_flags = '-Wno-comma'
149 s.default_subspecs = 'Interface', 'Implementation'
151 # Certificates, to be able to establish TLS connections:
152 s.resource_bundles = { 'gRPCCertificates-Cpp' => ['etc/roots.pem'] }
154 s.header_mappings_dir = 'include/grpcpp'
156 s.subspec 'Interface' do |ss|
157 ss.header_mappings_dir = 'include/grpcpp'
159 ss.source_files = ${ruby_multiline_list(grpcpp_public_headers, 22)}
162 s.subspec 'Implementation' do |ss|
163 ss.header_mappings_dir = '.'
164 ss.dependency "#{s.name}/Interface", version
165 ss.dependency 'gRPC-Core', version
166 abseil_version = '0.20190808.1'
167 % for abseil_spec in grpcpp_abseil_specs:
168 ss.dependency '${abseil_spec}', abseil_version
171 ss.source_files = ${ruby_multiline_list(sorted(grpcpp_private_files + grpc_private_headers), 22)}
173 ss.private_header_files = ${ruby_multiline_list(sorted(grpcpp_private_headers + grpc_private_headers), 30)}
176 s.subspec 'Protobuf' do |ss|
177 ss.header_mappings_dir = 'include/grpcpp'
178 ss.dependency "#{s.name}/Interface", version
180 ss.source_files = ${ruby_multiline_list(grpcpp_proto_files, 22)}
183 s.subspec 'Cronet-Interface' do |ss|
184 ss.header_mappings_dir = 'include/grpcpp'
185 ss.public_header_files = "include/grpcpp/security/cronet_credentials.h",
186 "include/grpcpp/security/cronet_credentials_impl.h"
187 ss.source_files = "include/grpcpp/security/cronet_credentials.h",
188 "include/grpcpp/security/cronet_credentials_impl.h"
191 s.subspec 'Cronet-Implementation' do |ss|
192 ss.header_mappings_dir = '.'
193 ss.dependency "#{s.name}/Cronet-Interface", version
194 ss.dependency "#{s.name}/Implementation", version
196 ss.dependency 'gRPC-Core/Cronet-Implementation', version
198 ss.source_files = "src/cpp/client/cronet_credentials.cc"
201 s.prepare_command = <<-END_OF_COMMAND
202 find src/core/ third_party/upb/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "upb/(.*)";#if COCOAPODS==1\\\n #include "third_party/upb/upb/\\1"\\\n#else\\\n #include "upb/\\1"\\\n#endif;g'
203 find src/core/ third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm
204 find src/core/ src/cpp/ -type f \\( -name '*.h' -or -name '*.c' -or -name '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(.*).upb.h";#if COCOAPODS==1\\\n #include "src/core/ext/upb-generated/\\1.upb.h"\\\n#else\\\n #include "\\1.upb.h"\\\n#endif;g'
205 find src/core/ src/cpp/ -type f -name '*.grpc_back' -print0 | xargs -0 rm