blob: 4e9d8c376a996574b50a6ce2a6e06fa7f2b6046d [file] [log] [blame]
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +02001# GRPC Bazel BUILD file.
Jorge Canizales3beb2402015-07-02 01:30:33 -07002# This currently builds C, C++ and Objective-C code.
Nicolas "Pixel" Nobled49893d2015-04-21 04:57:45 +02003# This file has been automatically generated from a template file.
4# Please look at the templates directory instead.
murgatroid99c241d2c2015-06-22 11:19:57 -07005# This file can be regenerated from the template by running
6# tools/buildgen/generate_projects.sh
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +02007
8# Copyright 2015, Google Inc.
9# All rights reserved.
10#
11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions are
13# met:
14#
15# * Redistributions of source code must retain the above copyright
16# notice, this list of conditions and the following disclaimer.
17# * Redistributions in binary form must reproduce the above
18# copyright notice, this list of conditions and the following disclaimer
19# in the documentation and/or other materials provided with the
20# distribution.
21# * Neither the name of Google Inc. nor the names of its
22# contributors may be used to endorse or promote products derived from
23# this software without specific prior written permission.
24#
25# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
37licenses(["notice"]) # 3-clause BSD
38
Ming Zhao3c0ba0c2015-04-10 12:05:22 -070039package(default_visibility = ["//visibility:public"])
40
41<%!
42def get_deps(target_dict):
43 deps = []
44 if target_dict.get('secure', 'no') == 'yes':
45 deps = [
46 "//external:libssl",
47 ]
48 if target_dict.get('build', None) == 'protoc':
49 deps.append("//external:protobuf_compiler")
50 if target_dict['name'] == 'grpc++_unsecure' or target_dict['name'] == 'grpc++':
51 deps.append("//external:protobuf_clib")
52 for d in target_dict.get('deps', []):
53 if d.find('//') == 0 or d[0] == ':':
54 deps.append(d)
55 else:
56 deps.append(':%s' % (d))
57 return deps
58%>
59
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +020060% for lib in libs:
Yang Gao736bd652015-04-16 15:42:42 -070061% if lib.build in ("all", "protoc"):
Ming Zhao3c0ba0c2015-04-10 12:05:22 -070062${cc_library(lib)}
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +020063% endif
64% endfor
65
Jorge Canizales140bca82015-06-20 09:47:00 -070066% for lib in libs:
Jorge Canizales7b1a0ca2015-06-26 21:49:42 -070067% if lib.name in ("grpc", "gpr"):
Jorge Canizales140bca82015-06-20 09:47:00 -070068${objc_library(lib)}
69% endif
70% endfor
71
Ming Zhao3c0ba0c2015-04-10 12:05:22 -070072% for tgt in targets:
73% if tgt.build == 'protoc':
74${cc_binary(tgt)}
75% endif
76% endfor
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +020077
Ming Zhao3c0ba0c2015-04-10 12:05:22 -070078<%def name="cc_library(lib)">
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +020079cc_library(
Ming Zhao3c0ba0c2015-04-10 12:05:22 -070080 name = "${lib.name}",
81 srcs = [
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +020082% for hdr in lib.get("headers", []):
Ming Zhao3c0ba0c2015-04-10 12:05:22 -070083 "${hdr}",
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +020084% endfor
85% for src in lib.src:
Ming Zhao3c0ba0c2015-04-10 12:05:22 -070086 "${src}",
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +020087% endfor
Ming Zhao3c0ba0c2015-04-10 12:05:22 -070088 ],
89 hdrs = [
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +020090% for hdr in lib.get("public_headers", []):
Ming Zhao3c0ba0c2015-04-10 12:05:22 -070091 "${hdr}",
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +020092% endfor
Ming Zhao3c0ba0c2015-04-10 12:05:22 -070093 ],
94 includes = [
95 "include",
96 ".",
97 ],
98 deps = [
99% for dep in get_deps(lib):
100 "${dep}",
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +0200101% endfor
Ming Zhao3c0ba0c2015-04-10 12:05:22 -0700102 ],
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +0200103)
Ming Zhao3c0ba0c2015-04-10 12:05:22 -0700104</%def>
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +0200105
Jorge Canizales140bca82015-06-20 09:47:00 -0700106<%def name="objc_library(lib)">
107objc_library(
108 name = "${lib.name}_objc",
109 srcs = [
110% for src in lib.src:
111 "${src}",
112% endfor
113 ],
114 hdrs = [
115% for hdr in lib.get("public_headers", []):
116 "${hdr}",
117% endfor
118% for hdr in lib.get("headers", []):
119 "${hdr}",
120% endfor
121 ],
122 includes = [
123 "include",
124 ".",
125 ],
126 deps = [
127% for dep in lib.get("deps", []):
128 ":${dep}_objc",
129% endfor
Jorge Canizales4dc4e3d2015-06-26 22:12:02 -0700130% if lib.get('secure', 'no') == 'yes':
131 "//external:libssl_objc",
132% endif
Jorge Canizales140bca82015-06-20 09:47:00 -0700133 ],
Jorge Canizales8c1fd042015-06-22 19:11:36 -0700134% if lib.get("baselib", false):
135 sdk_dylibs = ["libz"],
136% endif
Jorge Canizales140bca82015-06-20 09:47:00 -0700137)
138</%def>
139
Ming Zhao3c0ba0c2015-04-10 12:05:22 -0700140<%def name="cc_binary(tgt)">
141cc_binary(
142 name = "${tgt.name}",
143 srcs = [
144% for src in tgt.src:
145 "${src}",
146% endfor
147 ],
148 deps = [
149% for dep in get_deps(tgt):
150 "${dep}",
151% endfor
152 ],
153)
Nicolas "Pixel" Noblef6edf682015-03-31 05:17:34 +0200154</%def>
Jorge Canizales44dc4232015-06-19 16:30:31 -0700155
156objc_path = "src/objective-c"
157
158rx_library_path = objc_path + "/RxLibrary"
159
160objc_library(
Jorge Canizalesbba80762015-06-26 23:25:48 -0700161 name = "rx_library",
162 hdrs = glob([
163 rx_library_path + "/*.h",
164 rx_library_path + "/transformations/*.h",
165 ]),
166 srcs = glob([
167 rx_library_path + "/*.m",
168 rx_library_path + "/transformations/*.m",
169 ]),
170 includes = [objc_path],
171 deps = [
172 ":rx_library_private",
173 ],
Jorge Canizales44dc4232015-06-19 16:30:31 -0700174)
175
176objc_library(
Jorge Canizalesbba80762015-06-26 23:25:48 -0700177 name = "rx_library_private",
178 hdrs = glob([rx_library_path + "/private/*.h"]),
179 srcs = glob([rx_library_path + "/private/*.m"]),
180 visibility = ["//visibility:private"],
Jorge Canizales44dc4232015-06-19 16:30:31 -0700181)
Jorge Canizales866255e2015-06-20 18:58:38 -0700182
183objc_client_path = objc_path + "/GRPCClient"
184
185objc_library(
186 name = "grpc_client",
187 hdrs = glob([
188 objc_client_path + "/*.h",
189 objc_client_path + "/private/*.h",
190 ]),
191 srcs = glob([
192 objc_client_path + "/*.m",
193 objc_client_path + "/private/*.m",
194 ]),
195 includes = [objc_path],
Jorge Canizalesbb54ae82015-06-28 06:50:58 -0700196 bundles = [":gRPCCertificates"],
Jorge Canizales866255e2015-06-20 18:58:38 -0700197 deps = [
198 ":grpc_objc",
199 ":rx_library",
200 ],
201)
Jorge Canizalesbb54ae82015-06-28 06:50:58 -0700202
203objc_bundle_library(
204 # The choice of name is signicant here, since it determines the bundle name.
205 name = "gRPCCertificates",
206 resources = ["etc/roots.pem"],
207)
Jorge Canizales50f19822015-06-28 23:48:30 -0700208
209proto_objc_rpc_path = objc_path + "/ProtoRPC"
210
211objc_library(
212 name = "proto_objc_rpc",
213 hdrs = glob([
214 proto_objc_rpc_path + "/*.h",
215 ]),
216 srcs = glob([
217 proto_objc_rpc_path + "/*.m",
218 ]),
219 includes = [objc_path],
220 deps = [
221 ":grpc_client",
222 ":rx_library",
223 "//external:protobuf_objc",
224 ],
225)