Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 1 | %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 | |
Piotr Sikora | 12e26a7 | 2016-08-04 15:32:10 -0700 | [diff] [blame] | 41 | exports_files(["LICENSE"]) |
| 42 | |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 43 | package(default_visibility = ["//visibility:public"]) |
| 44 | |
| 45 | <%! |
| 46 | def get_deps(target_dict): |
| 47 | deps = [] |
| 48 | if target_dict.get('secure', False): |
| 49 | deps = [ |
| 50 | "//external:libssl", |
| 51 | ] |
| 52 | if target_dict.get('build', None) == 'protoc': |
| 53 | deps.append("//external:protobuf_compiler") |
Rob Earhart | ff20c2b | 2016-03-29 11:39:04 -0700 | [diff] [blame] | 54 | if (target_dict['name'] == 'grpc++_unsecure' or |
| 55 | target_dict['name'] == 'grpc++' or |
| 56 | target_dict['name'] == 'grpc++_codegen_lib'): |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 57 | deps.append("//external:protobuf_clib") |
| 58 | elif target_dict['name'] == 'grpc': |
| 59 | deps.append("//external:zlib") |
| 60 | for d in target_dict.get('deps', []): |
| 61 | if d.find('//') == 0 or d[0] == ':': |
| 62 | deps.append(d) |
| 63 | else: |
| 64 | deps.append(':%s' % (d)) |
| 65 | return deps |
| 66 | %> |
Rob Earhart | b7b8d05 | 2016-03-29 11:35:29 -0700 | [diff] [blame] | 67 | |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 68 | % for lib in libs: |
| 69 | % if lib.build in ("all", "protoc"): |
| 70 | ${cc_library(lib)} |
| 71 | % endif |
| 72 | % endfor |
| 73 | |
| 74 | % for lib in libs: |
Craig Tiller | da179ce | 2016-02-09 12:01:53 -0800 | [diff] [blame] | 75 | % if lib.name in ("grpc", "gpr"): |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 76 | ${objc_library(lib)} |
| 77 | % endif |
| 78 | % endfor |
| 79 | |
| 80 | % for tgt in targets: |
| 81 | % if tgt.build == 'protoc': |
| 82 | ${cc_binary(tgt)} |
| 83 | % endif |
| 84 | % endfor |
| 85 | |
| 86 | <%def name="cc_library(lib)"> |
Rob Earhart | b7b8d05 | 2016-03-29 11:35:29 -0700 | [diff] [blame] | 87 | <% |
| 88 | lib_hdrs = lib.get("headers", []) |
| 89 | hdrs = [h for h in lib_hdrs if not h.startswith('third_party/nanopb')] |
| 90 | srcs = [s for s in lib.src if not s.startswith('third_party/nanopb')] |
| 91 | uses_nanopb = len(lib_hdrs) != len(hdrs) or len(srcs) != len(lib.src) |
| 92 | %> |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 93 | cc_library( |
| 94 | name = "${lib.name}", |
| 95 | srcs = [ |
Rob Earhart | b7b8d05 | 2016-03-29 11:35:29 -0700 | [diff] [blame] | 96 | % for hdr in hdrs: |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 97 | "${hdr}", |
| 98 | % endfor |
Rob Earhart | b7b8d05 | 2016-03-29 11:35:29 -0700 | [diff] [blame] | 99 | % for src in srcs: |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 100 | "${src}", |
| 101 | % endfor |
| 102 | ], |
| 103 | hdrs = [ |
| 104 | % for hdr in lib.get("public_headers", []): |
| 105 | "${hdr}", |
| 106 | % endfor |
| 107 | ], |
| 108 | includes = [ |
| 109 | "include", |
| 110 | ".", |
| 111 | ], |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 112 | deps = [ |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 113 | % for dep in get_deps(lib): |
| 114 | "${dep}", |
| 115 | % endfor |
Rob Earhart | b7b8d05 | 2016-03-29 11:35:29 -0700 | [diff] [blame] | 116 | % if uses_nanopb: |
| 117 | "//external:nanopb", |
| 118 | % endif |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 119 | ], |
Rob Earhart | af379b2 | 2016-01-21 13:43:09 -0800 | [diff] [blame] | 120 | % if lib.name in ("grpc", "grpc_unsecure"): |
| 121 | copts = [ |
| 122 | "-std=gnu99", |
| 123 | ], |
| 124 | % endif |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 125 | ) |
| 126 | </%def> |
| 127 | |
| 128 | <%def name="objc_library(lib)"> |
Rob Earhart | b7b8d05 | 2016-03-29 11:35:29 -0700 | [diff] [blame] | 129 | <% |
| 130 | lib_hdrs = lib.get("headers", []) |
| 131 | hdrs = [h for h in lib_hdrs if not h.startswith('third_party/nanopb')] |
| 132 | srcs = [s for s in lib.src if not s.startswith('third_party/nanopb')] |
| 133 | uses_nanopb = len(lib_hdrs) != len(hdrs) or len(srcs) != len(lib.src) |
| 134 | %> |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 135 | objc_library( |
| 136 | name = "${lib.name}_objc", |
| 137 | srcs = [ |
Rob Earhart | b7b8d05 | 2016-03-29 11:35:29 -0700 | [diff] [blame] | 138 | % for src in srcs: |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 139 | "${src}", |
| 140 | % endfor |
| 141 | ], |
| 142 | hdrs = [ |
| 143 | % for hdr in lib.get("public_headers", []): |
| 144 | "${hdr}", |
| 145 | % endfor |
Rob Earhart | b7b8d05 | 2016-03-29 11:35:29 -0700 | [diff] [blame] | 146 | % for hdr in hdrs: |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 147 | "${hdr}", |
| 148 | % endfor |
| 149 | ], |
| 150 | includes = [ |
| 151 | "include", |
| 152 | ".", |
| 153 | ], |
| 154 | deps = [ |
| 155 | % for dep in lib.get("deps", []): |
| 156 | ":${dep}_objc", |
| 157 | % endfor |
| 158 | % if lib.get('secure', False): |
| 159 | "//external:libssl_objc", |
| 160 | % endif |
Rob Earhart | b7b8d05 | 2016-03-29 11:35:29 -0700 | [diff] [blame] | 161 | % if uses_nanopb: |
| 162 | "//external:nanopb", |
| 163 | % endif |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 164 | ], |
| 165 | % if lib.get("baselib", false): |
| 166 | sdk_dylibs = ["libz"], |
| 167 | % endif |
| 168 | ) |
| 169 | </%def> |
| 170 | |
| 171 | <%def name="cc_binary(tgt)"> |
| 172 | cc_binary( |
| 173 | name = "${tgt.name}", |
| 174 | srcs = [ |
| 175 | % for src in tgt.src: |
| 176 | "${src}", |
| 177 | % endfor |
| 178 | ], |
| 179 | deps = [ |
| 180 | % for dep in get_deps(tgt): |
| 181 | "${dep}", |
| 182 | % endfor |
| 183 | ], |
| 184 | ) |
| 185 | </%def> |
| 186 | |
| 187 | objc_path = "src/objective-c" |
| 188 | |
| 189 | rx_library_path = objc_path + "/RxLibrary" |
| 190 | |
| 191 | objc_library( |
| 192 | name = "rx_library", |
| 193 | hdrs = glob([ |
| 194 | rx_library_path + "/*.h", |
| 195 | rx_library_path + "/transformations/*.h", |
| 196 | ]), |
| 197 | srcs = glob([ |
| 198 | rx_library_path + "/*.m", |
| 199 | rx_library_path + "/transformations/*.m", |
| 200 | ]), |
| 201 | includes = [objc_path], |
| 202 | deps = [ |
| 203 | ":rx_library_private", |
| 204 | ], |
| 205 | ) |
| 206 | |
| 207 | objc_library( |
| 208 | name = "rx_library_private", |
| 209 | hdrs = glob([rx_library_path + "/private/*.h"]), |
| 210 | srcs = glob([rx_library_path + "/private/*.m"]), |
| 211 | visibility = ["//visibility:private"], |
| 212 | ) |
| 213 | |
| 214 | objc_client_path = objc_path + "/GRPCClient" |
| 215 | |
| 216 | objc_library( |
| 217 | name = "grpc_client", |
| 218 | hdrs = glob([ |
| 219 | objc_client_path + "/*.h", |
| 220 | objc_client_path + "/private/*.h", |
| 221 | ]), |
| 222 | srcs = glob([ |
| 223 | objc_client_path + "/*.m", |
| 224 | objc_client_path + "/private/*.m", |
| 225 | ]), |
| 226 | includes = [objc_path], |
| 227 | bundles = [":gRPCCertificates"], |
| 228 | deps = [ |
| 229 | ":grpc_objc", |
| 230 | ":rx_library", |
| 231 | ], |
| 232 | ) |
| 233 | |
| 234 | objc_bundle_library( |
| 235 | # The choice of name is signicant here, since it determines the bundle name. |
| 236 | name = "gRPCCertificates", |
| 237 | resources = ["etc/roots.pem"], |
| 238 | ) |
| 239 | |
| 240 | proto_objc_rpc_path = objc_path + "/ProtoRPC" |
| 241 | |
| 242 | objc_library( |
| 243 | name = "proto_objc_rpc", |
| 244 | hdrs = glob([ |
| 245 | proto_objc_rpc_path + "/*.h", |
| 246 | ]), |
| 247 | srcs = glob([ |
| 248 | proto_objc_rpc_path + "/*.m", |
| 249 | ]), |
| 250 | includes = [objc_path], |
| 251 | deps = [ |
| 252 | ":grpc_client", |
| 253 | ":rx_library", |
| 254 | "//external:protobuf_objc", |
| 255 | ], |
| 256 | ) |