Debian Codegraph @

templates/gRPC-C++.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-C++.podspec.template`
5 # instead. This file can be regenerated from the template by running
6 # `tools/buildgen/generate_projects.sh`.
7
8 # gRPC C++ CocoaPods podspec
9 #
10 # Copyright 2017 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 filegroup_maps = {filegroup.name: filegroup for filegroup in filegroups}
26
27 def ruby_multiline_list(files, indent):
28 return (',\n' + indent*' ').join('\'%s\'' % f for f in files)
29
30 def is_absl_lib(target_name):
31 return target_name.startswith("absl/")
32
33 def get_absl_spec_name(label):
34 # e.g. absl/apple:banana -> abseil/apple/banana
35 return "abseil/" + label[5:].replace(":", "/")
36
37 def lib_and_transitive_deps(lib):
38 return list(sorted(set({lib} | set(lib_maps[lib].transitive_deps))))
39
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)]
42
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.
47 absl_specs = set()
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:
51 if is_absl_lib(dep):
52 absl_specs.add(get_absl_spec_name(dep))
53 return list(sorted(absl_specs))
54
55 def list_lib_files(lib, fields):
56 files = set()
57 for lib_name in non_abseil_lib_and_transitive_deps(lib):
58 lib = lib_maps[lib_name]
59 for field in fields:
60 files.update(lib.get(field, []))
61 return list(sorted(files))
62
63 def filter_grpcpp(files):
64 return sorted([file for file in files if not file.startswith("include/grpc++")])
65
66 # ObjectiveC doesn't use c-ares so we don't need address_sorting files at all
67 address_sorting_unwanted_files = list_lib_files("address_sorting", ("public_headers", "headers", "src"))
68
69 # ObjectiveC needs to obtain re2 explicitly unlike other languages; TODO @donnadionne make ObjC more consistent with others
70 grpc_private_files = list(sorted((set(list_lib_files("grpc", ("headers", "src"))) - set(address_sorting_unwanted_files)) | set(list_lib_files("re2", ("headers", "src")))))
71 grpc_public_headers = list(sorted((set(list_lib_files("grpc", ("public_headers",))) - set(address_sorting_unwanted_files)) | set(list_lib_files("re2", ("public_headers",)))))
72 grpc_private_headers = list(sorted((set(list_lib_files("grpc", ("headers",))) - set(address_sorting_unwanted_files)) | set(list_lib_files("re2", ("headers",)))))
73
74 # TODO(jtattermusch): build.yaml no longer has filegroups, so the files here are just hand-listed
75 # This template shouldn't be touching the filegroups anyway, so this is only a bit more fragile.
76 grpcpp_proto_files = ['include/grpcpp/impl/codegen/config_protobuf.h',
77 'include/grpcpp/impl/codegen/proto_buffer_reader.h',
78 'include/grpcpp/impl/codegen/proto_buffer_writer.h',
79 'include/grpcpp/impl/codegen/proto_utils.h']
80
81 grpcpp_private_files = filter_grpcpp(
82 set(list_lib_files("grpc++", ("headers", "src")))
83 - set(grpc_private_files)
84 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
85 - set(grpcpp_proto_files)
86 - set(address_sorting_unwanted_files)
87 )
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)
93 - set(address_sorting_unwanted_files)
94 )
95 grpcpp_public_headers = filter_grpcpp(
96 set(list_lib_files("grpc++", ("public_headers",)))
97 - set(grpc_public_headers)
98 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
99 - set(grpcpp_proto_files)
100 - set(address_sorting_unwanted_files)
101 )
102 grpcpp_abseil_specs = list_abseil_specs("grpc++")
103 %>
104 Pod::Spec.new do |s|
105 s.name = 'gRPC-C++'
106 # TODO (mxyan): use version that match gRPC version when pod is stabilized
107 version = '${settings.version}'
108 s.version = version
109 s.summary = 'gRPC C++ library'
110 s.homepage = 'https://grpc.io'
111 s.license = 'Apache License, Version 2.0'
112 s.authors = { 'The gRPC contributors' => '[email protected]' }
113
114 s.source = {
115 :git => 'https://github.com/grpc/grpc.git',
116 :tag => "v#{version}",
117 }
118
119 s.ios.deployment_target = '9.0'
120 s.osx.deployment_target = '10.10'
121 s.tvos.deployment_target = '10.0'
122
123 s.requires_arc = false
124
125 name = 'grpcpp'
126 # Use `grpcpp` as framework name so that `#include <grpcpp/xxx.h>` works when built as
127 # framework.
128 s.module_name = name
129
130 # Add include prefix `grpcpp` so that `#include <grpcpp/xxx.h>` works when built as static
131 # library.
132 s.header_dir = name
133
134 s.pod_target_xcconfig = {
135 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"',
136 'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"'${"\\"}
137 ' "$(PODS_TARGET_SRCROOT)/src/core/ext/upb-generated"'${"\\"}
138 ' "$(PODS_TARGET_SRCROOT)/src/core/ext/upbdefs-generated"'${"\\"}
139 ' "$(PODS_TARGET_SRCROOT)/third_party/**"',
140 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1"',
141 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
142 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
143
144 # If we don't set these two settings, `include/grpc/support/time.h` and
145 # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
146 # build.
147 'USE_HEADERMAP' => 'NO',
148 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
149 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14',
150 }
151
152 s.libraries = 'c++'
153 s.compiler_flags = '-Wno-comma -Wno-unreachable-code -Wno-shorten-64-to-32'
154
155 s.default_subspecs = 'Interface', 'Implementation'
156
157 # Certificates, to be able to establish TLS connections:
158 s.resource_bundles = { 'gRPCCertificates-Cpp' => ['etc/roots.pem'] }
159
160 s.header_mappings_dir = 'include/grpcpp'
161
162 s.subspec 'Interface' do |ss|
163 ss.header_mappings_dir = 'include/grpcpp'
164
165 ss.source_files = ${ruby_multiline_list(grpcpp_public_headers, 22)}
166 end
167
168 s.subspec 'Implementation' do |ss|
169 ss.header_mappings_dir = '.'
170 ss.dependency "#{s.name}/Interface", version
171 ss.dependency 'gRPC-Core', version
172 abseil_version = '1.20220623.0'
173 % for abseil_spec in grpcpp_abseil_specs:
174 ss.dependency '${abseil_spec}', abseil_version
175 % endfor
176
177 ss.source_files = ${ruby_multiline_list(sorted(grpcpp_private_files + grpc_private_headers), 22)}
178
179 ss.private_header_files = ${ruby_multiline_list(sorted(grpcpp_private_headers + grpc_private_headers), 30)}
180 end
181
182 s.subspec 'Protobuf' do |ss|
183 ss.header_mappings_dir = 'include/grpcpp'
184 ss.dependency "#{s.name}/Interface", version
185
186 ss.source_files = ${ruby_multiline_list(grpcpp_proto_files, 22)}
187 end
188
189 s.subspec 'Cronet-Interface' do |ss|
190 ss.header_mappings_dir = 'include/grpcpp'
191 ss.public_header_files = "include/grpcpp/security/cronet_credentials.h",
192 "include/grpcpp/security/cronet_credentials_impl.h"
193 ss.source_files = "include/grpcpp/security/cronet_credentials.h",
194 "include/grpcpp/security/cronet_credentials_impl.h"
195 end
196
197 s.subspec 'Cronet-Implementation' do |ss|
198 ss.header_mappings_dir = '.'
199 ss.dependency "#{s.name}/Cronet-Interface", version
200 ss.dependency "#{s.name}/Implementation", version
201
202 ss.dependency 'gRPC-Core/Cronet-Implementation', version
203
204 ss.source_files = "src/cpp/client/cronet_credentials.cc"
205 end
206
207 # patch include of openssl to openssl_grpc
208 s.prepare_command = <<-END_OF_COMMAND
209 set -e
210 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'
211 find src/core/ -type f -name '*.grpc_back' -print0 | xargs -0 rm
212 END_OF_COMMAND
213 end