1# Copyright (c) 2009-2021, Google LLC 2# All rights reserved. 3# 4# Use of this source code is governed by a BSD-style 5# license that can be found in the LICENSE file or at 6# https://developers.google.com/open-source/licenses/bsd 7 8load("@bazel_skylib//rules:common_settings.bzl", "bool_flag") 9load("@rules_python//python:defs.bzl", "py_binary") 10load("//bazel/private:upb_proto_library_internal/copts.bzl", "upb_proto_library_copts") 11load( 12 "//upb/bazel:amalgamation.bzl", 13 "upb_amalgamation", 14) 15load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_COPTS") 16 17package(default_applicable_licenses = ["//:license"]) 18 19licenses(["notice"]) 20 21exports_files(["LICENSE"]) 22 23exports_files( 24 [ 25 "BUILD", 26 "WORKSPACE", 27 ], 28 visibility = ["//upb/cmake:__pkg__"], 29) 30 31config_setting( 32 name = "windows", 33 constraint_values = ["@platforms//os:windows"], 34 visibility = ["//visibility:public"], 35) 36 37bool_flag( 38 name = "fasttable_enabled", 39 build_setting_default = False, 40 visibility = ["//visibility:public"], 41) 42 43config_setting( 44 name = "fasttable_enabled_setting", 45 flag_values = {"//upb:fasttable_enabled": "true"}, 46 visibility = ["//visibility:public"], 47) 48 49upb_proto_library_copts( 50 name = "upb_proto_library_copts__for_generated_code_only_do_not_use", 51 copts = UPB_DEFAULT_COPTS, 52 visibility = ["//visibility:public"], 53) 54 55# Please update copy.bara.sky target = ":friends" if 56# you make changes to this list. 57package_group( 58 name = "friends", 59 packages = ["//..."], 60) 61 62package_group( 63 name = "friend_generators", 64 packages = ["//..."], 65) 66 67# Common support routines used by generated code. This library has no 68# implementation, but depends on :upb and exposes a few more hdrs. 69# 70# This is public only because we have no way of visibility-limiting it to 71# upb_c_proto_library() only. This interface is not stable and by using it you 72# give up any backward compatibility guarantees. 73cc_library( 74 name = "generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", 75 hdrs = ["generated_code_support.h"], 76 copts = UPB_DEFAULT_COPTS, 77 textual_hdrs = [ 78 ":port_inc", 79 ], 80 visibility = ["//visibility:public"], 81 deps = [ 82 ":base", 83 ":mem", 84 ":message", 85 ":mini_descriptor", 86 ":mini_table", 87 ":wire", 88 "//upb/message:internal", 89 ], 90) 91 92# Common support code for C++ generated code. 93cc_library( 94 name = "generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", 95 copts = UPB_DEFAULT_COPTS, 96 textual_hdrs = [ 97 ":port_inc", 98 ], 99 visibility = ["//visibility:public"], 100) 101 102# Aliases ###################################################################### 103# TODO: Remove these. 104 105alias( 106 name = "base", 107 actual = "//upb/base", 108 visibility = ["//visibility:public"], 109) 110 111alias( 112 name = "generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", 113 actual = "//upb/reflection:generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", 114 visibility = ["//visibility:public"], 115) 116 117alias( 118 name = "json", 119 actual = "//upb/json", 120 visibility = ["//visibility:public"], 121) 122 123alias( 124 name = "mem", 125 actual = "//upb/mem", 126 visibility = ["//visibility:public"], 127) 128 129alias( 130 name = "message", 131 actual = "//upb/message", 132 visibility = ["//visibility:public"], 133) 134 135alias( 136 name = "message_compare", 137 actual = "//upb/message:compare", 138 visibility = ["//upb:friends"], 139) 140 141alias( 142 name = "message_copy", 143 actual = "//upb/message:copy", 144 visibility = ["//visibility:public"], 145) 146 147alias( 148 name = "message_promote", 149 actual = "//upb/message:promote", 150 visibility = ["//visibility:public"], 151) 152 153alias( 154 name = "message_split64", 155 actual = "//upb/message:split64", 156 visibility = ["//visibility:public"], 157) 158 159alias( 160 name = "mini_descriptor", 161 actual = "//upb/mini_descriptor", 162 visibility = ["//visibility:public"], 163) 164 165alias( 166 name = "mini_table", 167 actual = "//upb/mini_table", 168 visibility = ["//upb:friends"], 169) 170 171alias( 172 name = "mini_table_compat", 173 actual = "//upb/mini_table:compat", 174 visibility = ["//upb:friends"], 175) 176 177alias( 178 name = "port", 179 actual = "//upb/port", 180 visibility = ["//visibility:public"], 181) 182 183alias( 184 name = "port_inc", 185 actual = "//upb/port:inc", 186 visibility = ["//visibility:public"], 187) 188 189alias( 190 name = "reflection", 191 actual = "//upb/reflection", 192 visibility = ["//visibility:public"], 193) 194 195alias( 196 name = "text", 197 actual = "//upb/text", 198 visibility = ["//visibility:public"], 199) 200 201alias( 202 name = "wire", 203 actual = "//upb/wire", 204 visibility = ["//visibility:public"], 205) 206 207alias( 208 name = "wire_reader", 209 actual = "//upb/wire:reader", 210 visibility = ["//visibility:public"], 211) 212 213alias( 214 name = "eps_copy_input_stream", 215 actual = "//upb/wire:eps_copy_input_stream", 216 visibility = ["//visibility:public"], 217) 218 219# Amalgamation ################################################################# 220 221upb_amalgamation( 222 name = "gen_amalgamation", 223 outs = [ 224 "upb.c", 225 "upb.h", 226 ], 227 libs = [ 228 ":base", 229 ":eps_copy_input_stream", 230 ":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", 231 ":mem", 232 ":message", 233 ":message_compare", 234 ":message_copy", 235 ":mini_descriptor", 236 ":mini_table", 237 ":mini_table_compat", 238 ":port", 239 ":reflection", 240 ":wire", 241 ":wire_reader", 242 "//src/google/protobuf:descriptor_upb_c_proto", 243 "//src/google/protobuf:descriptor_upb_minitable_proto", 244 "//upb/base:internal", 245 "//upb/hash:hash", 246 "//upb/lex:lex", 247 "//upb/mem:internal", 248 "//upb/message:internal", 249 "//upb/message:iterator", 250 "//upb/message:types", 251 "//upb/mini_descriptor:internal", 252 "//upb/mini_table:internal", 253 "//upb/reflection:descriptor_upb_proto", 254 "//upb/reflection:internal", 255 "//upb/text:debug", 256 "//upb/text:internal", 257 ], 258 strip_import_prefix = ["src"], 259 visibility = ["//rust:__pkg__"], 260) 261 262cc_library( 263 name = "amalgamation", 264 srcs = ["upb.c"], 265 hdrs = ["upb.h"], 266 copts = UPB_DEFAULT_COPTS, 267 deps = ["//third_party/utf8_range"], 268) 269 270upb_amalgamation( 271 name = "gen_php_amalgamation", 272 outs = [ 273 "php-upb.c", 274 "php-upb.h", 275 ], 276 libs = [ 277 ":base", 278 ":eps_copy_input_stream", 279 ":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", 280 ":json", 281 ":mem", 282 ":message", 283 ":message_compare", 284 ":message_copy", 285 ":mini_descriptor", 286 ":mini_table", 287 ":mini_table_compat", 288 ":port", 289 ":reflection", 290 ":wire", 291 ":wire_reader", 292 "//src/google/protobuf:descriptor_upb_c_proto", 293 "//src/google/protobuf:descriptor_upb_minitable_proto", 294 "//src/google/protobuf:descriptor_upb_reflection_proto", 295 "//upb/base:internal", 296 "//upb/hash:hash", 297 "//upb/lex:lex", 298 "//upb/mem:internal", 299 "//upb/message:internal", 300 "//upb/message:iterator", 301 "//upb/message:types", 302 "//upb/mini_descriptor:internal", 303 "//upb/mini_table:internal", 304 "//upb/reflection:descriptor_upb_proto", 305 "//upb/reflection:internal", 306 ], 307 prefix = "php-", 308 strip_import_prefix = ["src"], 309 visibility = ["@com_google_protobuf//php:__subpackages__"], 310) 311 312cc_library( 313 name = "php_amalgamation", 314 srcs = ["php-upb.c"], 315 hdrs = ["php-upb.h"], 316 copts = UPB_DEFAULT_COPTS, 317 deps = ["//third_party/utf8_range"], 318) 319 320upb_amalgamation( 321 name = "gen_ruby_amalgamation", 322 outs = [ 323 "ruby-upb.c", 324 "ruby-upb.h", 325 ], 326 libs = [ 327 ":base", 328 ":eps_copy_input_stream", 329 ":generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", 330 ":json", 331 ":mem", 332 ":message", 333 ":message_compare", 334 ":message_copy", 335 ":mini_descriptor", 336 ":mini_table", 337 ":mini_table_compat", 338 ":port", 339 ":reflection", 340 ":wire", 341 ":wire_reader", 342 "//src/google/protobuf:descriptor_upb_c_proto", 343 "//src/google/protobuf:descriptor_upb_minitable_proto", 344 "//upb/base:internal", 345 "//upb/hash:hash", 346 "//upb/lex:lex", 347 "//upb/mem:internal", 348 "//upb/message:internal", 349 "//upb/message:iterator", 350 "//upb/message:types", 351 "//upb/mini_descriptor:internal", 352 "//upb/mini_table:internal", 353 "//upb/reflection:descriptor_upb_proto", 354 "//upb/reflection:internal", 355 ], 356 prefix = "ruby-", 357 strip_import_prefix = ["src"], 358 visibility = ["@com_google_protobuf//ruby:__subpackages__"], 359) 360 361cc_library( 362 name = "ruby_amalgamation", 363 srcs = ["ruby-upb.c"], 364 hdrs = ["ruby-upb.h"], 365 copts = UPB_DEFAULT_COPTS, 366 deps = ["//third_party/utf8_range"], 367) 368 369exports_files( 370 [ 371 "third_party/lunit/console.lua", 372 "third_party/lunit/lunit.lua", 373 ], 374 visibility = ["//lua:__pkg__"], 375) 376 377filegroup( 378 name = "source_files", 379 srcs = glob( 380 [ 381 "**/*.h", 382 ], 383 exclude = [ 384 "**/conformance_upb.c", 385 "reflection/stage0/**/*", 386 ], 387 ), 388 visibility = [ 389 "//python/dist:__pkg__", 390 "//upb/cmake:__pkg__", 391 ], 392) 393 394filegroup( 395 name = "test_protos", 396 srcs = [ 397 "//src/google/protobuf:test_messages_proto2.proto", 398 "//src/google/protobuf:test_messages_proto3.proto", 399 "//src/google/protobuf:well_known_type_protos", 400 "//upb/json:test_protos", 401 "//upb/message:test_protos", 402 "//upb/test:test_protos", 403 "//upb/util:test_protos", 404 ], 405 visibility = ["//pkg:__pkg__"], 406) 407 408filegroup( 409 name = "test_srcs", 410 srcs = [ 411 "//upb/json:test_srcs", 412 "//upb/mem:test_srcs", 413 "//upb/message:test_srcs", 414 "//upb/test:test_srcs", 415 "//upb/util:test_srcs", 416 "//upb/wire:test_srcs", 417 ], 418 visibility = ["//pkg:__pkg__"], 419) 420 421filegroup( 422 name = "test_util", 423 srcs = [ 424 "//upb/test:test_util", 425 "//upb/util:test_util", 426 ], 427 visibility = ["//pkg:__pkg__"], 428) 429