blob: 12d5fc17d434e53e20495e4f21e3fbee5985e114 [file] [log] [blame]
Muxi Yan46ee18b2018-01-05 16:01:16 -08001%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 <%!
25 def grpc_lib_files(libs, expect_libs, groups):
26 out = []
27 for lib in libs:
28 if lib.name in expect_libs:
29 for group in groups:
30 out += lib.get(group, [])
31 return out
32
Muxi Yan6be15ee2018-02-20 14:05:33 -080033 def filter_grpcpp(files):
34 return [file for file in files if not file.startswith("include/grpc++")]
35
Muxi Yan46ee18b2018-01-05 16:01:16 -080036 def grpc_private_files(libs):
37 out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers", "src"))
38 return out
39
40 def grpc_private_headers(libs):
41 out = grpc_lib_files(libs, ("grpc", "gpr"), ("headers",))
42 return out
43
44 def grpc_public_headers(libs):
45 out = grpc_lib_files(libs, ("grpc", "gpr"), ("public_headers",))
46 return out
47
48 def grpcpp_proto_files(filegroups):
49 out = grpc_lib_files(filegroups, ("grpc++_codegen_proto", "grpc++_config_proto"), ("headers", "src", "public_headers"))
50 excl_files = grpc_lib_files(filegroups, ("grpc++_codegen_base",), ("headers", "src", "public_headers"))
51 out = [file for file in out if file not in excl_files]
52 return out
53
54 def grpcpp_private_files(libs, filegroups):
55 out = grpc_lib_files(libs, ("grpc++",), ("headers", "src"))
56 excl_files = grpc_private_files(libs)
57
58 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
59 excl_files += grpcpp_proto_files(filegroups)
60 out = [file for file in out if file not in excl_files]
61
62 # Since some C++ source files directly included private headers in C core, we include all the
63 # C core headers in C++ Implementation subspec as well.
64 out += [file for file in grpc_private_headers(libs) if not file.startswith("third_party/nanopb/")]
Muxi Yan6be15ee2018-02-20 14:05:33 -080065
66 out = filter_grpcpp(out)
67
Muxi Yan46ee18b2018-01-05 16:01:16 -080068 return out
69
70 def grpcpp_private_headers(libs, filegroups):
71 out = grpc_lib_files(libs, ("grpc++",), ("headers",))
72
73 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
74 excl_files = grpcpp_proto_files(filegroups)
75 out = [file for file in out if file not in excl_files]
76
77 # Since some C++ source files directly included private headers in C core, we intentionally
78 # keep the C core headers in \a out. But we should exclude nanopb headers.
79 out = [file for file in out if not file.startswith("third_party/nanopb/")]
Muxi Yan6be15ee2018-02-20 14:05:33 -080080
81 out = filter_grpcpp(out)
Muxi Yan46ee18b2018-01-05 16:01:16 -080082 return out
83
84 def grpcpp_public_headers(libs, filegroups):
85 out = grpc_lib_files(libs, ("grpc++",), ("public_headers",))
86 excl_files = grpc_public_headers(libs)
87
88 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
89 excl_files += grpcpp_proto_files(filegroups)
90
91 out = [file for file in out if file not in excl_files]
Muxi Yan6be15ee2018-02-20 14:05:33 -080092
93 out = filter_grpcpp(out)
94
Muxi Yan46ee18b2018-01-05 16:01:16 -080095 return out
96
97 def grpc_test_util_files(libs):
98 out = grpc_lib_files(libs, ("grpc_test_util", "gpr_test_util"), ("src", "headers"))
99 return out
100
101 def grpc_test_util_headers(libs):
102 out = grpc_lib_files(libs, ("grpc_test_util", "gpr_test_util"), ("headers",))
103 return out
104
Muxi Yanb19c5252018-02-21 17:29:33 -0800105 # Tests subspec is currently disabled since the tests currently use `grpc++` include style instead of `grpcpp`.
106 # TODO (mxyan): enable Tests subspec after the inclusion style is updated in `test/` directory.
Muxi Yan46ee18b2018-01-05 16:01:16 -0800107 def grpcpp_test_util_files(libs, filegroups):
108 out = grpc_lib_files(libs, ("grpc++_test_util",), ("src", "headers"))
109 excl_files = grpc_test_util_files(libs) + grpcpp_private_files(libs, filegroups)
110
111 # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
112 excl_files += grpc_lib_files(filegroups, ("grpc++_codegen_proto", "grpc++_config_proto"), ("headers", "src"))
113 excl_files += ["test/cpp/util/byte_buffer_proto_helper.cc",
114 "test/cpp/util/byte_buffer_proto_helper.h",
115 "test/cpp/end2end/test_service_impl.cc",
116 "test/cpp/end2end/test_service_impl.h"]
117 excl_files += [file for file in out if file.endswith(".proto")]
118
119 out = [file for file in out if not file in excl_files]
120
121 # Since some C++ test files directly included private headers in C core, we intentionally add these header
122 # files to this subspec
123 out += grpc_test_util_headers(libs)
124
125 return out
126
127 def ruby_multiline_list(files, indent):
128 return (',\n' + indent*' ').join('\'%s\'' % f for f in files)
129 %>
130 Pod::Spec.new do |s|
131 s.name = 'gRPC-C++'
132 # TODO (mxyan): use version that match gRPC version when pod is stabilized
133 # version = '${settings.version}'
Muxi Yanb19c5252018-02-21 17:29:33 -0800134 version = '0.0.2'
Muxi Yan46ee18b2018-01-05 16:01:16 -0800135 s.version = version
136 s.summary = 'gRPC C++ library'
137 s.homepage = 'https://grpc.io'
138 s.license = 'Apache License, Version 2.0'
139 s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
140
141 grpc_version = '${settings.version}'
142
143 s.source = {
144 :git => 'https://github.com/grpc/grpc.git',
145 :tag => "v#{grpc_version}",
146 }
147
148 s.ios.deployment_target = '7.0'
149 s.osx.deployment_target = '10.9'
150 s.requires_arc = false
151
Muxi Yan6be15ee2018-02-20 14:05:33 -0800152 name = 'grpcpp'
153 # Use `grpcpp` as framework name so that `#include <grpcpp/xxx.h>` works when built as
154 # framework.
155 s.module_name = name
156
157 # Add include prefix `grpcpp` so that `#include <grpcpp/xxx.h>` works when built as static
158 # library.
159 s.header_dir = name
Muxi Yan46ee18b2018-01-05 16:01:16 -0800160
161 s.pod_target_xcconfig = {
162 'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"',
163 'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"',
164 'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"',
165 'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
166 'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
167
168 # If we don't set these two settings, `include/grpc/support/time.h` and
169 # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
170 # build.
171 'USE_HEADERMAP' => 'NO',
172 'ALWAYS_SEARCH_USER_PATHS' => 'NO',
173 }
174
175 s.libraries = 'c++'
176
177 s.default_subspecs = 'Interface', 'Implementation'
178
Muxi Yan6ef01592018-02-21 18:10:49 -0800179 s.header_mappings_dir = 'include/grpcpp'
180
Muxi Yan46ee18b2018-01-05 16:01:16 -0800181 s.subspec 'Interface' do |ss|
Muxi Yan6be15ee2018-02-20 14:05:33 -0800182 ss.header_mappings_dir = 'include/grpcpp'
Muxi Yan46ee18b2018-01-05 16:01:16 -0800183
184 ss.source_files = ${ruby_multiline_list(grpcpp_public_headers(libs, filegroups), 22)}
185 end
186
187 s.subspec 'Implementation' do |ss|
188 ss.header_mappings_dir = '.'
189 ss.dependency "#{s.name}/Interface", version
190 ss.dependency 'gRPC-Core', grpc_version
191 ss.dependency 'nanopb', '~> 0.3'
192
193 ss.source_files = ${ruby_multiline_list(grpcpp_private_files(libs, filegroups), 22)}
194
195 ss.private_header_files = ${ruby_multiline_list(grpcpp_private_headers(libs, filegroups), 30)}
196 end
197
Muxi Yan46ee18b2018-01-05 16:01:16 -0800198 s.prepare_command = <<-END_OF_COMMAND
Muxi Yan277e2e42018-01-18 17:01:08 -0800199 find src/cpp/ -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
Muxi Yan46ee18b2018-01-05 16:01:16 -0800200 find src/cpp/ -name "*.back" -type f -delete
Muxi Yan277e2e42018-01-18 17:01:08 -0800201 find src/core/ -regex ".*\.h" -type f -exec sed -E -i'.back' 's;#include "third_party/nanopb/(.*)";#include <nanopb/\\1>;g' {} \\\;
Muxi Yan46ee18b2018-01-05 16:01:16 -0800202 find src/core/ -name "*.back" -type f -delete
203 END_OF_COMMAND
204 end