Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 1 | %YAML 1.2 |
| 2 | --- | |
Muxi Yan | 27e9db4 | 2017-01-30 09:21:05 -0800 | [diff] [blame] | 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`. |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 7 | |
Muxi Yan | 27e9db4 | 2017-01-30 09:21:05 -0800 | [diff] [blame] | 8 | # gRPC Core CocoaPods podspec |
| 9 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 10 | # Copyright 2015 gRPC authors. |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 11 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 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 |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 15 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 16 | # http://www.apache.org/licenses/LICENSE-2.0 |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 17 | # |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 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. |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 23 | |
| 24 | <%! |
Muxi Yan | b0f821c | 2017-12-19 15:37:57 -0800 | [diff] [blame] | 25 | def grpc_lib_files(libs, expect_libs, groups): |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 26 | out = [] |
| 27 | for lib in libs: |
Muxi Yan | b0f821c | 2017-12-19 15:37:57 -0800 | [diff] [blame] | 28 | if lib.name in expect_libs: |
| 29 | for group in groups: |
| 30 | out += lib.get(group, []) |
| 31 | return out |
| 32 | |
| 33 | def grpc_private_files(libs): |
| 34 | out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers", "src")) |
| 35 | return [file for file in out if not file.startswith("third_party/nanopb/")] |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 36 | |
| 37 | def grpc_public_headers(libs): |
Muxi Yan | b0f821c | 2017-12-19 15:37:57 -0800 | [diff] [blame] | 38 | out = grpc_lib_files(libs, ("grpc", "gpr"), ("public_headers",)) |
Muxi Yan | cd97297 | 2017-10-06 13:46:27 -0700 | [diff] [blame] | 39 | return out |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 40 | |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 41 | def grpc_private_headers(libs): |
Muxi Yan | b0f821c | 2017-12-19 15:37:57 -0800 | [diff] [blame] | 42 | out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers",)) |
| 43 | return [file for file in out if not file.startswith("third_party/nanopb/")] |
| 44 | |
| 45 | def grpc_cronet_files(libs): |
| 46 | out = grpc_lib_files(libs, ("grpc_cronet",), ("src", "headers")) |
| 47 | excl = grpc_private_files(libs) |
| 48 | excl += [ |
| 49 | # We do not need cronet dedicated plugin registry |
| 50 | "src/core/plugin_registry/grpc_cronet_plugin_registry.cc", |
| 51 | # We do not need dummy cronet API for ObjC |
| 52 | "src/core/ext/transport/cronet/transport/cronet_api_dummy.cc", |
| 53 | ] |
| 54 | return [file for file in out if not file in excl] |
| 55 | |
| 56 | def grpc_cronet_public_headers(libs): |
| 57 | out = grpc_lib_files(libs, ("grpc_cronet",), ("public_headers",)) |
| 58 | excl = grpc_public_headers(libs) |
| 59 | return [file for file in out if not file in excl] |
| 60 | |
| 61 | def grpc_test_util_files(libs): |
| 62 | out = grpc_lib_files(libs, ("grpc_test_util", "gpr_test_util"), ("src", "headers")) |
| 63 | excl = grpc_private_files(libs) |
| 64 | return [file for file in out if not file in excl] |
| 65 | |
| 66 | def end2end_tests_files(libs): |
| 67 | out = grpc_lib_files(libs, ("end2end_tests",), ("src", "headers")) |
| 68 | excl = grpc_private_files(libs) |
| 69 | return [file for file in out if not file in excl] |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 70 | |
| 71 | def ruby_multiline_list(files, indent): |
| 72 | return (',\n' + indent*' ').join('\'%s\'' % f for f in files) |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 73 | %> |
| 74 | Pod::Spec.new do |s| |
| 75 | s.name = 'gRPC-Core' |
Muxi Yan | 690aee6 | 2017-01-27 02:52:47 +0000 | [diff] [blame] | 76 | version = '${settings.version}' |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 77 | s.version = version |
| 78 | s.summary = 'Core cross-platform gRPC library, written in C' |
Mehrdad Afshari | bb3d95b | 2017-07-10 22:24:28 +0000 | [diff] [blame] | 79 | s.homepage = 'https://grpc.io' |
Jan Tattermusch | 4d5c310 | 2017-06-07 10:23:56 +0200 | [diff] [blame] | 80 | s.license = 'Apache License, Version 2.0' |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 81 | s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } |
| 82 | |
| 83 | s.source = { |
| 84 | :git => 'https://github.com/grpc/grpc.git', |
Muxi Yan | 690aee6 | 2017-01-27 02:52:47 +0000 | [diff] [blame] | 85 | :tag => "v#{version}", |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Muxi Yan | 3d2081b | 2017-10-31 10:27:46 -0700 | [diff] [blame] | 88 | # gRPC podspecs depend on fix for https://github.com/CocoaPods/CocoaPods/issues/6024, |
| 89 | # which was released in Cocoapods v1.2.0. |
| 90 | s.cocoapods_version = '>= 1.2.0' |
| 91 | |
Muxi Yan | 37d3fba | 2017-02-28 16:14:40 -0800 | [diff] [blame] | 92 | s.ios.deployment_target = '7.0' |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 93 | s.osx.deployment_target = '10.9' |
| 94 | s.requires_arc = false |
| 95 | |
| 96 | name = 'grpc' |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 97 | |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 98 | # When creating a dynamic framework, name it grpc.framework instead of gRPC-Core.framework. |
| 99 | # This lets users write their includes like `#include <grpc/grpc.h>` as opposed to `#include |
| 100 | # <gRPC-Core/grpc.h>`. |
| 101 | s.module_name = name |
| 102 | |
| 103 | # When creating a dynamic framework, copy the headers under `include/grpc/` into the root of |
| 104 | # the `Headers/` directory of the framework (i.e., not under `Headers/include/grpc`). |
| 105 | # |
| 106 | # TODO(jcanizales): Debug why this doesn't work on macOS. |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 107 | s.header_mappings_dir = 'include/grpc' |
| 108 | |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 109 | # The above has an undesired effect when creating a static library: It forces users to write |
| 110 | # includes like `#include <gRPC-Core/grpc.h>`. `s.header_dir` adds a path prefix to that, and |
| 111 | # because Cocoapods lets omit the pod name when including headers of static libraries, the |
| 112 | # following lets users write `#include <grpc/grpc.h>`. |
| 113 | s.header_dir = name |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 114 | |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 115 | # The module map created automatically by Cocoapods doesn't work for C libraries like gRPC-Core. |
Jorge Canizales | 3775074 | 2016-06-08 20:10:20 -0700 | [diff] [blame] | 116 | s.module_map = 'include/grpc/module.modulemap' |
| 117 | |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 118 | # To compile the library, we need the user headers search path (quoted includes) to point to the |
| 119 | # root of the repo, and the system headers search path (angled includes) to point to `include/`. |
| 120 | # Cocoapods effectively clones the repo under `<Podfile dir>/Pods/gRPC-Core/`, and sets a build |
| 121 | # variable called `$(PODS_ROOT)` to `<Podfile dir>/Pods/`, so we use that. |
| 122 | # |
| 123 | # Relying on the file structure under $(PODS_ROOT) isn't officially supported in Cocoapods, as it |
| 124 | # is taken as an implementation detail. We've asked for an alternative, and have been told that |
| 125 | # what we're doing should keep working: https://github.com/CocoaPods/CocoaPods/issues/4386 |
| 126 | # |
| 127 | # The `src_root` value of `$(PODS_ROOT)/gRPC-Core` assumes Cocoapods is installing this pod from |
| 128 | # its remote repo. For local development of this library, enabled by using `:path` in the Podfile, |
| 129 | # that assumption is wrong. In such case, the following settings need to be reset with the |
| 130 | # appropriate value of `src_root`. This can be accomplished in the `pre_install` hook of the |
| 131 | # Podfile; see `src/objective-c/tests/Podfile` for an example. |
| 132 | src_root = '$(PODS_ROOT)/gRPC-Core' |
| 133 | s.pod_target_xcconfig = { |
| 134 | 'GRPC_SRC_ROOT' => src_root, |
| 135 | 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"', |
| 136 | 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"', |
| 137 | # If we don't set these two settings, `include/grpc/support/time.h` and |
| 138 | # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the |
| 139 | # build. |
| 140 | 'USE_HEADERMAP' => 'NO', |
| 141 | 'ALWAYS_SEARCH_USER_PATHS' => 'NO', |
Muxi Yan | 9ecc215 | 2017-09-29 17:08:59 -0700 | [diff] [blame] | 142 | 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"', |
Muxi Yan | 94d669e | 2017-10-22 14:56:10 -0700 | [diff] [blame] | 143 | 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO', |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 144 | } |
Jorge Canizales | 3775074 | 2016-06-08 20:10:20 -0700 | [diff] [blame] | 145 | |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 146 | s.default_subspecs = 'Interface', 'Implementation' |
Yuchen Zeng | 9e4c8eb | 2016-11-18 01:06:57 -0800 | [diff] [blame] | 147 | s.compiler_flags = '-DGRPC_ARES=0' |
Muxi Yan | ae6bca4 | 2017-10-19 18:14:02 -0700 | [diff] [blame] | 148 | s.libraries = 'c++' |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 149 | |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 150 | # Like many other C libraries, gRPC-Core has its public headers under `include/<libname>/` and its |
| 151 | # sources and private headers in other directories outside `include/`. Cocoapods' linter doesn't |
| 152 | # allow any header to be listed outside the `header_mappings_dir` (even though doing so works in |
| 153 | # practice). Because we need our `header_mappings_dir` to be `include/grpc/` for the reason |
| 154 | # mentioned above, we work around the linter limitation by dividing the pod into two subspecs, one |
| 155 | # for public headers and the other for implementation. Each gets its own `header_mappings_dir`, |
| 156 | # making the linter happy. |
| 157 | # |
| 158 | # The list of source files is generated by a template: `templates/gRPC-Core.podspec.template`. It |
| 159 | # can be regenerated from the template by running `tools/buildgen/generate_projects.sh`. |
| 160 | s.subspec 'Interface' do |ss| |
| 161 | ss.header_mappings_dir = 'include/grpc' |
| 162 | |
| 163 | ss.source_files = ${ruby_multiline_list(grpc_public_headers(libs), 22)} |
| 164 | end |
| 165 | s.subspec 'Implementation' do |ss| |
| 166 | ss.header_mappings_dir = '.' |
| 167 | ss.libraries = 'z' |
| 168 | ss.dependency "#{s.name}/Interface", version |
Muxi Yan | c0d3bab | 2017-07-10 11:21:37 -0700 | [diff] [blame] | 169 | ss.dependency 'BoringSSL', '~> 9.0' |
Muxi Yan | ad272c9 | 2017-06-29 16:18:43 -0700 | [diff] [blame] | 170 | ss.dependency 'nanopb', '~> 0.3' |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 171 | |
| 172 | # To save you from scrolling, this is the last part of the podspec. |
| 173 | ss.source_files = ${ruby_multiline_list(grpc_private_files(libs), 22)} |
| 174 | |
| 175 | ss.private_header_files = ${ruby_multiline_list(grpc_private_headers(libs), 30)} |
| 176 | end |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 177 | |
| 178 | s.subspec 'Cronet-Interface' do |ss| |
| 179 | ss.header_mappings_dir = 'include/grpc' |
Muxi Yan | b0f821c | 2017-12-19 15:37:57 -0800 | [diff] [blame] | 180 | ss.source_files = ${ruby_multiline_list(grpc_cronet_public_headers(libs), 22)} |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 181 | end |
| 182 | |
Muxi Yan | f8372c6 | 2016-07-29 09:58:55 -0700 | [diff] [blame] | 183 | s.subspec 'Cronet-Implementation' do |ss| |
Muxi Yan | 2a5072e | 2016-07-27 15:10:22 -0700 | [diff] [blame] | 184 | ss.header_mappings_dir = '.' |
Muxi Yan | e2de92f | 2017-01-31 16:30:52 -0800 | [diff] [blame] | 185 | |
| 186 | ss.dependency "#{s.name}/Interface", version |
| 187 | ss.dependency "#{s.name}/Implementation", version |
| 188 | ss.dependency "#{s.name}/Cronet-Interface", version |
| 189 | |
Muxi Yan | b0f821c | 2017-12-19 15:37:57 -0800 | [diff] [blame] | 190 | ss.source_files = ${ruby_multiline_list(grpc_cronet_files(libs), 22)} |
Muxi Yan | 2a5072e | 2016-07-27 15:10:22 -0700 | [diff] [blame] | 191 | end |
| 192 | |
Muxi Yan | f8372c6 | 2016-07-29 09:58:55 -0700 | [diff] [blame] | 193 | s.subspec 'Tests' do |ss| |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 194 | ss.header_mappings_dir = '.' |
| 195 | |
Muxi Yan | e2de92f | 2017-01-31 16:30:52 -0800 | [diff] [blame] | 196 | ss.dependency "#{s.name}/Interface", version |
| 197 | ss.dependency "#{s.name}/Implementation", version |
| 198 | |
Muxi Yan | b0f821c | 2017-12-19 15:37:57 -0800 | [diff] [blame] | 199 | ss.source_files = ${ruby_multiline_list(grpc_test_util_files(libs), 22)}, |
| 200 | ${ruby_multiline_list(end2end_tests_files(libs), 22)} |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 201 | end |
Muxi Yan | 43c4710 | 2017-07-06 20:51:49 -0700 | [diff] [blame] | 202 | |
| 203 | # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path? |
| 204 | s.prepare_command = <<-END_OF_COMMAND |
Muxi Yan | f3c83bf | 2018-01-16 10:55:00 -0800 | [diff] [blame^] | 205 | find src/core/ -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\; |
Muxi Yan | 43c4710 | 2017-07-06 20:51:49 -0700 | [diff] [blame] | 206 | END_OF_COMMAND |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 207 | end |