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 | |
| 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: |
Craig Tiller | da179ce | 2016-02-09 12:01:53 -0800 | [diff] [blame] | 71 | % if lib.name in ("grpc", "gpr"): |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 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 Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 102 | deps = [ |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 103 | % for dep in get_deps(lib): |
| 104 | "${dep}", |
| 105 | % endfor |
| 106 | ], |
Rob Earhart | af379b2 | 2016-01-21 13:43:09 -0800 | [diff] [blame] | 107 | % if lib.name in ("grpc", "grpc_unsecure"): |
| 108 | copts = [ |
| 109 | "-std=gnu99", |
| 110 | ], |
| 111 | % endif |
Craig Tiller | 1ebb7c8 | 2015-08-31 15:53:36 -0700 | [diff] [blame] | 112 | ) |
| 113 | </%def> |
| 114 | |
| 115 | <%def name="objc_library(lib)"> |
| 116 | objc_library( |
| 117 | name = "${lib.name}_objc", |
| 118 | srcs = [ |
| 119 | % for src in lib.src: |
| 120 | "${src}", |
| 121 | % endfor |
| 122 | ], |
| 123 | hdrs = [ |
| 124 | % for hdr in lib.get("public_headers", []): |
| 125 | "${hdr}", |
| 126 | % endfor |
| 127 | % for hdr in lib.get("headers", []): |
| 128 | "${hdr}", |
| 129 | % endfor |
| 130 | ], |
| 131 | includes = [ |
| 132 | "include", |
| 133 | ".", |
| 134 | ], |
| 135 | deps = [ |
| 136 | % for dep in lib.get("deps", []): |
| 137 | ":${dep}_objc", |
| 138 | % endfor |
| 139 | % if lib.get('secure', False): |
| 140 | "//external:libssl_objc", |
| 141 | % endif |
| 142 | ], |
| 143 | % if lib.get("baselib", false): |
| 144 | sdk_dylibs = ["libz"], |
| 145 | % endif |
| 146 | ) |
| 147 | </%def> |
| 148 | |
| 149 | <%def name="cc_binary(tgt)"> |
| 150 | cc_binary( |
| 151 | name = "${tgt.name}", |
| 152 | srcs = [ |
| 153 | % for src in tgt.src: |
| 154 | "${src}", |
| 155 | % endfor |
| 156 | ], |
| 157 | deps = [ |
| 158 | % for dep in get_deps(tgt): |
| 159 | "${dep}", |
| 160 | % endfor |
| 161 | ], |
| 162 | ) |
| 163 | </%def> |
| 164 | |
| 165 | objc_path = "src/objective-c" |
| 166 | |
| 167 | rx_library_path = objc_path + "/RxLibrary" |
| 168 | |
| 169 | objc_library( |
| 170 | name = "rx_library", |
| 171 | hdrs = glob([ |
| 172 | rx_library_path + "/*.h", |
| 173 | rx_library_path + "/transformations/*.h", |
| 174 | ]), |
| 175 | srcs = glob([ |
| 176 | rx_library_path + "/*.m", |
| 177 | rx_library_path + "/transformations/*.m", |
| 178 | ]), |
| 179 | includes = [objc_path], |
| 180 | deps = [ |
| 181 | ":rx_library_private", |
| 182 | ], |
| 183 | ) |
| 184 | |
| 185 | objc_library( |
| 186 | name = "rx_library_private", |
| 187 | hdrs = glob([rx_library_path + "/private/*.h"]), |
| 188 | srcs = glob([rx_library_path + "/private/*.m"]), |
| 189 | visibility = ["//visibility:private"], |
| 190 | ) |
| 191 | |
| 192 | objc_client_path = objc_path + "/GRPCClient" |
| 193 | |
| 194 | objc_library( |
| 195 | name = "grpc_client", |
| 196 | hdrs = glob([ |
| 197 | objc_client_path + "/*.h", |
| 198 | objc_client_path + "/private/*.h", |
| 199 | ]), |
| 200 | srcs = glob([ |
| 201 | objc_client_path + "/*.m", |
| 202 | objc_client_path + "/private/*.m", |
| 203 | ]), |
| 204 | includes = [objc_path], |
| 205 | bundles = [":gRPCCertificates"], |
| 206 | deps = [ |
| 207 | ":grpc_objc", |
| 208 | ":rx_library", |
| 209 | ], |
| 210 | ) |
| 211 | |
| 212 | objc_bundle_library( |
| 213 | # The choice of name is signicant here, since it determines the bundle name. |
| 214 | name = "gRPCCertificates", |
| 215 | resources = ["etc/roots.pem"], |
| 216 | ) |
| 217 | |
| 218 | proto_objc_rpc_path = objc_path + "/ProtoRPC" |
| 219 | |
| 220 | objc_library( |
| 221 | name = "proto_objc_rpc", |
| 222 | hdrs = glob([ |
| 223 | proto_objc_rpc_path + "/*.h", |
| 224 | ]), |
| 225 | srcs = glob([ |
| 226 | proto_objc_rpc_path + "/*.m", |
| 227 | ]), |
| 228 | includes = [objc_path], |
| 229 | deps = [ |
| 230 | ":grpc_client", |
| 231 | ":rx_library", |
| 232 | "//external:protobuf_objc", |
| 233 | ], |
| 234 | ) |