blob: 23a656c3608528bd431e3ed9a5cf4dd1b67c2b91 [file] [log] [blame]
Craig Tiller1ebb7c82015-08-31 15:53:36 -07001%YAML 1.2
2--- |
3 # GRPC Bazel BUILD file.
4 # This currently builds C, C++ and Objective-C code.
5 # This file has been automatically generated from a template file.
6 # Please look at the templates directory instead.
7 # This file can be regenerated from the template by running
8 # tools/buildgen/generate_projects.sh
9
10 # Copyright 2015, Google Inc.
11 # All rights reserved.
12 #
13 # Redistribution and use in source and binary forms, with or without
14 # modification, are permitted provided that the following conditions are
15 # met:
16 #
17 # * Redistributions of source code must retain the above copyright
18 # notice, this list of conditions and the following disclaimer.
19 # * Redistributions in binary form must reproduce the above
20 # copyright notice, this list of conditions and the following disclaimer
21 # in the documentation and/or other materials provided with the
22 # distribution.
23 # * Neither the name of Google Inc. nor the names of its
24 # contributors may be used to endorse or promote products derived from
25 # this software without specific prior written permission.
26 #
27 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39 licenses(["notice"]) # 3-clause BSD
40
41 package(default_visibility = ["//visibility:public"])
42
43 <%!
44 def get_deps(target_dict):
45 deps = []
46 if target_dict.get('secure', False):
47 deps = [
48 "//external:libssl",
49 ]
50 if target_dict.get('build', None) == 'protoc':
51 deps.append("//external:protobuf_compiler")
Rob Earhartff20c2b2016-03-29 11:39:04 -070052 if (target_dict['name'] == 'grpc++_unsecure' or
53 target_dict['name'] == 'grpc++' or
54 target_dict['name'] == 'grpc++_codegen_lib'):
Craig Tiller1ebb7c82015-08-31 15:53:36 -070055 deps.append("//external:protobuf_clib")
56 elif target_dict['name'] == 'grpc':
57 deps.append("//external:zlib")
58 for d in target_dict.get('deps', []):
59 if d.find('//') == 0 or d[0] == ':':
60 deps.append(d)
61 else:
62 deps.append(':%s' % (d))
63 return deps
64 %>
Rob Earhartb7b8d052016-03-29 11:35:29 -070065
Craig Tiller1ebb7c82015-08-31 15:53:36 -070066 % for lib in libs:
67 % if lib.build in ("all", "protoc"):
68 ${cc_library(lib)}
69 % endif
70 % endfor
71
72 % for lib in libs:
Craig Tillerda179ce2016-02-09 12:01:53 -080073 % if lib.name in ("grpc", "gpr"):
Craig Tiller1ebb7c82015-08-31 15:53:36 -070074 ${objc_library(lib)}
75 % endif
76 % endfor
77
78 % for tgt in targets:
79 % if tgt.build == 'protoc':
80 ${cc_binary(tgt)}
81 % endif
82 % endfor
83
84 <%def name="cc_library(lib)">
Rob Earhartb7b8d052016-03-29 11:35:29 -070085 <%
86 lib_hdrs = lib.get("headers", [])
87 hdrs = [h for h in lib_hdrs if not h.startswith('third_party/nanopb')]
88 srcs = [s for s in lib.src if not s.startswith('third_party/nanopb')]
89 uses_nanopb = len(lib_hdrs) != len(hdrs) or len(srcs) != len(lib.src)
90 %>
Craig Tiller1ebb7c82015-08-31 15:53:36 -070091 cc_library(
92 name = "${lib.name}",
93 srcs = [
Rob Earhartb7b8d052016-03-29 11:35:29 -070094 % for hdr in hdrs:
Craig Tiller1ebb7c82015-08-31 15:53:36 -070095 "${hdr}",
96 % endfor
Rob Earhartb7b8d052016-03-29 11:35:29 -070097 % for src in srcs:
Craig Tiller1ebb7c82015-08-31 15:53:36 -070098 "${src}",
99 % endfor
100 ],
101 hdrs = [
102 % for hdr in lib.get("public_headers", []):
103 "${hdr}",
104 % endfor
105 ],
106 includes = [
107 "include",
108 ".",
109 ],
Ming Zhao3c0ba0c2015-04-10 12:05:22 -0700110 deps = [
Craig Tiller1ebb7c82015-08-31 15:53:36 -0700111 % for dep in get_deps(lib):
112 "${dep}",
113 % endfor
Rob Earhartb7b8d052016-03-29 11:35:29 -0700114 % if uses_nanopb:
115 "//external:nanopb",
116 % endif
Craig Tiller1ebb7c82015-08-31 15:53:36 -0700117 ],
Rob Earhartaf379b22016-01-21 13:43:09 -0800118 % if lib.name in ("grpc", "grpc_unsecure"):
119 copts = [
120 "-std=gnu99",
121 ],
122 % endif
Craig Tiller1ebb7c82015-08-31 15:53:36 -0700123 )
124 </%def>
125
126 <%def name="objc_library(lib)">
Rob Earhartb7b8d052016-03-29 11:35:29 -0700127 <%
128 lib_hdrs = lib.get("headers", [])
129 hdrs = [h for h in lib_hdrs if not h.startswith('third_party/nanopb')]
130 srcs = [s for s in lib.src if not s.startswith('third_party/nanopb')]
131 uses_nanopb = len(lib_hdrs) != len(hdrs) or len(srcs) != len(lib.src)
132 %>
Craig Tiller1ebb7c82015-08-31 15:53:36 -0700133 objc_library(
134 name = "${lib.name}_objc",
135 srcs = [
Rob Earhartb7b8d052016-03-29 11:35:29 -0700136 % for src in srcs:
Craig Tiller1ebb7c82015-08-31 15:53:36 -0700137 "${src}",
138 % endfor
139 ],
140 hdrs = [
141 % for hdr in lib.get("public_headers", []):
142 "${hdr}",
143 % endfor
Rob Earhartb7b8d052016-03-29 11:35:29 -0700144 % for hdr in hdrs:
Craig Tiller1ebb7c82015-08-31 15:53:36 -0700145 "${hdr}",
146 % endfor
147 ],
148 includes = [
149 "include",
150 ".",
151 ],
152 deps = [
153 % for dep in lib.get("deps", []):
154 ":${dep}_objc",
155 % endfor
156 % if lib.get('secure', False):
157 "//external:libssl_objc",
158 % endif
Rob Earhartb7b8d052016-03-29 11:35:29 -0700159 % if uses_nanopb:
160 "//external:nanopb",
161 % endif
Craig Tiller1ebb7c82015-08-31 15:53:36 -0700162 ],
163 % if lib.get("baselib", false):
164 sdk_dylibs = ["libz"],
165 % endif
166 )
167 </%def>
168
169 <%def name="cc_binary(tgt)">
170 cc_binary(
171 name = "${tgt.name}",
172 srcs = [
173 % for src in tgt.src:
174 "${src}",
175 % endfor
176 ],
177 deps = [
178 % for dep in get_deps(tgt):
179 "${dep}",
180 % endfor
181 ],
182 )
183 </%def>
184
185 objc_path = "src/objective-c"
186
187 rx_library_path = objc_path + "/RxLibrary"
188
189 objc_library(
190 name = "rx_library",
191 hdrs = glob([
192 rx_library_path + "/*.h",
193 rx_library_path + "/transformations/*.h",
194 ]),
195 srcs = glob([
196 rx_library_path + "/*.m",
197 rx_library_path + "/transformations/*.m",
198 ]),
199 includes = [objc_path],
200 deps = [
201 ":rx_library_private",
202 ],
203 )
204
205 objc_library(
206 name = "rx_library_private",
207 hdrs = glob([rx_library_path + "/private/*.h"]),
208 srcs = glob([rx_library_path + "/private/*.m"]),
209 visibility = ["//visibility:private"],
210 )
211
212 objc_client_path = objc_path + "/GRPCClient"
213
214 objc_library(
215 name = "grpc_client",
216 hdrs = glob([
217 objc_client_path + "/*.h",
218 objc_client_path + "/private/*.h",
219 ]),
220 srcs = glob([
221 objc_client_path + "/*.m",
222 objc_client_path + "/private/*.m",
223 ]),
224 includes = [objc_path],
225 bundles = [":gRPCCertificates"],
226 deps = [
227 ":grpc_objc",
228 ":rx_library",
229 ],
230 )
231
232 objc_bundle_library(
233 # The choice of name is signicant here, since it determines the bundle name.
234 name = "gRPCCertificates",
235 resources = ["etc/roots.pem"],
236 )
237
238 proto_objc_rpc_path = objc_path + "/ProtoRPC"
239
240 objc_library(
241 name = "proto_objc_rpc",
242 hdrs = glob([
243 proto_objc_rpc_path + "/*.h",
244 ]),
245 srcs = glob([
246 proto_objc_rpc_path + "/*.m",
247 ]),
248 includes = [objc_path],
249 deps = [
250 ":grpc_client",
251 ":rx_library",
252 "//external:protobuf_objc",
253 ],
254 )