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 names of lib itself and all of its transitive dependencies.""" 39 transitive_deps = [] 40 lib_metadata = lib_maps.get(lib, None) 41 if lib_metadata: 42 transitive_deps = lib_metadata.transitive_deps 43 return list(sorted(set({lib} | set(transitive_deps)))) 44 45 def non_abseil_lib_and_transitive_deps(lib): 46 return [l for l in lib_and_transitive_deps(lib) if not is_absl_lib(l)] 47 48 def list_abseil_specs(lib): 49 # This returns a list of abseil specs which the given lib and 50 # its non-abseil transitive dependencies depend on. 51 # As a result, internal abseil libraries are excluded from the result. 52 absl_specs = set() 53 for lib_name in lib_and_transitive_deps(lib): 54 if is_absl_lib(lib_name): continue 55 lib_metadata = lib_maps.get(lib_name, None) 56 if lib_metadata: 57 for dep in lib_metadata.deps: 58 if is_absl_lib(dep): 59 absl_specs.add(get_absl_spec_name(dep)) 60 return list(sorted(absl_specs)) 61 62 def collect_files_for_libs(libs, fields): 63 files = set() 64 for lib_name in libs: 65 lib = lib_maps.get(lib_name, None) 66 if lib: 67 for field in fields: 68 files.update(lib.get(field, [])) 69 return list(sorted(files)) 70 71 def filter_grpcpp(files): 72 return sorted([file for file in files if not file.startswith("include/grpc++")]) 73 74 # ObjectiveC doesn't use c-ares so we don't need address_sorting and cares files at all. 75 # absl deps will be declared explicitly so we also don't need to include them. 76 grpc_full_deps = set(non_abseil_lib_and_transitive_deps("grpc")) - set({"address_sorting", "cares"}) 77 grpc_private_headers = collect_files_for_libs(grpc_full_deps, ("headers", )) 78 79 # grpc++ dependencies minus grpc and the libraries grpc itself depends on. 80 grpcpp_full_deps = set(non_abseil_lib_and_transitive_deps("grpc++")) - set(lib_and_transitive_deps("grpc")) 81 82 # TODO(jtattermusch): build.yaml no longer has filegroups, so the files here are just hand-listed 83 # This template shouldn't be touching the filegroups anyway, so this is only a bit more fragile. 84 grpcpp_proto_files = ['include/grpcpp/impl/codegen/config_protobuf.h', 85 'include/grpcpp/impl/codegen/proto_buffer_reader.h', 86 'include/grpcpp/impl/codegen/proto_buffer_writer.h', 87 'include/grpcpp/impl/codegen/proto_utils.h'] 88 89 grpcpp_private_files = filter_grpcpp( 90 set(collect_files_for_libs(grpcpp_full_deps, ("headers", "src"))) 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 ) 94 grpcpp_private_headers = filter_grpcpp( 95 set(collect_files_for_libs(grpcpp_full_deps, ("headers", ))) 96 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib 97 - set(grpcpp_proto_files) 98 ) 99 grpcpp_public_headers = filter_grpcpp( 100 set(collect_files_for_libs(grpcpp_full_deps, ("public_headers", ))) 101 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib 102 - set(grpcpp_proto_files) 103 ) 104 grpcpp_abseil_specs = list_abseil_specs("grpc++") 105 %> 106 Pod::Spec.new do |s| 107 s.name = 'gRPC-C++' 108 # TODO (mxyan): use version that match gRPC version when pod is stabilized 109 version = '${settings.version}' 110 s.version = version 111 s.summary = 'gRPC C++ library' 112 s.homepage = 'https://grpc.io' 113 s.license = 'Apache License, Version 2.0' 114 s.authors = { 'The gRPC contributors' => '[email protected]' } 115 116 s.source = { 117 :git => 'https://github.com/grpc/grpc.git', 118 :tag => "v#{version}", 119 } 120 121 s.ios.deployment_target = '10.0' 122 s.osx.deployment_target = '10.12' 123 s.tvos.deployment_target = '12.0' 124 s.watchos.deployment_target = '6.0' 125 126 s.requires_arc = false 127 128 name = 'grpcpp' 129 # Use `grpcpp` as framework name so that `#include <grpcpp/xxx.h>` works when built as 130 # framework. 131 s.module_name = name 132 133 # Add include prefix `grpcpp` so that `#include <grpcpp/xxx.h>` works when built as static 134 # library. 135 s.header_dir = name 136 137 s.pod_target_xcconfig = { 138 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"', 139 'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"'${"\\"} 140 ' "$(PODS_TARGET_SRCROOT)/src/core/ext/upb-gen"'${"\\"} 141 ' "$(PODS_TARGET_SRCROOT)/src/core/ext/upbdefs-gen"'${"\\"} 142 ' "$(PODS_TARGET_SRCROOT)/third_party/re2"'${"\\"} 143 ' "$(PODS_TARGET_SRCROOT)/third_party/upb"'${"\\"} 144 ' "$(PODS_TARGET_SRCROOT)/third_party/xxhash"', 145 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1"', 146 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', 147 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO', 148 149 # If we don't set these two settings, `include/grpc/support/time.h` and 150 # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the 151 # build. 152 'USE_HEADERMAP' => 'NO', 153 'ALWAYS_SEARCH_USER_PATHS' => 'NO', 154 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14', 155 } 156 157 s.libraries = 'c++' 158 s.compiler_flags = '-Wno-comma -Wno-unreachable-code -Wno-shorten-64-to-32' 159 160 s.default_subspecs = 'Interface', 'Implementation' 161 162 # Certificates, to be able to establish TLS connections: 163 s.resource_bundles = { 'gRPCCertificates-Cpp' => ['etc/roots.pem'] } 164 165 s.header_mappings_dir = 'include/grpcpp' 166 167 # Exposes the privacy manifest. Depended on by any subspecs containing 168 # non-interface files. 169 s.subspec 'Privacy' do |ss| 170 ss.resource_bundles = { 171 s.module_name => 'src/objective-c/PrivacyInfo.xcprivacy' 172 } 173 end 174 175 s.subspec 'Interface' do |ss| 176 ss.header_mappings_dir = 'include/grpcpp' 177 178 ss.source_files = ${ruby_multiline_list(grpcpp_public_headers, 22)} 179 end 180 181 s.subspec 'Implementation' do |ss| 182 ss.header_mappings_dir = '.' 183 ss.dependency "#{s.name}/Privacy", version 184 ss.dependency "#{s.name}/Interface", version 185 ss.dependency 'gRPC-Core', version 186 abseil_version = '1.20240116.1' 187 % for abseil_spec in grpcpp_abseil_specs: 188 ss.dependency '${abseil_spec}', abseil_version 189 % endfor 190 191 ss.source_files = ${ruby_multiline_list(sorted(grpcpp_private_files + grpc_private_headers), 22)} 192 193 ss.private_header_files = ${ruby_multiline_list(sorted(grpcpp_private_headers + grpc_private_headers), 30)} 194 end 195 196 s.subspec 'Protobuf' do |ss| 197 ss.header_mappings_dir = 'include/grpcpp' 198 ss.dependency "#{s.name}/Interface", version 199 200 ss.source_files = ${ruby_multiline_list(grpcpp_proto_files, 22)} 201 end 202 203 s.subspec 'Cronet-Interface' do |ss| 204 ss.header_mappings_dir = 'include/grpcpp' 205 ss.public_header_files = "include/grpcpp/security/cronet_credentials.h", 206 "include/grpcpp/security/cronet_credentials_impl.h" 207 ss.source_files = "include/grpcpp/security/cronet_credentials.h", 208 "include/grpcpp/security/cronet_credentials_impl.h" 209 end 210 211 s.subspec 'Cronet-Implementation' do |ss| 212 ss.header_mappings_dir = '.' 213 ss.dependency "#{s.name}/Cronet-Interface", version 214 ss.dependency "#{s.name}/Implementation", version 215 ss.dependency "#{s.name}/Privacy", version 216 217 ss.dependency 'gRPC-Core/Cronet-Implementation', version 218 219 ss.source_files = "src/cpp/client/cronet_credentials.cc" 220 end 221 222 # patch include of openssl to openssl_grpc 223 s.prepare_command = <<-END_OF_COMMAND 224 set -e 225 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' 226 find src/core/ -type f -name '*.grpc_back' -print0 | xargs -0 rm 227 END_OF_COMMAND 228 end 229