Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 1 | # GRPC Bazel BUILD file. |
Jorge Canizales | 3beb240 | 2015-07-02 01:30:33 -0700 | [diff] [blame] | 2 | # This currently builds C, C++ and Objective-C code. |
Nicolas "Pixel" Noble | d49893d | 2015-04-21 04:57:45 +0200 | [diff] [blame] | 3 | # This file has been automatically generated from a template file. |
| 4 | # Please look at the templates directory instead. |
murgatroid99 | c241d2c | 2015-06-22 11:19:57 -0700 | [diff] [blame] | 5 | # This file can be regenerated from the template by running |
| 6 | # tools/buildgen/generate_projects.sh |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 7 | |
| 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 | |
| 37 | licenses(["notice"]) # 3-clause BSD |
| 38 | |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 39 | package(default_visibility = ["//visibility:public"]) |
| 40 | |
| 41 | <%! |
| 42 | def 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" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 60 | % for lib in libs: |
Yang Gao | 736bd65 | 2015-04-16 15:42:42 -0700 | [diff] [blame] | 61 | % if lib.build in ("all", "protoc"): |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 62 | ${cc_library(lib)} |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 63 | % endif |
| 64 | % endfor |
| 65 | |
Jorge Canizales | 140bca8 | 2015-06-20 09:47:00 -0700 | [diff] [blame] | 66 | % for lib in libs: |
Jorge Canizales | 7b1a0ca | 2015-06-26 21:49:42 -0700 | [diff] [blame] | 67 | % if lib.name in ("grpc", "gpr"): |
Jorge Canizales | 140bca8 | 2015-06-20 09:47:00 -0700 | [diff] [blame] | 68 | ${objc_library(lib)} |
| 69 | % endif |
| 70 | % endfor |
| 71 | |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 72 | % for tgt in targets: |
| 73 | % if tgt.build == 'protoc': |
| 74 | ${cc_binary(tgt)} |
| 75 | % endif |
| 76 | % endfor |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 77 | |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 78 | <%def name="cc_library(lib)"> |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 79 | cc_library( |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 80 | name = "${lib.name}", |
| 81 | srcs = [ |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 82 | % for hdr in lib.get("headers", []): |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 83 | "${hdr}", |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 84 | % endfor |
| 85 | % for src in lib.src: |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 86 | "${src}", |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 87 | % endfor |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 88 | ], |
| 89 | hdrs = [ |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 90 | % for hdr in lib.get("public_headers", []): |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 91 | "${hdr}", |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 92 | % endfor |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 93 | ], |
| 94 | includes = [ |
| 95 | "include", |
| 96 | ".", |
| 97 | ], |
| 98 | deps = [ |
| 99 | % for dep in get_deps(lib): |
| 100 | "${dep}", |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 101 | % endfor |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 102 | ], |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 103 | ) |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 104 | </%def> |
Nicolas "Pixel" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 105 | |
Jorge Canizales | 140bca8 | 2015-06-20 09:47:00 -0700 | [diff] [blame] | 106 | <%def name="objc_library(lib)"> |
| 107 | objc_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 Canizales | 4dc4e3d | 2015-06-26 22:12:02 -0700 | [diff] [blame] | 130 | % if lib.get('secure', 'no') == 'yes': |
| 131 | "//external:libssl_objc", |
| 132 | % endif |
Jorge Canizales | 140bca8 | 2015-06-20 09:47:00 -0700 | [diff] [blame] | 133 | ], |
Jorge Canizales | 8c1fd04 | 2015-06-22 19:11:36 -0700 | [diff] [blame] | 134 | % if lib.get("baselib", false): |
| 135 | sdk_dylibs = ["libz"], |
| 136 | % endif |
Jorge Canizales | 140bca8 | 2015-06-20 09:47:00 -0700 | [diff] [blame] | 137 | ) |
| 138 | </%def> |
| 139 | |
Ming Zhao | 3c0ba0c | 2015-04-10 12:05:22 -0700 | [diff] [blame] | 140 | <%def name="cc_binary(tgt)"> |
| 141 | cc_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" Noble | f6edf68 | 2015-03-31 05:17:34 +0200 | [diff] [blame] | 154 | </%def> |
Jorge Canizales | 44dc423 | 2015-06-19 16:30:31 -0700 | [diff] [blame] | 155 | |
| 156 | objc_path = "src/objective-c" |
| 157 | |
| 158 | rx_library_path = objc_path + "/RxLibrary" |
| 159 | |
| 160 | objc_library( |
Jorge Canizales | bba8076 | 2015-06-26 23:25:48 -0700 | [diff] [blame] | 161 | 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 Canizales | 44dc423 | 2015-06-19 16:30:31 -0700 | [diff] [blame] | 174 | ) |
| 175 | |
| 176 | objc_library( |
Jorge Canizales | bba8076 | 2015-06-26 23:25:48 -0700 | [diff] [blame] | 177 | 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 Canizales | 44dc423 | 2015-06-19 16:30:31 -0700 | [diff] [blame] | 181 | ) |
Jorge Canizales | 866255e | 2015-06-20 18:58:38 -0700 | [diff] [blame] | 182 | |
| 183 | objc_client_path = objc_path + "/GRPCClient" |
| 184 | |
| 185 | objc_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 Canizales | bb54ae8 | 2015-06-28 06:50:58 -0700 | [diff] [blame] | 196 | bundles = [":gRPCCertificates"], |
Jorge Canizales | 866255e | 2015-06-20 18:58:38 -0700 | [diff] [blame] | 197 | deps = [ |
| 198 | ":grpc_objc", |
| 199 | ":rx_library", |
| 200 | ], |
| 201 | ) |
Jorge Canizales | bb54ae8 | 2015-06-28 06:50:58 -0700 | [diff] [blame] | 202 | |
| 203 | objc_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 Canizales | 50f1982 | 2015-06-28 23:48:30 -0700 | [diff] [blame] | 208 | |
| 209 | proto_objc_rpc_path = objc_path + "/ProtoRPC" |
| 210 | |
| 211 | objc_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 | ) |