Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 1 | %YAML 1.2 |
| 2 | --- | |
| 3 | # GRPC CocoaPods podspec |
Jorge Canizales | 667557f | 2016-06-09 09:15:28 -0700 | [diff] [blame] | 4 | # This file has been automatically generated from a template file. Please make modifications to |
| 5 | # `templates/gRPC-Core.podspec.template` instead. This file can be regenerated from the template by |
| 6 | # running `tools/buildgen/generate_projects.sh`. |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 7 | |
| 8 | # Copyright 2015, Google Inc. |
| 9 | # All rights reserved. |
| 10 | # |
| 11 | # Redistribution and use in source and binary forms, with or without |
| 12 | # modification, are permitted provided that the following conditions are |
| 13 | # met: |
| 14 | # |
| 15 | # * Redistributions of source code must retain the above copyright |
| 16 | # notice, this list of conditions and the following disclaimer. |
| 17 | # * Redistributions in binary form must reproduce the above |
| 18 | # copyright notice, this list of conditions and the following disclaimer |
| 19 | # in the documentation and/or other materials provided with the |
| 20 | # distribution. |
| 21 | # * Neither the name of Google Inc. nor the names of its |
| 22 | # contributors may be used to endorse or promote products derived from |
| 23 | # this software without specific prior written permission. |
| 24 | # |
| 25 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 26 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 27 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 28 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 29 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 30 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 31 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 32 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 33 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 34 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 35 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 36 | |
| 37 | <%! |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 38 | def grpc_private_files(libs): |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 39 | out = [] |
| 40 | for lib in libs: |
| 41 | if lib.name in ("grpc", "gpr"): |
| 42 | out += lib.get('headers', []) |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 43 | out += lib.get('src', []) |
| 44 | return out; |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 45 | |
| 46 | def grpc_public_headers(libs): |
| 47 | out = [] |
| 48 | for lib in libs: |
| 49 | if lib.name in ("grpc", "gpr"): |
| 50 | out += lib.get('public_headers', []) |
| 51 | return out |
| 52 | |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 53 | def grpc_private_headers(libs): |
| 54 | out = [] |
| 55 | for lib in libs: |
| 56 | if lib.name in ("grpc", "gpr"): |
| 57 | out += lib.get('headers', []) |
| 58 | return out |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 59 | |
| 60 | def ruby_multiline_list(files, indent): |
| 61 | return (',\n' + indent*' ').join('\'%s\'' % f for f in files) |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 62 | %> |
| 63 | Pod::Spec.new do |s| |
| 64 | s.name = 'gRPC-Core' |
Muxi Yan | 447d0a2 | 2016-10-25 14:14:12 -0700 | [diff] [blame] | 65 | version = '1.0.1' |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 66 | s.version = version |
| 67 | s.summary = 'Core cross-platform gRPC library, written in C' |
| 68 | s.homepage = 'http://www.grpc.io' |
| 69 | s.license = 'New BSD' |
| 70 | s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } |
| 71 | |
| 72 | s.source = { |
| 73 | :git => 'https://github.com/grpc/grpc.git', |
Jorge Canizales | 4a18c67 | 2016-08-18 13:26:25 -0700 | [diff] [blame] | 74 | :tag => "v#{version}", |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 75 | # TODO(jcanizales): Depend explicitly on the nanopb pod, and disable submodules. |
Jorge Canizales | 66c8ddd | 2016-06-08 17:39:40 -0700 | [diff] [blame] | 76 | :submodules => true, |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | s.ios.deployment_target = '7.1' |
| 80 | s.osx.deployment_target = '10.9' |
| 81 | s.requires_arc = false |
| 82 | |
| 83 | name = 'grpc' |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 84 | |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 85 | # When creating a dynamic framework, name it grpc.framework instead of gRPC-Core.framework. |
| 86 | # This lets users write their includes like `#include <grpc/grpc.h>` as opposed to `#include |
| 87 | # <gRPC-Core/grpc.h>`. |
| 88 | s.module_name = name |
| 89 | |
| 90 | # When creating a dynamic framework, copy the headers under `include/grpc/` into the root of |
| 91 | # the `Headers/` directory of the framework (i.e., not under `Headers/include/grpc`). |
| 92 | # |
| 93 | # TODO(jcanizales): Debug why this doesn't work on macOS. |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 94 | s.header_mappings_dir = 'include/grpc' |
| 95 | |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 96 | # The above has an undesired effect when creating a static library: It forces users to write |
| 97 | # includes like `#include <gRPC-Core/grpc.h>`. `s.header_dir` adds a path prefix to that, and |
| 98 | # because Cocoapods lets omit the pod name when including headers of static libraries, the |
| 99 | # following lets users write `#include <grpc/grpc.h>`. |
| 100 | s.header_dir = name |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 101 | |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 102 | # 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] | 103 | s.module_map = 'include/grpc/module.modulemap' |
| 104 | |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 105 | # To compile the library, we need the user headers search path (quoted includes) to point to the |
| 106 | # root of the repo, and the system headers search path (angled includes) to point to `include/`. |
| 107 | # Cocoapods effectively clones the repo under `<Podfile dir>/Pods/gRPC-Core/`, and sets a build |
| 108 | # variable called `$(PODS_ROOT)` to `<Podfile dir>/Pods/`, so we use that. |
| 109 | # |
| 110 | # Relying on the file structure under $(PODS_ROOT) isn't officially supported in Cocoapods, as it |
| 111 | # is taken as an implementation detail. We've asked for an alternative, and have been told that |
| 112 | # what we're doing should keep working: https://github.com/CocoaPods/CocoaPods/issues/4386 |
| 113 | # |
| 114 | # The `src_root` value of `$(PODS_ROOT)/gRPC-Core` assumes Cocoapods is installing this pod from |
| 115 | # its remote repo. For local development of this library, enabled by using `:path` in the Podfile, |
| 116 | # that assumption is wrong. In such case, the following settings need to be reset with the |
| 117 | # appropriate value of `src_root`. This can be accomplished in the `pre_install` hook of the |
| 118 | # Podfile; see `src/objective-c/tests/Podfile` for an example. |
| 119 | src_root = '$(PODS_ROOT)/gRPC-Core' |
| 120 | s.pod_target_xcconfig = { |
| 121 | 'GRPC_SRC_ROOT' => src_root, |
| 122 | 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"', |
| 123 | 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"', |
| 124 | # If we don't set these two settings, `include/grpc/support/time.h` and |
| 125 | # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the |
| 126 | # build. |
| 127 | 'USE_HEADERMAP' => 'NO', |
| 128 | 'ALWAYS_SEARCH_USER_PATHS' => 'NO', |
| 129 | } |
Jorge Canizales | 3775074 | 2016-06-08 20:10:20 -0700 | [diff] [blame] | 130 | |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 131 | s.default_subspecs = 'Interface', 'Implementation' |
Yuchen Zeng | 9e4c8eb | 2016-11-18 01:06:57 -0800 | [diff] [blame^] | 132 | s.compiler_flags = '-DGRPC_ARES=0' |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 133 | |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 134 | # Like many other C libraries, gRPC-Core has its public headers under `include/<libname>/` and its |
| 135 | # sources and private headers in other directories outside `include/`. Cocoapods' linter doesn't |
| 136 | # allow any header to be listed outside the `header_mappings_dir` (even though doing so works in |
| 137 | # practice). Because we need our `header_mappings_dir` to be `include/grpc/` for the reason |
| 138 | # mentioned above, we work around the linter limitation by dividing the pod into two subspecs, one |
| 139 | # for public headers and the other for implementation. Each gets its own `header_mappings_dir`, |
| 140 | # making the linter happy. |
| 141 | # |
| 142 | # The list of source files is generated by a template: `templates/gRPC-Core.podspec.template`. It |
| 143 | # can be regenerated from the template by running `tools/buildgen/generate_projects.sh`. |
| 144 | s.subspec 'Interface' do |ss| |
| 145 | ss.header_mappings_dir = 'include/grpc' |
| 146 | |
| 147 | ss.source_files = ${ruby_multiline_list(grpc_public_headers(libs), 22)} |
| 148 | end |
| 149 | s.subspec 'Implementation' do |ss| |
| 150 | ss.header_mappings_dir = '.' |
| 151 | ss.libraries = 'z' |
| 152 | ss.dependency "#{s.name}/Interface", version |
Muxi Yan | 6fd881e | 2016-10-21 14:46:01 -0700 | [diff] [blame] | 153 | ss.dependency 'BoringSSL', '~> 7.0' |
Jorge Canizales | cc074d9 | 2016-06-28 09:52:43 -0700 | [diff] [blame] | 154 | |
| 155 | # To save you from scrolling, this is the last part of the podspec. |
| 156 | ss.source_files = ${ruby_multiline_list(grpc_private_files(libs), 22)} |
| 157 | |
| 158 | ss.private_header_files = ${ruby_multiline_list(grpc_private_headers(libs), 30)} |
| 159 | end |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 160 | |
| 161 | s.subspec 'Cronet-Interface' do |ss| |
| 162 | ss.header_mappings_dir = 'include/grpc' |
| 163 | ss.source_files = 'include/grpc/grpc_cronet.h' |
| 164 | end |
| 165 | |
Muxi Yan | f8372c6 | 2016-07-29 09:58:55 -0700 | [diff] [blame] | 166 | s.subspec 'Cronet-Implementation' do |ss| |
Muxi Yan | 2a5072e | 2016-07-27 15:10:22 -0700 | [diff] [blame] | 167 | ss.header_mappings_dir = '.' |
| 168 | ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.c', |
| 169 | 'src/core/ext/transport/cronet/transport/cronet_transport.c' |
| 170 | end |
| 171 | |
Muxi Yan | f8372c6 | 2016-07-29 09:58:55 -0700 | [diff] [blame] | 172 | s.subspec 'Tests' do |ss| |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 173 | ss.header_mappings_dir = '.' |
| 174 | |
Muxi Yan | 2a5072e | 2016-07-27 15:10:22 -0700 | [diff] [blame] | 175 | ss.source_files = 'test/core/end2end/cq_verifier.{c,h}', |
Muxi Yan | 37480eb | 2016-07-14 16:22:03 -0700 | [diff] [blame] | 176 | 'test/core/end2end/end2end_tests.{c,h}', |
| 177 | 'test/core/end2end/tests/*.{c,h}', |
| 178 | 'test/core/end2end/data/*.{c,h}', |
| 179 | 'test/core/util/test_config.{c,h}', |
| 180 | 'test/core/util/port.h', |
| 181 | 'test/core/util/port_posix.c', |
| 182 | 'test/core/util/port_server_client.{c,h}' |
| 183 | |
| 184 | ss.dependency 'CronetFramework' |
| 185 | end |
Jorge Canizales | e487a72 | 2016-04-30 12:05:26 -0700 | [diff] [blame] | 186 | end |