Debian Codegraph @

templates/gRPC-Core.podspec.template

raw
1 %YAML 1.2
2 --- |
3 # This file has been automatically generated from a template file.
4 # Please make modifications to `templates/gRPC-Core.podspec.template`
5 # instead. This file can be regenerated from the template by running
6 # `tools/buildgen/generate_projects.sh`.
7
8 # gRPC Core CocoaPods podspec
9 #
10 # Copyright 2015 gRPC authors.
11 #
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
15 #
16 # http://www.apache.org/licenses/LICENSE-2.0
17 #
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.
23 <%
24 lib_maps = {lib.name: lib for lib in libs}
25
26 def ruby_multiline_list(files, indent):
27 return (',\n' + indent*' ').join('\'%s\'' % f for f in files)
28
29 def is_absl_lib(target_name):
30 return target_name.startswith("absl/")
31
32 def get_absl_spec_name(label):
33 # e.g. absl/apple:banana -> abseil/apple/banana
34 return "abseil/" + label[5:].replace(":", "/")
35
36 def lib_and_transitive_deps(lib):
37 return list(sorted(set({lib} | set(lib_maps[lib].transitive_deps))))
38
39 def non_abseil_lib_and_transitive_deps(lib):
40 return [l for l in lib_and_transitive_deps(lib) if not is_absl_lib(l)]
41
42 def list_abseil_specs(lib):
43 # This returns a list of abseil specs which the given lib and
44 # its non-abseil transitive dependencies depend on.
45 # As a result, internal abseil libraries are excluded from the result.
46 absl_specs = set()
47 for lib_name in lib_and_transitive_deps(lib):
48 if is_absl_lib(lib_name): continue
49 for dep in lib_maps[lib_name].deps:
50 if is_absl_lib(dep):
51 absl_specs.add(get_absl_spec_name(dep))
52 return list(sorted(absl_specs))
53
54 def list_lib_files(lib, fields):
55 files = set()
56 for lib_name in non_abseil_lib_and_transitive_deps(lib):
57 lib = lib_maps[lib_name]
58 for field in fields:
59 files.update(lib.get(field, []))
60 return list(sorted(files))
61
62 # ObjectiveC doesn't use c-ares so we don't need address_sorting files at all
63 address_sorting_unwanted_files = list_lib_files("address_sorting", ("public_headers", "headers", "src"))
64
65 # ObjectiveC needs to obtain re2 explicitly unlike other languages; TODO @donnadionne make ObjC more consistent with others
66 grpc_private_files = list(
67 sorted((set(list_lib_files("grpc", ("headers", "src"))) -
68 set(address_sorting_unwanted_files))
69 | set(list_lib_files("re2", ("headers", "src")))))
70 grpc_public_headers = list(
71 sorted((set(list_lib_files("grpc", ("public_headers", ))) -
72 set(address_sorting_unwanted_files))
73 | set(list_lib_files("re2", ("public_headers", )))))
74 grpc_private_headers = list(
75 sorted((set(list_lib_files("grpc", ("headers", ))) -
76 set(address_sorting_unwanted_files))
77 | set(list_lib_files("re2", ("headers", )))))
78 grpc_abseil_specs = list_abseil_specs("grpc")
79 grpc_tests_abseil_specs = list(sorted(set(list_abseil_specs("end2end_tests")) - set(grpc_abseil_specs)))
80
81 # TODO(jtattermusch): build.yaml is now generated from bazel build
82 # which doesn't have an explicit "grpc_cronet" target. Until it exists
83 # we construct the list of files by taking what's in the "grpc" target
84 # and adding a few files on top of that.
85 grpc_cronet_extra_public_headers = ['include/grpc/grpc_cronet.h']
86 grpc_cronet_extra_impl_files = [
87 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc',
88 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.h',
89 'src/core/ext/transport/cronet/transport/cronet_status.cc',
90 'src/core/ext/transport/cronet/transport/cronet_status.h',
91 'src/core/ext/transport/cronet/transport/cronet_transport.cc',
92 'src/core/ext/transport/cronet/transport/cronet_transport.h',
93 'third_party/objective_c/Cronet/bidirectional_stream_c.h'
94 ]
95
96 grpc_cronet_files = list(sorted(grpc_cronet_extra_impl_files))
97 grpc_cronet_public_headers = list(sorted(grpc_cronet_extra_public_headers))
98
99 grpc_test_util_files = list(sorted(
100 set(list_lib_files("end2end_tests", ("src", "headers")))
101 - set(grpc_private_files)
102 - set(address_sorting_unwanted_files)
103 - set([
104 # Subprocess is not supported in tvOS and not needed by our tests.
105 "test/core/util/subprocess_posix.cc",
106 ])))
107 %>
108 Pod::Spec.new do |s|
109 s.name = 'gRPC-Core'
110 version = '${settings.version}'
111 s.version = version
112 s.summary = 'Core cross-platform gRPC library, written in C'
113 s.homepage = 'https://grpc.io'
114 s.license = 'Apache License, Version 2.0'
115 s.authors = { 'The gRPC contributors' => '[email protected]' }
116
117 s.source = {
118 :git => 'https://github.com/grpc/grpc.git',
119 :tag => "v#{version}",
120 :submodules => true,
121 }
122
123 # gRPC podspecs depend on fix for https://github.com/CocoaPods/CocoaPods/issues/6024,
124 # which was released in Cocoapods v1.2.0.
125 s.cocoapods_version = '>= 1.2.0'
126
127 s.ios.deployment_target = '9.0'
128 s.osx.deployment_target = '10.10'
129 s.tvos.deployment_target = '10.0'
130 s.watchos.deployment_target = '4.0'
131
132 s.requires_arc = false
133
134 name = 'grpc'
135 abseil_version = '1.20220623.0'
136
137 # When creating a dynamic framework, name it grpc.framework instead of gRPC-Core.framework.
138 # This lets users write their includes like `#include <grpc/grpc.h>` as opposed to `#include
139 # <gRPC-Core/grpc.h>`.
140 s.module_name = name
141
142 # When creating a dynamic framework, copy the headers under `include/grpc/` into the root of
143 # the `Headers/` directory of the framework (i.e., not under `Headers/include/grpc`).
144 #
145 # TODO(jcanizales): Debug why this doesn't work on macOS.
146 s.header_mappings_dir = 'include/grpc'
147
148 # The above has an undesired effect when creating a static library: It forces users to write
149 # includes like `#include <gRPC-Core/grpc.h>`. `s.header_dir` adds a path prefix to that, and
150 # because Cocoapods lets omit the pod name when including headers of static libraries, the
151 # following lets users write `#include <grpc/grpc.h>`.
152 s.header_dir = name
153
154 # The module map created automatically by Cocoapods doesn't work for C libraries like gRPC-Core.
155 s.module_map = 'include/grpc/module.modulemap'
156
157 # To compile the library, we need the user headers search path (quoted includes) to point to the
158 # root of the repo, third_party/** and two upb generated directories, and the system headers
159 # search path (angled includes) to point to `include/`.
160 s.pod_target_xcconfig = {
161 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"',
162 'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"'${"\\"}
163 ' "$(PODS_TARGET_SRCROOT)/src/core/ext/upb-generated"'${"\\"}
164 ' "$(PODS_TARGET_SRCROOT)/src/core/ext/upbdefs-generated"'${"\\"}
165 ' "$(PODS_TARGET_SRCROOT)/third_party/**"',
166 # If we don't set these two settings, `include/grpc/support/time.h` and
167 # `src/core/lib/gpr/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
168 # build.
169 'USE_HEADERMAP' => 'NO',
170 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
171 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1"',
172 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
173 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14',
174 }
175
176 s.default_subspecs = 'Interface', 'Implementation'
177 s.compiler_flags = '-DGRPC_ARES=0 -Wno-comma'
178 s.libraries = 'c++'
179
180 # Like many other C libraries, gRPC-Core has its public headers under `include/<libname>/` and its
181 # sources and private headers in other directories outside `include/`. Cocoapods' linter doesn't
182 # allow any header to be listed outside the `header_mappings_dir` (even though doing so works in
183 # practice). Because we need our `header_mappings_dir` to be `include/grpc/` for the reason
184 # mentioned above, we work around the linter limitation by dividing the pod into two subspecs, one
185 # for public headers and the other for implementation. Each gets its own `header_mappings_dir`,
186 # making the linter happy.
187 #
188 # The list of source files is generated by a template: `templates/gRPC-Core.podspec.template`. It
189 # can be regenerated from the template by running `tools/buildgen/generate_projects.sh`.
190 s.subspec 'Interface' do |ss|
191 ss.header_mappings_dir = 'include/grpc'
192
193 ss.source_files = ${ruby_multiline_list(grpc_public_headers, 22)}
194 end
195 s.subspec 'Implementation' do |ss|
196 ss.header_mappings_dir = '.'
197 ss.libraries = 'z'
198 ss.dependency "#{s.name}/Interface", version
199 ss.dependency 'BoringSSL-GRPC', '0.0.24'
200 % for abseil_spec in grpc_abseil_specs:
201 ss.dependency '${abseil_spec}', abseil_version
202 % endfor
203 ss.compiler_flags = '-DBORINGSSL_PREFIX=GRPC -Wno-unreachable-code -Wno-shorten-64-to-32'
204
205 ss.source_files = ${ruby_multiline_list(grpc_private_files, 22)}
206 ss.private_header_files = ${ruby_multiline_list(grpc_private_headers, 30)}
207 end
208
209 # CFStream is now default. Leaving this subspec only for compatibility purpose.
210 s.subspec 'CFStream-Implementation' do |ss|
211 ss.dependency "#{s.name}/Implementation", version
212 end
213
214 s.subspec 'Cronet-Interface' do |ss|
215 ss.header_mappings_dir = 'include/grpc'
216 ss.source_files = ${ruby_multiline_list(grpc_cronet_public_headers, 22)}
217 end
218
219 s.subspec 'Cronet-Implementation' do |ss|
220 ss.header_mappings_dir = '.'
221
222 ss.dependency "#{s.name}/Interface", version
223 ss.dependency "#{s.name}/Implementation", version
224 ss.dependency "#{s.name}/Cronet-Interface", version
225
226 ss.source_files = ${ruby_multiline_list(grpc_cronet_files, 22)}
227 end
228
229 s.subspec 'Tests' do |ss|
230 ss.header_mappings_dir = '.'
231
232 ss.dependency "#{s.name}/Interface", version
233 ss.dependency "#{s.name}/Implementation", version
234 % for abseil_spec in grpc_tests_abseil_specs:
235 ss.dependency '${abseil_spec}', abseil_version
236 % endfor
237
238 ss.source_files = ${ruby_multiline_list(grpc_test_util_files, 22)}
239 end
240
241 # patch include of openssl to openssl_grpc
242 s.prepare_command = <<-END_OF_COMMAND
243 set -e
244 find src/core -type f \\( -path '*.h' -or -path '*.cc' \\) -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include <openssl/(.*)>;#if COCOAPODS==1\\\n #include <openssl_grpc/\\1>\\\n#else\\\n #include <openssl/\\1>\\\n#endif;g'
245 find src/core/ -type f -name '*.grpc_back' -print0 | xargs -0 rm
246 END_OF_COMMAND
247 end