upb: create upb/message/BUILD

PiperOrigin-RevId: 557944463
pull/13675/head^2
Eric Salo 1 year ago committed by Copybara-Service
parent f5621a975f
commit d90f74d47b
  1. 2
      .github/workflows/bazel_tests.yml
  2. 360
      BUILD
  3. 1
      cmake/BUILD.bazel
  4. 2
      protos/BUILD
  5. 1
      python/dist/BUILD.bazel
  6. 332
      upb/message/BUILD
  7. 1
      upb/test/BUILD

@ -27,7 +27,7 @@ jobs:
- { NAME: "ASAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=asan -c dbg -- -benchmarks:benchmark -python/..." }
- { NAME: "UBSAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=ubsan -c dbg -- -benchmarks:benchmark -python/... -lua/...", install: "libunwind-dev" }
- { NAME: "32-bit", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--copt=-m32 --linkopt=-m32 -- benchmarks:benchmark -python/...", install: "g++-multilib" }
- { NAME: "32-bit ASAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=asan -c dbg --copt=-m32 --linkopt=-m32 -- -//benchmarks/... -//python/... -//:message_copy_test -//:message_promote_test -//:message_test -//upb/test:test_generated_code", install: "g++-multilib" }
- { NAME: "32-bit ASAN", BAZEL: bazel, CC: clang, os: ubuntu-20-large, flags: "--config=asan -c dbg --copt=-m32 --linkopt=-m32 -- -//benchmarks/... -//python/... -//upb/message:copy_test -//upb/message:promote_test -//upb/message:test -//upb/test:test_generated_code", install: "g++-multilib" }
- { NAME: "Windows", BAZEL: bazel, os: windows-2019, startup-flags: "--output_user_root=C:/tmp", flags: "--config=cpp17_msvc", targets: "upb/... upbc/... python/... protos/... protos_generator/..." }
- { NAME: "macOS", BAZEL: bazel, CC: clang, os: macos-11 }
# Current github runners are all Intel based, so just build/compile for Apple Silicon to detect issues there.

360
BUILD

@ -26,7 +26,6 @@
load("//bazel:build_defs.bzl", "UPB_DEFAULT_COPTS")
load(
"//bazel:upb_proto_library.bzl",
"upb_proto_library",
"upb_proto_library_copts",
"upb_proto_reflection_library",
)
@ -38,10 +37,7 @@ load(
)
# begin:google_only
# load(
# "//tools/build_defs/kotlin/native:rules.bzl",
# "kt_native_interop_hint",
# )
# load("//tools/build_defs/kotlin/native:rules.bzl", "kt_native_interop_hint")
# load("//tools/build_defs/license:license.bzl", "license")
# end:google_only
@ -109,254 +105,14 @@ package_group(
cc_library(
name = "upb",
hdrs = [
"upb/message/internal/extension.h",
"upb/message/message.h",
"upb/upb.hpp",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":collections_internal",
":mem",
":message_internal",
":mini_table",
":port",
],
)
cc_library(
name = "message",
hdrs = [
"upb/message/message.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":mem",
":message_internal",
":mini_table",
":port",
],
)
cc_library(
name = "message_internal",
srcs = [
"upb/message/message.c",
],
hdrs = [
"upb/message/internal/extension.h",
"upb/message/internal/message.h",
"upb/message/message.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":base_internal",
":hash",
":mem",
":mini_table",
":port",
],
)
cc_library(
name = "message_tagged_ptr",
hdrs = ["upb/message/tagged_ptr.h"],
copts = UPB_DEFAULT_COPTS,
visibility = ["//:friends"],
deps = [
":message_typedef",
":port",
],
)
cc_library(
name = "message_accessors_internal",
hdrs = [
"upb/message/internal/accessors.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//:friends"],
deps = [
":collections_internal",
":message_internal",
":mini_table_internal",
":port",
],
)
cc_library(
name = "message_accessors",
srcs = [
"upb/message/accessors.c",
"upb/message/internal/accessors.h",
],
hdrs = [
"upb/message/accessors.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":collections_internal",
":eps_copy_input_stream",
":message_internal",
":mini_table",
":mini_table_internal",
":port",
":upb",
":wire",
":wire_internal",
":wire_reader",
],
)
cc_library(
name = "message_promote",
srcs = [
"upb/message/promote.c",
],
hdrs = [
"upb/message/promote.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":collections_internal",
":eps_copy_input_stream",
":hash",
":mem",
":message_accessors",
":message_internal",
":message_typedef",
":mini_table",
":port",
":upb",
":wire",
":wire_internal",
":wire_reader",
],
)
cc_library(
name = "message_copy",
srcs = [
"upb/message/copy.c",
],
hdrs = [
"upb/message/copy.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":collections_internal",
":mem",
":message_accessors",
":message_internal",
":message_typedef",
":mini_table",
":mini_table_internal",
":port",
":upb",
],
)
cc_library(
name = "message_split64",
hdrs = [
"upb/message/accessors_split64.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":message_accessors",
":port",
],
)
cc_library(
name = "message_typedef",
hdrs = [
"upb/message/typedef.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
)
cc_test(
name = "message_accessors_test",
srcs = ["upb/message/accessors_test.cc"],
deps = [
":base",
":collections",
":message_accessors",
":mini_descriptor",
":mini_descriptor_encode_internal",
":mini_descriptor_internal",
":mini_table",
":port",
":upb",
":wire",
":wire_internal",
"//upb/test:test_messages_proto2_upb_proto",
"//upb/test:test_messages_proto3_upb_proto",
"//upb/test:test_upb_proto",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_googletest//:gtest_main",
"@com_google_protobuf//:protobuf",
],
)
cc_test(
name = "message_promote_test",
srcs = ["upb/message/promote_test.cc"],
deps = [
":base",
":collections",
":message_accessors",
":message_copy",
":message_promote",
":mini_descriptor_encode_internal",
":mini_descriptor_internal",
":mini_table",
":port",
":upb",
":wire",
":wire_internal",
"//upb/test:test_messages_proto2_upb_proto",
"//upb/test:test_messages_proto3_upb_proto",
"//upb/test:test_upb_proto",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_googletest//:gtest_main",
"@com_google_protobuf//:protobuf",
],
)
cc_test(
name = "message_copy_test",
srcs = ["upb/message/copy_test.cc"],
deps = [
":base",
":collections",
":mem",
":message_accessors",
":message_copy",
":message_internal",
":mini_table",
":upb",
":wire",
"//upb/test:test_messages_proto2_upb_proto",
"//upb/test:test_messages_proto3_upb_proto",
"//upb/test:test_upb_proto",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_googletest//:gtest_main",
"@com_google_protobuf//:protobuf",
],
)
@ -390,10 +146,7 @@ cc_library(
# Common support code for C++ generated code.
cc_library(
name = "generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
hdrs = [
"upb/message/message.h",
"upb/upb.hpp",
],
hdrs = ["upb/upb.hpp"],
copts = UPB_DEFAULT_COPTS,
textual_hdrs = [
"//upb/port:inc",
@ -449,19 +202,6 @@ upb_proto_reflection_library(
deps = ["@com_google_protobuf//:descriptor_proto"],
)
cc_library(
name = "message_rep_internal",
hdrs = [
"upb/message/internal/map_entry.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//:__subpackages__"],
deps = [
":base",
":hash",
],
)
# TODO(b/232091617): Once we can delete the deprecated forwarding headers
# (= everything in upb/) we can move this build target down into reflection/
bootstrap_cc_library(
@ -545,6 +285,7 @@ bootstrap_cc_library(
":collections",
":hash",
":mem",
":message",
":message_accessors",
":mini_descriptor",
":mini_descriptor_encode_internal",
@ -618,6 +359,66 @@ alias(
visibility = ["//:__subpackages__"],
)
alias(
name = "message",
actual = "//upb/message",
visibility = ["//visibility:public"],
)
alias(
name = "message_accessors",
actual = "//upb/message:accessors",
visibility = ["//visibility:public"],
)
alias(
name = "message_accessors_internal",
actual = "//upb/message:accessors_internal",
visibility = ["//:friends"],
)
alias(
name = "message_copy",
actual = "//upb/message:copy",
visibility = ["//visibility:public"],
)
alias(
name = "message_internal",
actual = "//upb/message:internal",
visibility = ["//visibility:public"],
)
alias(
name = "message_promote",
actual = "//upb/message:promote",
visibility = ["//visibility:public"],
)
alias(
name = "message_rep_internal",
actual = "//upb/message:rep_internal",
visibility = ["//visibility:public"],
)
alias(
name = "message_split64",
actual = "//upb/message:split64",
visibility = ["//visibility:public"],
)
alias(
name = "message_tagged_ptr",
actual = "//upb/message:tagged_ptr",
visibility = ["//:friends"],
)
alias(
name = "message_typedef",
actual = "//upb/message:typedef",
visibility = ["//visibility:public"],
)
alias(
name = "mini_descriptor",
actual = "//upb/mini_descriptor",
@ -712,41 +513,6 @@ cc_test(
],
)
cc_test(
name = "message_test",
srcs = ["upb/message/test.cc"],
deps = [
":json",
":message_test_upb_proto",
":message_test_upb_proto_reflection",
":reflection",
":upb",
":wire",
"//upb/test:fuzz_util",
"//upb/test:test_messages_proto3_upb_proto",
"@com_google_googletest//:gtest_main",
],
)
proto_library(
name = "message_test_proto",
testonly = 1,
srcs = ["upb/message/test.proto"],
deps = ["@com_google_protobuf//src/google/protobuf:test_messages_proto3_proto"],
)
upb_proto_library(
name = "message_test_upb_proto",
testonly = 1,
deps = [":message_test_proto"],
)
upb_proto_reflection_library(
name = "message_test_upb_proto_reflection",
testonly = 1,
deps = [":message_test_proto"],
)
# Internal C/C++ libraries #####################################################
cc_binary(

@ -109,6 +109,7 @@ sh_test(
"//upb/hash:source_files",
"//upb/lex:source_files",
"//upb/mem:source_files",
"//upb/message:source_files",
"//upb/mini_descriptor:source_files",
"//upb/mini_table:source_files",
"//upb/port:source_files",

@ -74,7 +74,9 @@ cc_library(
deps = [
":protos_extension_lock",
"//:mem",
"//:message",
"//:message_copy",
"//:message_internal",
"//:message_promote",
"//:message_typedef",
"//:mini_table",

@ -259,6 +259,7 @@ pkg_files(
"//upb/hash:source_files",
"//upb/lex:source_files",
"//upb/mem:source_files",
"//upb/message:source_files",
"//upb/mini_descriptor:source_files",
"//upb/mini_table:source_files",
"//upb/port:source_files",

@ -0,0 +1,332 @@
# Copyright (c) 2009-2021, Google LLC
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Google LLC nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL Google LLC BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
load("//bazel:build_defs.bzl", "UPB_DEFAULT_COPTS")
load(
"//bazel:upb_proto_library.bzl",
"upb_proto_library",
"upb_proto_reflection_library",
)
cc_library(
name = "accessors",
srcs = [
"accessors.c",
"internal/accessors.h",
],
hdrs = [
"accessors.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":internal",
"//:base",
"//:collections_internal",
"//:eps_copy_input_stream",
"//:mini_table",
"//:mini_table_internal",
"//:port",
"//:wire",
"//:wire_internal",
"//:wire_reader",
],
)
cc_library(
name = "accessors_internal",
hdrs = [
"internal/accessors.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":internal",
"//:collections_internal",
"//:mini_table_internal",
"//:port",
],
)
cc_library(
name = "copy",
srcs = [
"copy.c",
],
hdrs = [
"copy.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":accessors",
":internal",
":typedef",
"//:base",
"//:collections_internal",
"//:mem",
"//:mini_table",
"//:mini_table_internal",
"//:port",
],
)
cc_library(
name = "internal",
srcs = [
"message.c",
],
hdrs = [
"internal/extension.h",
"internal/message.h",
"message.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
"//:base",
"//:base_internal",
"//:hash",
"//:mem",
"//:mini_table",
"//:port",
],
)
cc_library(
name = "message",
hdrs = [
"message.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":internal",
"//:base",
"//:mem",
"//:mini_table",
"//:port",
],
)
cc_library(
name = "promote",
srcs = [
"promote.c",
],
hdrs = [
"promote.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":accessors",
":internal",
":typedef",
"//:base",
"//:collections_internal",
"//:eps_copy_input_stream",
"//:hash",
"//:mem",
"//:mini_table",
"//:port",
"//:wire",
"//:wire_internal",
"//:wire_reader",
],
)
cc_library(
name = "rep_internal",
hdrs = [
"internal/map_entry.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
"//:base",
"//:hash",
],
)
cc_library(
name = "split64",
hdrs = [
"accessors_split64.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":accessors",
"//:port",
],
)
cc_library(
name = "tagged_ptr",
hdrs = ["tagged_ptr.h"],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":typedef",
"//:port",
],
)
cc_library(
name = "typedef",
hdrs = [
"typedef.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [],
)
# TODO(salo): Move these proto library targets to //third_party/protobuf/BUILD
# after we have the monorepo.
proto_library(
name = "message_test_proto",
testonly = 1,
srcs = ["test.proto"],
deps = ["@com_google_protobuf//src/google/protobuf:test_messages_proto3_proto"],
)
upb_proto_library(
name = "message_test_upb_proto",
testonly = 1,
deps = [":message_test_proto"],
)
upb_proto_reflection_library(
name = "message_test_upb_proto_reflection",
testonly = 1,
deps = [":message_test_proto"],
)
cc_test(
name = "accessors_test",
srcs = ["accessors_test.cc"],
deps = [
":accessors",
"//:base",
"//:collections",
"//:mini_descriptor",
"//:mini_descriptor_encode_internal",
"//:mini_descriptor_internal",
"//:mini_table",
"//:port",
"//:upb",
"//:wire",
"//:wire_internal",
"//upb/test:test_messages_proto2_upb_proto",
"//upb/test:test_messages_proto3_upb_proto",
"//upb/test:test_upb_proto",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_googletest//:gtest_main",
"@com_google_protobuf//:protobuf",
],
)
cc_test(
name = "copy_test",
srcs = ["copy_test.cc"],
deps = [
":accessors",
":copy",
":internal",
"//:base",
"//:collections",
"//:mem",
"//:mini_table",
"//:upb",
"//:wire",
"//upb/test:test_messages_proto2_upb_proto",
"//upb/test:test_messages_proto3_upb_proto",
"//upb/test:test_upb_proto",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_googletest//:gtest_main",
"@com_google_protobuf//:protobuf",
],
)
cc_test(
name = "promote_test",
srcs = ["promote_test.cc"],
deps = [
":accessors",
":copy",
":promote",
"//:base",
"//:collections",
"//:mini_descriptor_encode_internal",
"//:mini_descriptor_internal",
"//:mini_table",
"//:port",
"//:upb",
"//:wire",
"//:wire_internal",
"//upb/test:test_messages_proto2_upb_proto",
"//upb/test:test_messages_proto3_upb_proto",
"//upb/test:test_upb_proto",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_googletest//:gtest_main",
"@com_google_protobuf//:protobuf",
],
)
# This test doesn't directly include any files from this subdir so it probably
# should live elsewhere.
cc_test(
name = "test",
srcs = ["test.cc"],
deps = [
":message_test_upb_proto",
":message_test_upb_proto_reflection",
"//:json",
"//:reflection",
"//:upb",
"//:wire",
"//upb/test:fuzz_util",
"//upb/test:test_messages_proto3_upb_proto",
"@com_google_googletest//:gtest_main",
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
[
"**/*.c",
"**/*.h",
],
),
visibility = [
"//cmake:__pkg__",
"//python/dist:__pkg__",
]
)
# end:github_only

@ -139,6 +139,7 @@ cc_library(
visibility = ["//:__subpackages__"],
deps = [
"//:upb",
"//:message",
"//:mini_descriptor",
"//:mini_table",
"//:mini_table_internal",

Loading…
Cancel
Save