• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  <%!
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
33  def filter_grpcpp(files):
34    return [file for file in files if not file.startswith("include/grpc++")]
35
36  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    out = filter_grpcpp(out)
53    return out
54
55  def grpcpp_private_files(libs, filegroups):
56    out = grpc_lib_files(libs, ("grpc++",), ("headers", "src"))
57    excl_files = grpc_private_files(libs)
58
59    # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
60    excl_files += grpcpp_proto_files(filegroups)
61    out = [file for file in out if file not in excl_files]
62
63    # Since some C++ source files directly included private headers in C core, we include all the
64    # C core headers in C++ Implementation subspec as well.
65    out += [file for file in grpc_private_headers(libs) if not file.startswith("third_party/nanopb/")]
66
67    out = filter_grpcpp(out)
68
69    return out
70
71  def grpcpp_private_headers(libs, filegroups):
72    out = grpc_lib_files(libs, ("grpc++",), ("headers",))
73
74    # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
75    excl_files = grpcpp_proto_files(filegroups)
76    out = [file for file in out if file not in excl_files]
77
78    # Since some C++ source files directly included private headers in C core, we intentionally
79    # keep the C core headers in \a out. But we should exclude nanopb headers.
80    out = [file for file in out if not file.startswith("third_party/nanopb/")]
81
82    out = filter_grpcpp(out)
83    return out
84
85  def grpcpp_public_headers(libs, filegroups):
86    out = grpc_lib_files(libs, ("grpc++",), ("public_headers",))
87    excl_files = grpc_public_headers(libs)
88
89    # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
90    excl_files += grpcpp_proto_files(filegroups)
91
92    out = [file for file in out if file not in excl_files]
93
94    out = filter_grpcpp(out)
95
96    return out
97
98  def grpc_test_util_files(libs):
99    out = grpc_lib_files(libs, ("grpc_test_util", "gpr_test_util"), ("src", "headers"))
100    return out
101
102  def grpc_test_util_headers(libs):
103    out = grpc_lib_files(libs, ("grpc_test_util", "gpr_test_util"), ("headers",))
104    return out
105
106  # Tests subspec is currently disabled since the tests currently use `grpc++` include style instead of `grpcpp`.
107  # TODO (mxyan): enable Tests subspec after the inclusion style is updated in `test/` directory.
108  def grpcpp_test_util_files(libs, filegroups):
109    out = grpc_lib_files(libs, ("grpc++_test_util",), ("src", "headers"))
110    excl_files = grpc_test_util_files(libs) + grpcpp_private_files(libs, filegroups)
111
112    # We exclude proto related files in this particular podspec so that we can provide a protobuf-independent lib
113    excl_files += grpc_lib_files(filegroups, ("grpc++_codegen_proto", "grpc++_config_proto"), ("headers", "src"))
114    excl_files += ["test/cpp/util/byte_buffer_proto_helper.cc",
115                   "test/cpp/util/byte_buffer_proto_helper.h",
116                   "test/cpp/end2end/test_service_impl.cc",
117                   "test/cpp/end2end/test_service_impl.h"]
118    excl_files += [file for file in out if file.endswith(".proto")]
119
120    out = [file for file in out if not file in excl_files]
121
122    # Since some C++ test files directly included private headers in C core, we intentionally add these header
123    # files to this subspec
124    out += grpc_test_util_headers(libs)
125
126    return out
127
128  def ruby_multiline_list(files, indent):
129    return (',\n' + indent*' ').join('\'%s\'' % f for f in files)
130  %>
131  Pod::Spec.new do |s|
132    s.name     = 'gRPC-C++'
133    # TODO (mxyan): use version that match gRPC version when pod is stabilized
134    # version = '${settings.version}'
135    version = '0.0.3'
136    s.version  = version
137    s.summary  = 'gRPC C++ library'
138    s.homepage = 'https://grpc.io'
139    s.license  = 'Apache License, Version 2.0'
140    s.authors  = { 'The gRPC contributors' => 'grpc-packages@google.com' }
141
142    grpc_version = '${settings.version}'
143
144    s.source = {
145      :git => 'https://github.com/grpc/grpc.git',
146      :tag => "v#{grpc_version}",
147    }
148
149    s.ios.deployment_target = '7.0'
150    s.osx.deployment_target = '10.9'
151    s.requires_arc = false
152
153    name = 'grpcpp'
154    # Use `grpcpp` as framework name so that `#include <grpcpp/xxx.h>` works when built as
155    # framework.
156    s.module_name = name
157
158    # Add include prefix `grpcpp` so that `#include <grpcpp/xxx.h>` works when built as static
159    # library.
160    s.header_dir = name
161
162    s.pod_target_xcconfig = {
163      'HEADER_SEARCH_PATHS' => '"$(inherited)" "$(PODS_TARGET_SRCROOT)/include"',
164      'USER_HEADER_SEARCH_PATHS' => '"$(PODS_TARGET_SRCROOT)"',
165      'GCC_PREPROCESSOR_DEFINITIONS' => '"$(inherited)" "COCOAPODS=1" "PB_NO_PACKED_STRUCTS=1"',
166      'CLANG_WARN_STRICT_PROTOTYPES' => 'NO',
167      'CLANG_WARN_DOCUMENTATION_COMMENTS' => 'NO',
168
169      # If we don't set these two settings, `include/grpc/support/time.h` and
170      # `src/core/lib/support/string.h` shadow the system `<time.h>` and `<string.h>`, breaking the
171      # build.
172      'USE_HEADERMAP' => 'NO',
173      'ALWAYS_SEARCH_USER_PATHS' => 'NO',
174    }
175
176    s.libraries = 'c++'
177
178    s.default_subspecs = 'Interface', 'Implementation'
179
180    s.header_mappings_dir = 'include/grpcpp'
181
182    s.subspec 'Interface' do |ss|
183      ss.header_mappings_dir = 'include/grpcpp'
184
185      ss.source_files = ${ruby_multiline_list(grpcpp_public_headers(libs, filegroups), 22)}
186    end
187
188    s.subspec 'Implementation' do |ss|
189      ss.header_mappings_dir = '.'
190      ss.dependency "#{s.name}/Interface", version
191      ss.dependency 'gRPC-Core', grpc_version
192      ss.dependency 'nanopb', '~> 0.3'
193
194      ss.source_files = ${ruby_multiline_list(grpcpp_private_files(libs, filegroups), 22)}
195
196      ss.private_header_files = ${ruby_multiline_list(grpcpp_private_headers(libs, filegroups), 30)}
197    end
198
199    s.subspec 'Protobuf' do |ss|
200      ss.header_mappings_dir = 'include/grpcpp'
201      ss.dependency "#{s.name}/Interface", version
202
203      ss.source_files = ${ruby_multiline_list(grpcpp_proto_files(filegroups), 22)}
204    end
205
206    s.prepare_command = <<-END_OF_COMMAND
207      find src/cpp/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include <nanopb/\\1>;g'
208      find src/cpp/ -type f -path '*.grpc_back' -print0 | xargs -0 rm
209      find src/core/ -type f ! -path '*.grpc_back' -print0 | xargs -0 -L1 sed -E -i'.grpc_back' 's;#include "(pb(_.*)?\\.h)";#include <nanopb/\\1>;g'
210      find src/core/ -type f -path '*.grpc_back' -print0 | xargs -0 rm
211    END_OF_COMMAND
212  end
213