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( 9 "//bazel:upb_minitable_proto_library.bzl", 10 "upb_minitable_proto_library", 11) 12load( 13 "//bazel:upb_proto_library.bzl", 14 "upb_c_proto_library", 15 "upb_proto_reflection_library", 16) 17load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_COPTS") 18 19package(default_applicable_licenses = ["//:license"]) 20 21cc_library( 22 name = "message", 23 srcs = [ 24 "accessors.c", 25 "array.c", 26 "compat.c", 27 "map.c", 28 "map_sorter.c", 29 "message.c", 30 ], 31 hdrs = [ 32 "accessors.h", 33 "array.h", 34 "compat.h", 35 "map.h", 36 "map_gencode_util.h", 37 "message.h", 38 "tagged_ptr.h", 39 "value.h", 40 ], 41 copts = UPB_DEFAULT_COPTS, 42 visibility = ["//visibility:public"], 43 deps = [ 44 ":internal", 45 ":types", 46 "//upb:base", 47 "//upb:mem", 48 "//upb:mini_table", 49 "//upb:port", 50 "//upb/base:internal", 51 "//upb/hash", 52 "//upb/mini_table:internal", 53 ], 54) 55 56cc_library( 57 name = "internal", 58 srcs = [ 59 "internal/compare_unknown.c", 60 "internal/extension.c", 61 "internal/message.c", 62 "value.h", 63 ], 64 hdrs = [ 65 "internal/accessors.h", 66 "internal/array.h", 67 "internal/compare_unknown.h", 68 "internal/extension.h", 69 "internal/map.h", 70 "internal/map_sorter.h", 71 "internal/message.h", 72 "internal/tagged_ptr.h", 73 ], 74 copts = UPB_DEFAULT_COPTS, 75 visibility = ["//visibility:public"], 76 deps = [ 77 ":types", 78 "//upb:base", 79 "//upb:eps_copy_input_stream", 80 "//upb:mem", 81 "//upb:mini_table", 82 "//upb:port", 83 "//upb:wire_reader", 84 "//upb/base:internal", 85 "//upb/hash", 86 "//upb/mini_table:internal", 87 ], 88) 89 90cc_library( 91 name = "iterator", 92 srcs = [ 93 "internal/iterator.c", 94 ], 95 hdrs = [ 96 "internal/iterator.h", 97 ], 98 copts = UPB_DEFAULT_COPTS, 99 visibility = ["//visibility:public"], 100 deps = [ 101 ":internal", 102 ":message", 103 "//upb:mini_table", 104 "//upb:port", 105 ], 106) 107 108cc_library( 109 name = "compare", 110 srcs = [ 111 "compare.c", 112 ], 113 hdrs = [ 114 "compare.h", 115 ], 116 copts = UPB_DEFAULT_COPTS, 117 visibility = ["//visibility:public"], 118 deps = [ 119 ":internal", 120 ":iterator", 121 ":message", 122 "//upb:base", 123 "//upb:mini_table", 124 "//upb:port", 125 "//upb/mini_table:internal", 126 ], 127) 128 129cc_library( 130 name = "copy", 131 srcs = [ 132 "copy.c", 133 "merge.c", 134 ], 135 hdrs = [ 136 "copy.h", 137 "merge.h", 138 ], 139 copts = UPB_DEFAULT_COPTS, 140 visibility = ["//visibility:public"], 141 deps = [ 142 ":internal", 143 ":message", 144 "//upb:base", 145 "//upb:mem", 146 "//upb:mini_table", 147 "//upb:port", 148 "//upb:wire", 149 "//upb/base:internal", 150 "//upb/mini_table:internal", 151 ], 152) 153 154cc_library( 155 name = "promote", 156 srcs = [ 157 "promote.c", 158 ], 159 hdrs = [ 160 "promote.h", 161 ], 162 copts = UPB_DEFAULT_COPTS, 163 visibility = ["//visibility:public"], 164 deps = [ 165 ":internal", 166 ":message", 167 "//upb:base", 168 "//upb:eps_copy_input_stream", 169 "//upb:mem", 170 "//upb:mini_table", 171 "//upb:port", 172 "//upb:wire", 173 "//upb:wire_reader", 174 ], 175) 176 177cc_test( 178 name = "merge_test", 179 srcs = ["merge_test.cc"], 180 deps = [ 181 ":copy", 182 ":internal", 183 "//upb:base", 184 "//upb:mem", 185 "//upb:message", 186 "//upb:mini_table", 187 "//upb:port", 188 "//upb:wire", 189 "//upb/test:test_messages_proto2_upb_minitable", 190 "//upb/test:test_messages_proto2_upb_proto", 191 "//upb/test:test_upb_proto", 192 "@com_google_googletest//:gtest", 193 "@com_google_googletest//:gtest_main", 194 ], 195) 196 197cc_library( 198 name = "split64", 199 hdrs = [ 200 "accessors_split64.h", 201 ], 202 copts = UPB_DEFAULT_COPTS, 203 visibility = ["//visibility:public"], 204 deps = [ 205 ":message", 206 "//upb:port", 207 ], 208) 209 210cc_library( 211 name = "types", 212 hdrs = [ 213 "internal/map_entry.h", 214 "internal/types.h", 215 ], 216 copts = UPB_DEFAULT_COPTS, 217 visibility = ["//visibility:public"], 218 deps = [ 219 "//upb:base", 220 "//upb:port", 221 "//upb/hash", 222 ], 223) 224 225proto_library( 226 name = "message_test_proto", 227 testonly = 1, 228 srcs = ["test.proto"], 229 deps = ["//src/google/protobuf:test_messages_proto3_proto"], 230) 231 232upb_minitable_proto_library( 233 name = "message_test_upb_minitable_proto", 234 testonly = 1, 235 deps = [":message_test_proto"], 236) 237 238upb_c_proto_library( 239 name = "message_test_upb_proto", 240 testonly = 1, 241 deps = [":message_test_proto"], 242) 243 244upb_proto_reflection_library( 245 name = "message_test_upb_proto_reflection", 246 testonly = 1, 247 deps = [":message_test_proto"], 248) 249 250cc_test( 251 name = "accessors_test", 252 srcs = ["accessors_test.cc"], 253 deps = [ 254 ":message", 255 "//:protobuf", 256 "//upb:base", 257 "//upb:mem", 258 "//upb:mini_descriptor", 259 "//upb:mini_table", 260 "//upb:port", 261 "//upb:wire", 262 "//upb/mini_descriptor:internal", 263 "//upb/test:test_messages_proto2_upb_minitable", 264 "//upb/test:test_messages_proto2_upb_proto", 265 "//upb/test:test_messages_proto3_upb_minitable", 266 "//upb/test:test_messages_proto3_upb_proto", 267 "//upb/test:test_upb_proto", 268 "@com_google_absl//absl/container:flat_hash_set", 269 "@com_google_googletest//:gtest", 270 "@com_google_googletest//:gtest_main", 271 ], 272) 273 274cc_test( 275 name = "array_test", 276 srcs = ["array_test.cc"], 277 deps = [ 278 ":message", 279 "//upb:base", 280 "//upb:mem", 281 "@com_google_googletest//:gtest", 282 "@com_google_googletest//:gtest_main", 283 ], 284) 285 286cc_test( 287 name = "compare_unknown_test", 288 srcs = ["internal/compare_unknown_test.cc"], 289 deps = [ 290 ":internal", 291 "//upb:port", 292 "//upb:wire_reader", 293 "//upb/base:internal", 294 "@com_google_absl//absl/types:variant", 295 "@com_google_googletest//:gtest", 296 "@com_google_googletest//:gtest_main", 297 ], 298) 299 300cc_test( 301 name = "copy_test", 302 srcs = ["copy_test.cc"], 303 deps = [ 304 ":copy", 305 ":internal", 306 ":message", 307 "//:protobuf", 308 "//upb:base", 309 "//upb:mem", 310 "//upb:mini_table", 311 "//upb:port", 312 "//upb:wire", 313 "//upb/test:test_messages_proto2_upb_minitable", 314 "//upb/test:test_messages_proto2_upb_proto", 315 "//upb/test:test_upb_proto", 316 "@com_google_absl//absl/container:flat_hash_set", 317 "@com_google_googletest//:gtest", 318 "@com_google_googletest//:gtest_main", 319 ], 320) 321 322cc_test( 323 name = "map_test", 324 srcs = ["map_test.cc"], 325 deps = [ 326 ":message", 327 "//upb:base", 328 "//upb:mem", 329 "@com_google_googletest//:gtest", 330 "@com_google_googletest//:gtest_main", 331 ], 332) 333 334cc_test( 335 name = "promote_test", 336 srcs = ["promote_test.cc"], 337 deps = [ 338 ":copy", 339 ":internal", 340 ":message", 341 ":promote", 342 "//:protobuf", 343 "//upb:base", 344 "//upb:mem", 345 "//upb:mini_descriptor", 346 "//upb:mini_table", 347 "//upb:wire", 348 "//upb/mini_descriptor:internal", 349 "//upb/test:test_messages_proto2_upb_proto", 350 "//upb/test:test_messages_proto3_upb_proto", 351 "//upb/test:test_proto_upb_minitable", 352 "//upb/test:test_upb_proto", 353 "@com_google_absl//absl/container:flat_hash_set", 354 "@com_google_googletest//:gtest", 355 "@com_google_googletest//:gtest_main", 356 ], 357) 358 359# This test doesn't directly include any files from this subdir so it probably 360# should live elsewhere. 361cc_test( 362 name = "test", 363 srcs = ["test.cc"], 364 deps = [ 365 ":internal", 366 ":message", 367 ":message_test_upb_minitable_proto", 368 ":message_test_upb_proto", 369 ":message_test_upb_proto_reflection", 370 "//upb:base", 371 "//upb:json", 372 "//upb:mem", 373 "//upb:mini_table", 374 "//upb:reflection", 375 "//upb:wire", 376 "//upb/test:fuzz_util", 377 "//upb/test:test_messages_proto3_upb_proto", 378 "@com_google_googletest//:gtest", 379 "@com_google_googletest//:gtest_main", 380 ], 381) 382 383proto_library( 384 name = "utf8_test_proto", 385 testonly = 1, 386 srcs = ["utf8_test.proto"], 387) 388 389proto_library( 390 name = "utf8_test_proto2_proto", 391 testonly = 1, 392 srcs = ["utf8_test_proto2.proto"], 393) 394 395upb_minitable_proto_library( 396 name = "utf8_test_upb_minitable_proto", 397 testonly = 1, 398 deps = [":utf8_test_proto"], 399) 400 401upb_minitable_proto_library( 402 name = "utf8_test_proto2_upb_minitable_proto", 403 testonly = 1, 404 deps = [":utf8_test_proto2_proto"], 405) 406 407upb_c_proto_library( 408 name = "utf8_test_upb_proto", 409 testonly = 1, 410 deps = [":utf8_test_proto"], 411) 412 413upb_c_proto_library( 414 name = "utf8_test_proto2_upb_proto", 415 testonly = 1, 416 deps = [":utf8_test_proto2_proto"], 417) 418 419cc_test( 420 name = "utf8_test", 421 srcs = ["utf8_test.cc"], 422 deps = [ 423 ":utf8_test_proto2_upb_minitable_proto", 424 ":utf8_test_proto2_upb_proto", 425 ":utf8_test_upb_minitable_proto", 426 ":utf8_test_upb_proto", 427 "//upb:base", 428 "//upb:mem", 429 "//upb:wire", 430 "@com_google_googletest//:gtest", 431 "@com_google_googletest//:gtest_main", 432 ], 433) 434 435filegroup( 436 name = "source_files", 437 srcs = glob( 438 [ 439 "**/*.c", 440 "**/*.h", 441 ], 442 ), 443 visibility = [ 444 "//python/dist:__pkg__", 445 "//upb/cmake:__pkg__", 446 ], 447) 448 449filegroup( 450 name = "test_srcs", 451 srcs = glob( 452 [ 453 "**/*test.cc", 454 ], 455 exclude = ["promote_test.cc"], 456 ), 457 visibility = ["//upb:__pkg__"], 458) 459 460filegroup( 461 name = "test_protos", 462 srcs = glob( 463 [ 464 "**/*.proto", 465 ], 466 ), 467 visibility = ["//upb:__pkg__"], 468) 469