blob: bb18c353b103bf96c7bfd5dca0d8773aac41f76f [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")
52 if target_dict['name'] == 'grpc++_unsecure' or target_dict['name'] == 'grpc++':
53 deps.append("//external:protobuf_clib")
54 elif target_dict['name'] == 'grpc':
55 deps.append("//external:zlib")
56 for d in target_dict.get('deps', []):
57 if d.find('//') == 0 or d[0] == ':':
58 deps.append(d)
59 else:
60 deps.append(':%s' % (d))
61 return deps
62 %>
63
64 % for lib in libs:
65 % if lib.build in ("all", "protoc"):
66 ${cc_library(lib)}
67 % endif
68 % endfor
69
70 % for lib in libs:
71 % if lib.name in ("grpc", "gpr"):
72 ${objc_library(lib)}
73 % endif
74 % endfor
75
76 % for tgt in targets:
77 % if tgt.build == 'protoc':
78 ${cc_binary(tgt)}
79 % endif
80 % endfor
81
82 <%def name="cc_library(lib)">
83 cc_library(
84 name = "${lib.name}",
85 srcs = [
86 % for hdr in lib.get("headers", []):
87 "${hdr}",
88 % endfor
89 % for src in lib.src:
90 "${src}",
91 % endfor
92 ],
93 hdrs = [
94 % for hdr in lib.get("public_headers", []):
95 "${hdr}",
96 % endfor
97 ],
98 includes = [
99 "include",
100 ".",
101 ],
Ming Zhao3c0ba0c2015-04-10 12:05:22 -0700102 deps = [
Craig Tiller1ebb7c82015-08-31 15:53:36 -0700103 % for dep in get_deps(lib):
104 "${dep}",
105 % endfor
106 ],
107 )
108 </%def>
109
110 <%def name="objc_library(lib)">
111 objc_library(
112 name = "${lib.name}_objc",
113 srcs = [
114 % for src in lib.src:
115 "${src}",
116 % endfor
117 ],
118 hdrs = [
119 % for hdr in lib.get("public_headers", []):
120 "${hdr}",
121 % endfor
122 % for hdr in lib.get("headers", []):
123 "${hdr}",
124 % endfor
125 ],
126 includes = [
127 "include",
128 ".",
129 ],
130 deps = [
131 % for dep in lib.get("deps", []):
132 ":${dep}_objc",
133 % endfor
134 % if lib.get('secure', False):
135 "//external:libssl_objc",
136 % endif
137 ],
138 % if lib.get("baselib", false):
139 sdk_dylibs = ["libz"],
140 % endif
141 )
142 </%def>
143
144 <%def name="cc_binary(tgt)">
145 cc_binary(
146 name = "${tgt.name}",
147 srcs = [
148 % for src in tgt.src:
149 "${src}",
150 % endfor
151 ],
152 deps = [
153 % for dep in get_deps(tgt):
154 "${dep}",
155 % endfor
156 ],
157 )
158 </%def>
159
160 objc_path = "src/objective-c"
161
162 rx_library_path = objc_path + "/RxLibrary"
163
164 objc_library(
165 name = "rx_library",
166 hdrs = glob([
167 rx_library_path + "/*.h",
168 rx_library_path + "/transformations/*.h",
169 ]),
170 srcs = glob([
171 rx_library_path + "/*.m",
172 rx_library_path + "/transformations/*.m",
173 ]),
174 includes = [objc_path],
175 deps = [
176 ":rx_library_private",
177 ],
178 )
179
180 objc_library(
181 name = "rx_library_private",
182 hdrs = glob([rx_library_path + "/private/*.h"]),
183 srcs = glob([rx_library_path + "/private/*.m"]),
184 visibility = ["//visibility:private"],
185 )
186
187 objc_client_path = objc_path + "/GRPCClient"
188
189 objc_library(
190 name = "grpc_client",
191 hdrs = glob([
192 objc_client_path + "/*.h",
193 objc_client_path + "/private/*.h",
194 ]),
195 srcs = glob([
196 objc_client_path + "/*.m",
197 objc_client_path + "/private/*.m",
198 ]),
199 includes = [objc_path],
200 bundles = [":gRPCCertificates"],
201 deps = [
202 ":grpc_objc",
203 ":rx_library",
204 ],
205 )
206
207 objc_bundle_library(
208 # The choice of name is signicant here, since it determines the bundle name.
209 name = "gRPCCertificates",
210 resources = ["etc/roots.pem"],
211 )
212
213 proto_objc_rpc_path = objc_path + "/ProtoRPC"
214
215 objc_library(
216 name = "proto_objc_rpc",
217 hdrs = glob([
218 proto_objc_rpc_path + "/*.h",
219 ]),
220 srcs = glob([
221 proto_objc_rpc_path + "/*.m",
222 ]),
223 includes = [objc_path],
224 deps = [
225 ":grpc_client",
226 ":rx_library",
227 "//external:protobuf_objc",
228 ],
229 )