blob: f3ac30c08d31c3ebdc55ebee2c032b7660dcba24 [file] [log] [blame]
Jorge Canizalese487a722016-04-30 12:05:26 -07001%YAML 1.2
2--- |
Muxi Yan27e9db42017-01-30 09:21:05 -08003 # 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 Canizalese487a722016-04-30 12:05:26 -07007
Muxi Yan27e9db42017-01-30 09:21:05 -08008 # gRPC Core CocoaPods podspec
9 #
Jan Tattermusch4d5c3102017-06-07 10:23:56 +020010 # Copyright 2015 gRPC authors.
Jorge Canizalese487a722016-04-30 12:05:26 -070011 #
Jan Tattermusch4d5c3102017-06-07 10:23:56 +020012 # 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 Canizalese487a722016-04-30 12:05:26 -070015 #
Jan Tattermusch4d5c3102017-06-07 10:23:56 +020016 # http://www.apache.org/licenses/LICENSE-2.0
Jorge Canizalese487a722016-04-30 12:05:26 -070017 #
Jan Tattermusch4d5c3102017-06-07 10:23:56 +020018 # 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 Canizalese487a722016-04-30 12:05:26 -070023
24 <%!
Jorge Canizalescc074d92016-06-28 09:52:43 -070025 def grpc_private_files(libs):
Jorge Canizalese487a722016-04-30 12:05:26 -070026 out = []
27 for lib in libs:
28 if lib.name in ("grpc", "gpr"):
29 out += lib.get('headers', [])
Jorge Canizalese487a722016-04-30 12:05:26 -070030 out += lib.get('src', [])
Muxi Yand89b9e32017-06-29 14:31:59 -070031 return [f for f in out if not f.startswith("third_party/nanopb/")]
Jorge Canizalescc074d92016-06-28 09:52:43 -070032
33 def grpc_public_headers(libs):
Muxi Yan89cf5a42017-10-02 13:19:56 -070034 excluded_files = ["include/grpc/support/atm_gcc_sync.h",
35 "include/grpc/support/atm_windows.h",
36 "include/grpc/support/sync_windows.h",
37 "include/grpc/support/tls_gcc.h",
38 "include/grpc/support/tls_msvc.h",
39 "include/grpc/impl/codegen/atm_gcc_sync.h",
40 "include/grpc/impl/codegen/atm_windows.h",
41 "include/grpc/impl/codegen/sync_windows.h"]
Jorge Canizalescc074d92016-06-28 09:52:43 -070042 out = []
43 for lib in libs:
44 if lib.name in ("grpc", "gpr"):
45 out += lib.get('public_headers', [])
Muxi Yan89cf5a42017-10-02 13:19:56 -070046 return [f for f in out if not f in excluded_files]
Jorge Canizalescc074d92016-06-28 09:52:43 -070047
Jorge Canizalese487a722016-04-30 12:05:26 -070048 def grpc_private_headers(libs):
49 out = []
50 for lib in libs:
51 if lib.name in ("grpc", "gpr"):
52 out += lib.get('headers', [])
Muxi Yand89b9e32017-06-29 14:31:59 -070053 return [f for f in out if not f.startswith("third_party/nanopb/")]
Jorge Canizalescc074d92016-06-28 09:52:43 -070054
55 def ruby_multiline_list(files, indent):
56 return (',\n' + indent*' ').join('\'%s\'' % f for f in files)
Jorge Canizalese487a722016-04-30 12:05:26 -070057 %>
58 Pod::Spec.new do |s|
59 s.name = 'gRPC-Core'
Muxi Yan690aee62017-01-27 02:52:47 +000060 version = '${settings.version}'
Jorge Canizalese487a722016-04-30 12:05:26 -070061 s.version = version
62 s.summary = 'Core cross-platform gRPC library, written in C'
Mehrdad Afsharibb3d95b2017-07-10 22:24:28 +000063 s.homepage = 'https://grpc.io'
Jan Tattermusch4d5c3102017-06-07 10:23:56 +020064 s.license = 'Apache License, Version 2.0'
Jorge Canizalese487a722016-04-30 12:05:26 -070065 s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
66
67 s.source = {
68 :git => 'https://github.com/grpc/grpc.git',
Muxi Yan690aee62017-01-27 02:52:47 +000069 :tag => "v#{version}",
Jorge Canizalese487a722016-04-30 12:05:26 -070070 }
71
Muxi Yan37d3fba2017-02-28 16:14:40 -080072 s.ios.deployment_target = '7.0'
Jorge Canizalese487a722016-04-30 12:05:26 -070073 s.osx.deployment_target = '10.9'
74 s.requires_arc = false
75
76 name = 'grpc'
Jorge Canizalese487a722016-04-30 12:05:26 -070077
Jorge Canizalescc074d92016-06-28 09:52:43 -070078 # When creating a dynamic framework, name it grpc.framework instead of gRPC-Core.framework.
79 # This lets users write their includes like `#include <grpc/grpc.h>` as opposed to `#include
80 # <gRPC-Core/grpc.h>`.
81 s.module_name = name
82
83 # When creating a dynamic framework, copy the headers under `include/grpc/` into the root of
84 # the `Headers/` directory of the framework (i.e., not under `Headers/include/grpc`).
85 #
86 # TODO(jcanizales): Debug why this doesn't work on macOS.
Jorge Canizalese487a722016-04-30 12:05:26 -070087 s.header_mappings_dir = 'include/grpc'
88
Jorge Canizalescc074d92016-06-28 09:52:43 -070089 # The above has an undesired effect when creating a static library: It forces users to write
90 # includes like `#include <gRPC-Core/grpc.h>`. `s.header_dir` adds a path prefix to that, and
91 # because Cocoapods lets omit the pod name when including headers of static libraries, the
92 # following lets users write `#include <grpc/grpc.h>`.
93 s.header_dir = name
Jorge Canizalese487a722016-04-30 12:05:26 -070094
Jorge Canizalescc074d92016-06-28 09:52:43 -070095 # The module map created automatically by Cocoapods doesn't work for C libraries like gRPC-Core.
Jorge Canizales37750742016-06-08 20:10:20 -070096 s.module_map = 'include/grpc/module.modulemap'
97
Jorge Canizalescc074d92016-06-28 09:52:43 -070098 # To compile the library, we need the user headers search path (quoted includes) to point to the
99 # root of the repo, and the system headers search path (angled includes) to point to `include/`.
100 # Cocoapods effectively clones the repo under `<Podfile dir>/Pods/gRPC-Core/`, and sets a build
101 # variable called `$(PODS_ROOT)` to `<Podfile dir>/Pods/`, so we use that.
102 #
103 # Relying on the file structure under $(PODS_ROOT) isn't officially supported in Cocoapods, as it
104 # is taken as an implementation detail. We've asked for an alternative, and have been told that
105 # what we're doing should keep working: https://github.com/CocoaPods/CocoaPods/issues/4386
106 #
107 # The `src_root` value of `$(PODS_ROOT)/gRPC-Core` assumes Cocoapods is installing this pod from
108 # its remote repo. For local development of this library, enabled by using `:path` in the Podfile,
109 # that assumption is wrong. In such case, the following settings need to be reset with the
110 # appropriate value of `src_root`. This can be accomplished in the `pre_install` hook of the
111 # Podfile; see `src/objective-c/tests/Podfile` for an example.
112 src_root = '$(PODS_ROOT)/gRPC-Core'
113 s.pod_target_xcconfig = {
114 'GRPC_SRC_ROOT' => src_root,
115 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(GRPC_SRC_ROOT)/include"',
116 'USER_HEADER_SEARCH_PATHS' => '"$(GRPC_SRC_ROOT)"',
117 # If we don't set these two settings, `include/grpc/support/time.h` and
118 # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
119 # build.
120 'USE_HEADERMAP' => 'NO',
121 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
Muxi Yan9ecc2152017-09-29 17:08:59 -0700122 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"',
Jorge Canizalescc074d92016-06-28 09:52:43 -0700123 }
Jorge Canizales37750742016-06-08 20:10:20 -0700124
Muxi Yan37480eb2016-07-14 16:22:03 -0700125 s.default_subspecs = 'Interface', 'Implementation'
Yuchen Zeng9e4c8eb2016-11-18 01:06:57 -0800126 s.compiler_flags = '-DGRPC_ARES=0'
Muxi Yan37480eb2016-07-14 16:22:03 -0700127
Jorge Canizalescc074d92016-06-28 09:52:43 -0700128 # Like many other C libraries, gRPC-Core has its public headers under `include/<libname>/` and its
129 # sources and private headers in other directories outside `include/`. Cocoapods' linter doesn't
130 # allow any header to be listed outside the `header_mappings_dir` (even though doing so works in
131 # practice). Because we need our `header_mappings_dir` to be `include/grpc/` for the reason
132 # mentioned above, we work around the linter limitation by dividing the pod into two subspecs, one
133 # for public headers and the other for implementation. Each gets its own `header_mappings_dir`,
134 # making the linter happy.
135 #
136 # The list of source files is generated by a template: `templates/gRPC-Core.podspec.template`. It
137 # can be regenerated from the template by running `tools/buildgen/generate_projects.sh`.
138 s.subspec 'Interface' do |ss|
139 ss.header_mappings_dir = 'include/grpc'
140
141 ss.source_files = ${ruby_multiline_list(grpc_public_headers(libs), 22)}
142 end
143 s.subspec 'Implementation' do |ss|
144 ss.header_mappings_dir = '.'
145 ss.libraries = 'z'
146 ss.dependency "#{s.name}/Interface", version
Muxi Yanc0d3bab2017-07-10 11:21:37 -0700147 ss.dependency 'BoringSSL', '~> 9.0'
Muxi Yanad272c92017-06-29 16:18:43 -0700148 ss.dependency 'nanopb', '~> 0.3'
Jorge Canizalescc074d92016-06-28 09:52:43 -0700149
150 # To save you from scrolling, this is the last part of the podspec.
151 ss.source_files = ${ruby_multiline_list(grpc_private_files(libs), 22)}
152
153 ss.private_header_files = ${ruby_multiline_list(grpc_private_headers(libs), 30)}
154 end
Muxi Yan37480eb2016-07-14 16:22:03 -0700155
156 s.subspec 'Cronet-Interface' do |ss|
157 ss.header_mappings_dir = 'include/grpc'
Muxi Yane38b0122017-03-16 20:53:41 -0700158 ss.source_files = 'include/grpc/grpc_cronet.h'
Muxi Yan37480eb2016-07-14 16:22:03 -0700159 end
160
Muxi Yanf8372c62016-07-29 09:58:55 -0700161 s.subspec 'Cronet-Implementation' do |ss|
Muxi Yan2a5072e2016-07-27 15:10:22 -0700162 ss.header_mappings_dir = '.'
Muxi Yane2de92f2017-01-31 16:30:52 -0800163
164 ss.dependency "#{s.name}/Interface", version
165 ss.dependency "#{s.name}/Implementation", version
166 ss.dependency "#{s.name}/Cronet-Interface", version
167
Yash Tibrewaldabce0a2017-10-04 11:58:02 -0700168 ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc',
169 'src/core/ext/transport/cronet/transport/cronet_transport.{cc,h}',
Muxi Yanf0a12692017-01-31 16:36:56 -0800170 'third_party/objective_c/Cronet/bidirectional_stream_c.h'
Muxi Yan2a5072e2016-07-27 15:10:22 -0700171 end
172
Muxi Yanf8372c62016-07-29 09:58:55 -0700173 s.subspec 'Tests' do |ss|
Muxi Yan37480eb2016-07-14 16:22:03 -0700174 ss.header_mappings_dir = '.'
175
Muxi Yane2de92f2017-01-31 16:30:52 -0800176 ss.dependency "#{s.name}/Interface", version
177 ss.dependency "#{s.name}/Implementation", version
178
Muxi Yan2a5072e2016-07-27 15:10:22 -0700179 ss.source_files = 'test/core/end2end/cq_verifier.{c,h}',
Muxi Yan37480eb2016-07-14 16:22:03 -0700180 'test/core/end2end/end2end_tests.{c,h}',
Muxi Yan53c4c282016-11-08 13:34:02 -0800181 'test/core/end2end/end2end_test_utils.c',
Muxi Yan37480eb2016-07-14 16:22:03 -0700182 'test/core/end2end/tests/*.{c,h}',
Muxi Yanf0a6fd82017-08-31 14:31:03 -0700183 'test/core/end2end/fixtures/*.h',
Muxi Yan37480eb2016-07-14 16:22:03 -0700184 'test/core/end2end/data/*.{c,h}',
Muxi Yane38b0122017-03-16 20:53:41 -0700185 'test/core/util/debugger_macros.{c,h}',
Muxi Yan37480eb2016-07-14 16:22:03 -0700186 'test/core/util/test_config.{c,h}',
187 'test/core/util/port.h',
Craig Tiller46ab5f52017-02-28 08:40:19 -0800188 'test/core/util/port.c',
Muxi Yan37480eb2016-07-14 16:22:03 -0700189 'test/core/util/port_server_client.{c,h}'
Muxi Yan37480eb2016-07-14 16:22:03 -0700190 end
Muxi Yan43c47102017-07-06 20:51:49 -0700191
192 # TODO (mxyan): Instead of this hack, add include path "third_party" to C core's include path?
193 s.prepare_command = <<-END_OF_COMMAND
194 find src/core/ -type f -exec sed -E -i '.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
195 END_OF_COMMAND
Jorge Canizalese487a722016-04-30 12:05:26 -0700196 end