1# Copyright (c) 2009-2021, Google LLC 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are met: 6# * Redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer. 8# * Redistributions in binary form must reproduce the above copyright 9# notice, this list of conditions and the following disclaimer in the 10# documentation and/or other materials provided with the distribution. 11# * Neither the name of Google LLC nor the 12# names of its contributors may be used to endorse or promote products 13# derived from this software without specific prior written permission. 14# 15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY 19# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 26load( 27 "//bazel:build_defs.bzl", 28 "UPB_DEFAULT_COPTS", 29 "UPB_DEFAULT_CPPOPTS", 30) 31load( 32 "//bazel:upb_proto_library.bzl", 33 "upb_proto_library", 34 "upb_proto_reflection_library", 35) 36load( 37 "//upbc:bootstrap_compiler.bzl", 38 "bootstrap_cc_binary", 39 "bootstrap_cc_library", 40 "bootstrap_upb_proto_library", 41) 42 43licenses(["notice"]) 44 45proto_library( 46 name = "code_generator_request", 47 srcs = ["code_generator_request.proto"], 48 visibility = ["//:friends"], 49 deps = ["@com_google_protobuf//:compiler_plugin_proto"], 50) 51 52upb_proto_library( 53 name = "code_generator_request_upb_proto", 54 visibility = ["//:friends"], 55 deps = [":code_generator_request"], 56) 57 58upb_proto_reflection_library( 59 name = "code_generator_request_upb_proto_reflection", 60 visibility = ["//:friends"], 61 deps = [":code_generator_request"], 62) 63 64bootstrap_upb_proto_library( 65 name = "plugin_upb_proto", 66 base_dir = "", 67 google3_src_files = [ 68 "net/proto2/compiler/proto/plugin.proto", 69 "net/proto2/compiler/proto/profile.proto", 70 ], 71 google3_src_rules = [ 72 "//net/proto2/proto:descriptor_proto_source", 73 "//net/proto2/compiler/proto:plugin.proto", 74 "//net/proto2/compiler/proto:profile.proto", 75 ], 76 oss_src_files = ["google/protobuf/compiler/plugin.proto"], 77 oss_src_rules = [ 78 "@com_google_protobuf//:descriptor_proto_srcs", 79 "@com_google_protobuf//src/google/protobuf/compiler:plugin_proto_src", 80 ], 81 oss_strip_prefix = "third_party/protobuf/github/bootstrap/src", 82 proto_lib_deps = ["@com_google_protobuf//:compiler_plugin_proto"], 83 visibility = ["//:friends"], 84 deps = ["//:descriptor_upb_proto"], 85) 86 87upb_proto_reflection_library( 88 name = "plugin_upb_proto_reflection", 89 visibility = ["//:friends"], 90 deps = ["@com_google_protobuf//:compiler_plugin_proto"], 91) 92 93cc_binary( 94 name = "upbc_so", 95 srcs = ["upbc_so.c"], 96 copts = UPB_DEFAULT_COPTS, 97 linkshared = 1, 98 linkstatic = 1, 99 visibility = ["//visibility:public"], 100 deps = [ 101 "//:collections", 102 "//:mem", 103 "//:message", 104 "//:message_accessors", 105 "//:mini_table", 106 "//:port", 107 "//upbc:upbdev", 108 ], 109) 110 111bootstrap_cc_library( 112 name = "common", 113 srcs = [ 114 "common.cc", 115 ], 116 hdrs = [ 117 "common.h", 118 ], 119 bootstrap_deps = [ 120 "//:reflection", 121 ], 122 copts = UPB_DEFAULT_CPPOPTS, 123 visibility = ["//protos_generator:__pkg__"], 124 deps = [ 125 "@com_google_absl//absl/strings", 126 ], 127) 128 129bootstrap_cc_library( 130 name = "file_layout", 131 srcs = [ 132 "file_layout.cc", 133 ], 134 hdrs = [ 135 "file_layout.h", 136 ], 137 bootstrap_deps = [ 138 ":common", 139 "//:reflection", 140 "//:descriptor_upb_proto", 141 ], 142 copts = UPB_DEFAULT_CPPOPTS, 143 visibility = ["//protos_generator:__pkg__"], 144 deps = [ 145 "//:mini_table", 146 "//:mini_table_internal", 147 "//:port", 148 "//:upb", 149 "@com_google_absl//absl/container:flat_hash_map", 150 "@com_google_absl//absl/strings", 151 ], 152) 153 154cc_library( 155 name = "keywords", 156 srcs = [ 157 "keywords.cc", 158 ], 159 hdrs = [ 160 "keywords.h", 161 ], 162 copts = UPB_DEFAULT_CPPOPTS, 163 visibility = ["//protos_generator:__pkg__"], 164) 165 166bootstrap_cc_library( 167 name = "plugin", 168 hdrs = [ 169 "plugin.h", 170 ], 171 bootstrap_deps = [ 172 ":plugin_upb_proto", 173 "//:descriptor_upb_proto", 174 "//:reflection", 175 ], 176 copts = UPB_DEFAULT_CPPOPTS, 177 visibility = ["//protos_generator:__pkg__"], 178 deps = [ 179 "//:port", 180 "@com_google_absl//absl/container:flat_hash_set", 181 "@com_google_absl//absl/log:absl_check", 182 "@com_google_absl//absl/log:absl_log", 183 "@com_google_absl//absl/strings", 184 ], 185) 186 187bootstrap_cc_library( 188 name = "names", 189 srcs = [ 190 "names.cc", 191 ], 192 hdrs = [ 193 "names.h", 194 ], 195 bootstrap_deps = [ 196 "//:reflection", 197 ], 198 copts = UPB_DEFAULT_CPPOPTS, 199 visibility = ["//protos_generator:__pkg__"], 200 deps = [ 201 "@com_google_absl//absl/base:core_headers", 202 "@com_google_absl//absl/container:flat_hash_map", 203 "@com_google_absl//absl/strings", 204 "@com_google_protobuf//:protobuf", 205 "@com_google_protobuf//src/google/protobuf/compiler:code_generator", 206 ], 207) 208 209cc_library( 210 name = "upbdev", 211 srcs = [ 212 "code_generator_request.c", 213 "code_generator_request.h", 214 "upbdev.c", 215 ], 216 hdrs = [ 217 "upbdev.h", 218 ], 219 copts = UPB_DEFAULT_COPTS, 220 visibility = ["//visibility:public"], 221 deps = [ 222 ":code_generator_request_upb_proto", 223 ":code_generator_request_upb_proto_reflection", 224 ":plugin_upb_proto", 225 ":plugin_upb_proto_reflection", 226 "//:base", 227 "//:json", 228 "//:mem", 229 "//:mini_table", 230 "//:port", 231 "//:reflection", 232 ], 233) 234 235bootstrap_cc_binary( 236 name = "protoc-gen-upb", 237 srcs = ["protoc-gen-upb.cc"], 238 bootstrap_deps = [ 239 ":common", 240 ":file_layout", 241 ":names", 242 ":plugin", 243 ":plugin_upb_proto", 244 "//:descriptor_upb_proto", 245 "//:reflection", 246 ], 247 copts = UPB_DEFAULT_CPPOPTS, 248 visibility = ["//visibility:public"], 249 deps = [ 250 "//:base", 251 "//:mem", 252 "//:mini_table_internal", 253 "//:port", 254 "//:wire_types", 255 "@com_google_absl//absl/container:flat_hash_map", 256 "@com_google_absl//absl/container:flat_hash_set", 257 "@com_google_absl//absl/log:absl_check", 258 "@com_google_absl//absl/log:absl_log", 259 "@com_google_absl//absl/strings", 260 ], 261) 262 263cc_binary( 264 name = "protoc-gen-upbdefs", 265 srcs = [ 266 "protoc-gen-upbdefs.cc", 267 ], 268 copts = UPB_DEFAULT_CPPOPTS, 269 # To work around the following link error from ABSL: 270 # /usr/bin/x86_64-linux-gnu-ld: bazel-out/k8-opt-exec-2B5CBBC6-ST-c1776f9924ec/bin/external/com_google_absl/absl/time/libtime.a(duration.o): undefined reference to symbol 'floor@@GLIBC_2.2.5' 271 # /usr/bin/x86_64-linux-gnu-ld: /opt/manylinux/2014/x86_64/lib64/libm.so.6: error adding symbols: DSO missing from command line 272 # clang-14: error: linker command failed with exit code 1 (use -v to see invocation) 273 linkopts = ["-lm"], 274 visibility = ["//visibility:public"], 275 deps = [ 276 ":common", 277 ":file_layout", 278 ":plugin", 279 "//:descriptor_upb_proto", 280 "//:reflection", 281 "//upb/util:def_to_proto", 282 ], 283) 284 285cc_binary( 286 name = "protoc-gen-upbdev", 287 srcs = [ 288 "protoc-gen-upbdev.cc", 289 "subprocess.cc", 290 "subprocess.h", 291 ], 292 copts = UPB_DEFAULT_CPPOPTS, 293 target_compatible_with = select({ 294 "@platforms//os:windows": ["@platforms//:incompatible"], 295 "//conditions:default": [], 296 }), 297 visibility = ["//visibility:public"], 298 deps = [ 299 ":plugin_upb_proto", 300 ":upbdev", 301 "//:port", 302 "@com_google_absl//absl/log:absl_log", 303 "@com_google_absl//absl/strings", 304 ], 305) 306