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' => 'grpc-packages@google.com' } 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 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1"', 138 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', 139 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO', 140 141 # If we don't set these two settings, `include/grpc/support/time.h` and 142 # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the 143 # build. 144 'USE_HEADERMAP' => 'NO', 145 'ALWAYS_SEARCH_USER_PATHS' => 'NO', 146 } 147 148 s.libraries = 'c++' 149 s.compiler_flags = '-Wno-comma -Wno-unreachable-code -Wno-shorten-64-to-32' 150 151 s.default_subspecs = 'Interface', 'Implementation' 152 153 # Certificates, to be able to establish TLS connections: 154 s.resource_bundles = { 'gRPCCertificates-Cpp' => ['etc/roots.pem'] } 155 156 s.header_mappings_dir = 'include/grpcpp' 157 158 s.subspec 'Interface' do |ss| 159 ss.header_mappings_dir = 'include/grpcpp' 160 161 ss.source_files = ${ruby_multiline_list(grpcpp_public_headers, 22)} 162 end 163 164 s.subspec 'Implementation' do |ss| 165 ss.header_mappings_dir = '.' 166 ss.dependency "#{s.name}/Interface", version 167 ss.dependency 'gRPC-Core', version 168 abseil_version = '1.20200923.3' 169 % for abseil_spec in grpcpp_abseil_specs: 170 ss.dependency '${abseil_spec}', abseil_version 171 % endfor 172 173 ss.source_files = ${ruby_multiline_list(sorted(grpcpp_private_files + grpc_private_headers), 22)} 174 175 ss.private_header_files = ${ruby_multiline_list(sorted(grpcpp_private_headers + grpc_private_headers), 30)} 176 end 177 178 s.subspec 'Protobuf' do |ss| 179 ss.header_mappings_dir = 'include/grpcpp' 180 ss.dependency "#{s.name}/Interface", version 181 182 ss.source_files = ${ruby_multiline_list(grpcpp_proto_files, 22)} 183 end 184 185 s.subspec 'Cronet-Interface' do |ss| 186 ss.header_mappings_dir = 'include/grpcpp' 187 ss.public_header_files = "include/grpcpp/security/cronet_credentials.h", 188 "include/grpcpp/security/cronet_credentials_impl.h" 189 ss.source_files = "include/grpcpp/security/cronet_credentials.h", 190 "include/grpcpp/security/cronet_credentials_impl.h" 191 end 192 193 s.subspec 'Cronet-Implementation' do |ss| 194 ss.header_mappings_dir = '.' 195 ss.dependency "#{s.name}/Cronet-Interface", version 196 ss.dependency "#{s.name}/Implementation", version 197 198 ss.dependency 'gRPC-Core/Cronet-Implementation', version 199 200 ss.source_files = "src/cpp/client/cronet_credentials.cc" 201 end 202 203 s.prepare_command = <<-END_OF_COMMAND 204 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' 205 find 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 "third_party/(.*)";#if COCOAPODS==1\\\n #include "third_party/upb/third_party/\\1"\\\n#else\\\n #include "third_party/\\1"\\\n#endif;g' 206 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' 207 find src/core/ src/cpp/ third_party/upb/ -type f -name '*.grpc_back' -print0 | xargs -0 rm 208 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' 209 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' 210 find src/core/ src/cpp/ -type f -name '*.grpc_back' -print0 | xargs -0 rm 211 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' 212 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' 213 find src/core/ third_party/re2/ -type f -name '*.grpc_back' -print0 | xargs -0 rm 214 END_OF_COMMAND 215 end 216