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