upb: create upb/base/BUILD

The next in a series of CLs to split upb/BUILD into subdirs.

PiperOrigin-RevId: 552010931
pull/13675/head^2
Eric Salo 2 years ago committed by Copybara-Service
parent b19edc5ce0
commit e1e8f1e222
  1. 100
      BUILD
  2. 1
      benchmarks/BUILD
  3. 2
      benchmarks/benchmark.cc
  4. 1
      cmake/BUILD.bazel
  5. 1
      protos/BUILD
  6. 1
      python/dist/BUILD.bazel
  7. 70
      upb/base/BUILD
  8. 0
      upb/base/internal/log2.h
  9. 2
      upb/collections/map_sorter.c
  10. 2
      upb/hash/common.c
  11. 2
      upb/message/message.c
  12. 4
      upb/message/tagged_ptr.h
  13. 35
      upb/message/typedef.h
  14. 4
      upb/mini_descriptor/BUILD
  15. 2
      upb/mini_descriptor/internal/base92.h
  16. 2
      upb/mini_descriptor/internal/encode.c
  17. 2
      upb/mini_descriptor/internal/encode.hpp
  18. 4
      upb/mini_table/BUILD
  19. 3
      upb/mini_table/internal/message.h
  20. 1
      upb/test/BUILD

100
BUILD

@ -130,9 +130,6 @@ cc_library(
"upb/alloc.h",
"upb/arena.h",
"upb/array.h",
"upb/base/descriptor_constants.h",
"upb/base/status.h",
"upb/base/string_view.h",
"upb/collections/array.h",
"upb/decode.h",
"upb/encode.h",
@ -155,34 +152,19 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":base",
":base_internal",
":collections_internal",
":fastdecode",
":hash",
":lex",
":mem",
":message_internal",
":mini_table",
":port",
":wire",
"//upb/mini_table",
],
)
cc_library(
name = "base",
srcs = [
"upb/base/status.c",
],
hdrs = [
"upb/base/descriptor_constants.h",
"upb/base/log2.h",
"upb/base/status.h",
"upb/base/string_view.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//:__subpackages__"],
deps = [":port"],
)
cc_library(
name = "message",
hdrs = [
@ -191,25 +173,14 @@ cc_library(
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":mem",
":message_internal",
":mini_table",
":port",
"//upb/mini_table",
],
)
alias(
name = "mini_table",
actual = "//upb/mini_table",
visibility = ["//:friends"],
)
alias(
name = "mini_table_internal",
actual = "//upb/mini_table:internal",
visibility = ["//:friends"],
)
cc_library(
name = "message_internal",
srcs = [
@ -224,10 +195,11 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":base",
":base_internal",
":hash",
":mem",
":mini_table",
":port",
"//upb/mini_table",
],
)
@ -237,6 +209,7 @@ cc_library(
copts = UPB_DEFAULT_COPTS,
visibility = ["//:friends"],
deps = [
":message_typedef",
":port",
],
)
@ -268,6 +241,7 @@ cc_library(
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":collections_internal",
":eps_copy_input_stream",
":message_internal",
@ -337,10 +311,21 @@ cc_library(
],
)
cc_library(
name = "message_typedef",
hdrs = [
"upb/message/typedef.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [],
)
cc_test(
name = "message_accessors_test",
srcs = ["upb/message/accessors_test.cc"],
deps = [
":base",
":collections",
":message_accessors",
":port",
@ -362,6 +347,7 @@ cc_test(
name = "message_promote_test",
srcs = ["upb/message/promote_test.cc"],
deps = [
":base",
":collections",
":message_accessors",
":message_copy",
@ -384,6 +370,7 @@ cc_test(
name = "message_copy_test",
srcs = ["upb/message/copy_test.cc"],
deps = [
":base",
":collections",
":message_accessors",
":message_copy",
@ -429,6 +416,8 @@ cc_library(
],
visibility = ["//visibility:public"],
deps = [
":base",
":base_internal",
":collections_internal",
":message_accessors",
":message_accessors_internal",
@ -548,13 +537,14 @@ cc_library(
visibility = ["//:__subpackages__"],
deps = [
":base",
":base_internal",
":hash",
":mem",
":message_internal",
":message_rep_internal",
":message_tagged_ptr",
":mini_table",
":port",
"//upb/mini_table",
],
)
@ -589,6 +579,7 @@ bootstrap_cc_library(
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":collections",
":port",
":upb",
@ -653,6 +644,7 @@ bootstrap_cc_library(
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":base",
":collections",
":hash",
":message_accessors",
@ -688,12 +680,38 @@ cc_library(
],
)
# Aliases ######################################################################
alias(
name = "base",
actual = "//upb/base",
visibility = ["//visibility:public"],
)
alias(
name = "base_internal",
actual = "//upb/base:internal",
visibility = ["//visibility:public"],
)
alias(
name = "json",
actual = "//upb/json",
visibility = ["//visibility:public"],
)
alias(
name = "mini_table",
actual = "//upb/mini_table",
visibility = ["//:friends"],
)
alias(
name = "mini_table_internal",
actual = "//upb/mini_table:internal",
visibility = ["//:friends"],
)
# Tests ########################################################################
cc_test(
@ -720,6 +738,7 @@ cc_test(
name = "collections_test",
srcs = ["upb/collections/test.cc"],
deps = [
":base",
":collections",
":upb",
"@com_google_googletest//:gtest_main",
@ -840,9 +859,9 @@ cc_library(
deps = [
":mem",
":message_internal",
":mini_table",
":port",
":wire_internal",
"//upb/mini_table",
],
)
@ -872,10 +891,10 @@ cc_library(
":message_accessors_internal",
":message_internal",
":message_rep_internal",
":mini_table",
":port",
":wire_reader",
":wire_types",
"//upb/mini_table",
"@utf8_range",
],
)
@ -936,6 +955,7 @@ cc_library(
visibility = ["//:__subpackages__"],
deps = [
":base",
":base_internal",
":mem",
":port",
],
@ -1004,6 +1024,7 @@ upb_amalgamation(
":message_internal",
":message_rep_internal",
":message_tagged_ptr",
":message_typedef",
":port",
":reflection_internal",
":reflection",
@ -1011,6 +1032,7 @@ upb_amalgamation(
":wire_internal",
":wire_reader",
":wire_types",
"//upb/base:internal",
"//upb/mini_descriptor:encode_internal",
"//upb/mini_descriptor:internal",
"//upb/mini_descriptor:mini_descriptor",
@ -1050,6 +1072,7 @@ upb_amalgamation(
":message_internal",
":message_rep_internal",
":message_tagged_ptr",
":message_typedef",
":port",
":reflection_internal",
":reflection",
@ -1057,6 +1080,7 @@ upb_amalgamation(
":wire_internal",
":wire_reader",
":wire_types",
"//upb/base:internal",
"//upb/mini_descriptor:encode_internal",
"//upb/mini_descriptor:internal",
"//upb/mini_descriptor:mini_descriptor",
@ -1097,6 +1121,7 @@ upb_amalgamation(
":message_internal",
":message_rep_internal",
":message_tagged_ptr",
":message_typedef",
":port",
":reflection_internal",
":reflection",
@ -1104,6 +1129,7 @@ upb_amalgamation(
":wire_internal",
":wire_reader",
":wire_types",
"//upb/base:internal",
"//upb/mini_descriptor:encode_internal",
"//upb/mini_descriptor:internal",
"//upb/mini_descriptor:mini_descriptor",

@ -95,6 +95,7 @@ cc_test(
"//:descriptor_upb_proto",
"//:mem",
"//:reflection",
"//upb/base:internal",
"@com_github_google_benchmark//:benchmark_main",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_protobuf//:protobuf",

@ -37,7 +37,7 @@
#include "benchmarks/descriptor.upb.h"
#include "benchmarks/descriptor.upbdefs.h"
#include "benchmarks/descriptor_sv.pb.h"
#include "upb/base/log2.h"
#include "upb/base/internal/log2.h"
#include "upb/mem/arena.h"
#include "upb/reflection/def.hpp"

@ -100,6 +100,7 @@ sh_test(
":copy_protos",
":gen_cmakelists",
"//:source_files",
"//upb/base:source_files",
"//upb/mini_descriptor:source_files",
"//upb/mini_table:source_files",
"@utf8_range//:utf8_range_srcs",

@ -49,6 +49,7 @@ cc_library(
deps = [
":protos",
":protos_traits",
"//:base",
"//:collections_internal",
"//:message_copy",
"//:mini_table",

@ -214,6 +214,7 @@ pkg_tar(
"//:LICENSE",
"//:source_files",
"//python:message_srcs",
"//upb/base:source_files",
"//upb/mini_descriptor:source_files",
"//upb/mini_table:source_files",
"//upb/util:source_files",

@ -0,0 +1,70 @@
# 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")
cc_library(
name = "base",
srcs = [
"status.c",
],
hdrs = [
"descriptor_constants.h",
"status.h",
"string_view.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = [
":internal",
"//:port",
],
)
cc_library(
name = "internal",
hdrs = [
"internal/log2.h",
],
copts = UPB_DEFAULT_COPTS,
visibility = ["//visibility:public"],
deps = ["//:port"],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
[
"**/*.c",
"**/*.h",
],
),
visibility = [
"//cmake:__pkg__",
"//python/dist:__pkg__",
]
)
# end:github_only

@ -25,7 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "upb/base/log2.h"
#include "upb/base/internal/log2.h"
#include "upb/collections/map_sorter_internal.h"
// Must be last.

@ -33,7 +33,7 @@
#include <string.h>
#include "upb/base/log2.h"
#include "upb/base/internal/log2.h"
#include "upb/hash/int_table.h"
#include "upb/hash/str_table.h"

@ -29,7 +29,7 @@
#include <math.h>
#include "upb/base/log2.h"
#include "upb/base/internal/log2.h"
#include "upb/message/internal.h"
// Must be last.

@ -30,6 +30,8 @@
#include <stdint.h>
#include "upb/message/typedef.h"
// Must be last.
#include "upb/port/def.inc"
@ -37,8 +39,6 @@
extern "C" {
#endif
typedef void upb_Message;
// When a upb_Message* is stored in a message, array, or map, it is stored in a
// tagged form. If the tag bit is set, the referenced upb_Message is of type
// _kUpb_MiniTable_Empty (a sentinel message type with no fields) instead of

@ -0,0 +1,35 @@
/*
* 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.
*/
#ifndef UPB_MESSAGE_TYPEDEF_H_
#define UPB_MESSAGE_TYPEDEF_H_
// This typedef needs its own header to resolve a circular dependency between
// messages and mini tables.
typedef void upb_Message;
#endif /* UPB_MESSAGE_TYPEDEF_H_ */

@ -19,6 +19,7 @@ cc_library(
visibility = ["//:__subpackages__"],
deps = [
"//:base",
"//:base_internal",
"//:port",
],
)
@ -41,9 +42,9 @@ cc_library(
":internal",
"//:base",
"//:mem",
"//:mini_table",
"//:mini_table_internal",
"//:port",
"//upb/mini_table",
],
)
@ -61,6 +62,7 @@ cc_library(
deps = [
":internal",
"//:base",
"//:base_internal",
"//:port",
],
)

@ -28,7 +28,7 @@
#ifndef UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_
#define UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_
#include "upb/base/log2.h"
#include "upb/base/internal/log2.h"
// Must be last.
#include "upb/port/def.inc"

@ -27,7 +27,7 @@
#include "upb/mini_descriptor/internal/encode.h"
#include "upb/base/log2.h"
#include "upb/base/internal/log2.h"
#include "upb/mini_descriptor/internal/base92.h"
#include "upb/mini_descriptor/internal/modifiers.h"
#include "upb/mini_descriptor/internal/wire_constants.h"

@ -30,7 +30,7 @@
#include <string>
#include "upb/base/log2.h"
#include "upb/base/internal/log2.h"
#include "upb/mini_descriptor/internal/encode.h"
namespace upb {

@ -48,8 +48,10 @@ cc_library(
deps = [
":internal",
"//:base",
"//:base_internal",
"//:hash",
"//:mem",
"//:message_typedef",
"//:port",
],
)
@ -70,6 +72,8 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
"//:base",
"//:base_internal",
"//:message_typedef",
"//:port",
],
)

@ -28,13 +28,12 @@
#ifndef UPB_MINI_TABLE_INTERNAL_MESSAGE_H_
#define UPB_MINI_TABLE_INTERNAL_MESSAGE_H_
#include "upb/message/typedef.h"
#include "upb/mini_table/internal/field.h"
// Must be last.
#include "upb/port/def.inc"
typedef void upb_Message;
struct upb_Decoder;
typedef const char* _upb_FieldParser(struct upb_Decoder* d, const char* ptr,
upb_Message* msg, intptr_t table,

@ -187,6 +187,7 @@ cc_test(
":test_messages_proto3_upb_proto",
":test_upb_proto",
"//:upb",
"//:base",
"//:port",
"@com_google_googletest//:gtest_main",
],

Loading…
Cancel
Save