Reorganize upb file structure

This change moves almost everything in the `upb/` directory up one level, so
that for example `upb/upb/generated_code_support.h` becomes just
`upb/generated_code_support.h`. The only exceptions I made to this were that I
left `upb/cmake` and `upb/BUILD` where they are, mostly because that avoids
conflict with other files and the current locations seem reasonable for now.

The `python/` directory is a little bit of a challenge because we had to merge
the existing directory there with `upb/python/`. I made `upb/python/BUILD` into
the BUILD file for the merged directory, and it effectively loads the contents
of the other BUILD file via `python/build_targets.bzl`, but I plan to clean
this up soon.

PiperOrigin-RevId: 568651768
pull/14188/head
Adam Cozzette 2023-09-26 14:36:20 -07:00 committed by Copybara-Service
parent 30a7b23724
commit 501ececd39
454 changed files with 1882 additions and 1847 deletions

13
.github/BUILD.bazel vendored
View File

@ -6,26 +6,29 @@
# of Xcode.
xcode_version(
name = "version14_2_14C18",
version = "14.2.14C18",
aliases = ["14C18"],
default_ios_sdk_version = "16.2",
default_tvos_sdk_version = "16.1",
default_macos_sdk_version = "13.1",
default_tvos_sdk_version = "16.1",
default_watchos_sdk_version = "9.1",
version = "14.2.14C18",
)
xcode_version(
name = "version14_1_0_14B47b",
version = "14.1.0.14B47b",
aliases = ["14B47b"],
default_ios_sdk_version = "16.1",
default_tvos_sdk_version = "16.1",
default_macos_sdk_version = "13.0",
default_tvos_sdk_version = "16.1",
default_watchos_sdk_version = "9.1",
version = "14.1.0.14B47b",
)
xcode_config(
name = "host_xcodes",
versions = [":version14_2_14C18", ":version14_1_0_14B47b"],
default = ":version14_1_0_14B47b",
versions = [
":version14_2_14C18",
":version14_1_0_14B47b",
],
)

View File

@ -20,7 +20,7 @@ jobs:
version: ["3.8", "3.9", "3.10", "3.11" ]
include:
- type: Pure
targets: //python/... //upb/python/... //python:python_version_test
targets: //python/... //python:python_version_test
flags: --define=use_fast_cpp_protos=false
- type: C++
targets: //python/... //python:python_version_test
@ -46,6 +46,7 @@ jobs:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: python_linux/${{ matrix.type }}_${{ matrix.version }}
bazel: test ${{ matrix.targets }} ${{ matrix.flags }} --test_env=KOKORO_PYTHON_VERSION
exclude-targets: -//python/pb_unit_tests/...
macos:
@ -57,7 +58,7 @@ jobs:
version: [ "3.11" ]
include:
- type: Pure
targets: //python/... //upb/python/... //python:python_version_test
targets: //python/... //python:python_version_test
- type: C++
targets: //python/... //python:python_version_test
flags: --define=use_fast_cpp_protos=true
@ -95,3 +96,4 @@ jobs:
test ${{ matrix.targets }} ${{ matrix.flags }}
--test_env=KOKORO_PYTHON_VERSION=${{ matrix.version }}
--macos_minimum_os=10.9
exclude-targets: -//python/pb_unit_tests/...

View File

@ -20,9 +20,9 @@ jobs:
- { name: "Fastbuild" }
- { name: "Optimized", flags: "-c opt" }
- { name: "FastTable", flags: "--//upb:fasttable_enabled=true" }
- { name: "ASAN", flags: "--config=asan -c dbg", exclude-targets: "-//upb/benchmarks:benchmark -//upb/python/..." }
- { name: "UBSAN", flags: "--config=ubsan -c dbg", exclude-targets: "-//upb/benchmarks:benchmark -//upb/python/... -//upb/lua/..." }
- { name: "32-bit", flags: "--copt=-m32 --linkopt=-m32", exclude-targets: "-//upb/benchmarks:benchmark -//upb/python/..." }
- { name: "ASAN", flags: "--config=asan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/..." }
- { name: "UBSAN", flags: "--config=ubsan -c dbg", exclude-targets: "-//benchmarks:benchmark -//python/... -//lua/..." }
- { name: "32-bit", flags: "--copt=-m32 --linkopt=-m32", exclude-targets: "-//benchmarks:benchmark -//python/..." }
# TODO: b/297027295 - Add 32-bit ASAN test
name: ${{ matrix.config.name }}
@ -39,7 +39,7 @@ jobs:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/sanitize@sha256:04cd765285bc52cbbf51d66c8c66d8603579cf0f19cc42df26b09d2c270541fb
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: upb-bazel
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //upb/... ${{ matrix.config.flags }}
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //bazel/... //benchmarks/... //lua/... //protos/... //protos_generator/... //python/... //upb/... //upbc/... ${{ matrix.config.flags }}
exclude-targets: ${{ matrix.config.exclude-targets }}
linux-gcc:
@ -58,7 +58,7 @@ jobs:
image: "us-docker.pkg.dev/protobuf-build/containers/test/linux/gcc:12.2-6.3.0-63dd26c0c7a808d92673a3e52e848189d4ab0f17"
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: "upb-bazel-gcc"
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 -c opt //upb/...
bazel: test --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 -c opt //bazel/... //benchmarks/... //lua/... //protos/... //protos_generator/... //python/... //upb/... //upbc/...
windows:
strategy:
@ -75,7 +75,8 @@ jobs:
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: "upb-bazel-windows"
bazel: test --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 //upb/upb/... //upb/upbc/... //upb/python/... //upb/protos/... //upb/protos_generator/...
bazel: test --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 //upb/... //upbc/... //python/... //protos/... //protos_generator/...
exclude-targets: -//python:conformance_test -//upb:def_builder_test
macos:
strategy:
@ -96,7 +97,7 @@ jobs:
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: "upb-bazel-macos"
bazel: ${{ matrix.config.bazel-command }} --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 ${{ matrix.config.flags }} //upb/...
bazel: ${{ matrix.config.bazel-command }} --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 ${{ matrix.config.flags }} //bazel/... //benchmarks/... //lua/... //protos/... //protos_generator/... //python/... //upb/... //upbc/...
no-python:
strategy:
@ -118,7 +119,7 @@ jobs:
which python3 &&
mv `which python3` /tmp &&
! which python3 &&
bazel test $BAZEL_FLAGS --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //upb/python/... -- -//upb/python/dist:source_wheel
bazel test $BAZEL_FLAGS --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 //python/... -- -//python/dist:source_wheel
build_wheels:
name: Build Wheels
@ -135,7 +136,7 @@ jobs:
image: us-docker.pkg.dev/protobuf-build/release-containers/linux/apple@sha256:b3dc9b75d8e599b0e95ed245d89f44b5a4231112f975da89dd02006a484a58df
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: upb-bazel-python
bazel: build --crosstool_top=//toolchain:clang_suite --//toolchain:release=true --symlink_prefix=/ -c dbg //upb/python/dist //upb/python/dist:test_wheel //upb/python/dist:source_wheel
bazel: build --crosstool_top=//toolchain:clang_suite --//toolchain:release=true --symlink_prefix=/ -c dbg //python/dist //python/dist:test_wheel //python/dist:source_wheel
- name: Move Wheels
run: mkdir wheels && find _build/out \( -name 'protobuf*.whl' -o -name 'protobuf-*.tar.gz' \) -exec mv '{}' wheels ';'
- uses: actions/upload-artifact@v3
@ -146,7 +147,7 @@ jobs:
with:
name: requirements
# Tests shouldn't have access to the whole upb repo, upload the one file we need
path: upb/python/requirements.txt
path: python/requirements.txt
test_wheels:
name: Test Wheels

View File

@ -1,9 +1,9 @@
# Bazel (https://bazel.build/) BUILD file for Protobuf.
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_lite_proto_library", "java_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
load("@rules_java//java:defs.bzl", "java_lite_proto_library", "java_proto_library")
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")
load(":protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library", "internal_ruby_proto_library")
@ -153,8 +153,8 @@ filegroup(
internal_ruby_proto_library(
name = "well_known_ruby_protos",
srcs = [":well_known_protos"],
includes = ["src"],
default_runtime = "",
includes = ["src"],
visibility = [
"//conformance:__pkg__",
"//ruby:__subpackages__",
@ -182,14 +182,14 @@ cc_binary(
cc_binary(
name = "protoc_static",
copts = COPTS,
linkopts = LINK_OPTS,
features = select({
# This isn't possible on mac because there is no static library for lcrt0.o
"@platforms//os:osx": [],
"//build_defs:config_osx": [],
# When cross-compiling we need to statically link all C++ libraries.
"//conditions:default": ["fully_static_link"],
# This isn't possible on mac because there is no static library for lcrt0.o
"@platforms//os:osx": [],
"//build_defs:config_osx": [],
# When cross-compiling we need to statically link all C++ libraries.
"//conditions:default": ["fully_static_link"],
}),
linkopts = LINK_OPTS,
visibility = ["//visibility:public"],
deps = ["//src/google/protobuf/compiler:protoc_lib"],
)
@ -201,9 +201,9 @@ cc_binary(
# Expose the runtime for the proto_lang_toolchain so that it can also be used in
# a user-defined proto_lang_toolchain.
alias(
name = "protobuf_nowkt",
actual = "//src/google/protobuf:protobuf_nowkt",
visibility = ["//visibility:public"],
name = "protobuf_nowkt",
actual = "//src/google/protobuf:protobuf_nowkt",
visibility = ["//visibility:public"],
)
# The "lite" runtime works for .proto files that specify the option:
@ -302,13 +302,13 @@ alias(
alias(
name = "python_srcs",
actual = "//python:python_srcs",
visibility = ["//upb:__subpackages__"],
visibility = ["//python:__subpackages__"],
)
alias(
name = "python_test_srcs",
actual = "//python:python_test_srcs",
visibility = ["//upb:__subpackages__"],
visibility = ["//python:__subpackages__"],
)
alias(
@ -545,11 +545,11 @@ internal_ruby_proto_library(
# The above must come first.
"src",
],
deps = [":well_known_ruby_protos"],
visibility = [
"//conformance:__pkg__",
"//ruby:__subpackages__",
],
deps = [":well_known_ruby_protos"],
)
filegroup(

View File

@ -107,13 +107,13 @@ ruby_bundle(
gemfile = "//ruby:Gemfile",
)
load("//upb/bazel:workspace_deps.bzl", "upb_deps")
load("//bazel:workspace_deps.bzl", "upb_deps")
upb_deps()
http_archive(
name = "lua",
build_file = "//upb/bazel:lua.BUILD",
build_file = "//bazel:lua.BUILD",
sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b",
strip_prefix = "lua-5.2.4",
urls = [
@ -134,11 +134,11 @@ http_archive(
urls = ["https://github.com/googleapis/googleapis/archive/30ed2662a85403cbdeb9ea38df1e414a2a276b83.zip"],
strip_prefix = "googleapis-30ed2662a85403cbdeb9ea38df1e414a2a276b83",
sha256 = "4dfc28101127d22abd6f0f6308d915d490c4594c0cfcf7643769c446d6763a46",
build_file = "//upb/benchmarks:BUILD.googleapis",
build_file = "//benchmarks:BUILD.googleapis",
patch_cmds = ["find google -type f -name BUILD.bazel -delete"],
)
load("//upb/bazel:system_python.bzl", "system_python")
load("//bazel:system_python.bzl", "system_python")
system_python(
name = "system_python",
@ -149,7 +149,7 @@ load("@system_python//:pip.bzl", "pip_parse")
pip_parse(
name = "pip_deps",
requirements = "//upb/python:requirements.txt",
requirements = "//python:requirements.txt",
)
load("@pip_deps//:requirements.bzl", "install_deps")

View File

@ -54,7 +54,7 @@ upb_amalgamation = rule(
"_amalgamator": attr.label(
executable = True,
cfg = "exec",
default = "//upb/bazel:amalgamate",
default = "//bazel:amalgamate",
),
"prefix": attr.string(
default = "",

View File

@ -39,7 +39,7 @@ cc_import(
hdrs = glob(["**/*.h"]),
shared_library = "python{0}.dll",
interface_library = "libs/python{0}.lib",
visibility = ["@com_google_protobuf//upb/python:__pkg__"],
visibility = ["@com_google_protobuf//python:__pkg__"],
)
cc_import(
@ -47,7 +47,7 @@ cc_import(
hdrs = glob(["**/*.h"]),
shared_library = "python{1}.dll",
interface_library = "libs/python{1}.lib",
visibility = ["@com_google_protobuf//upb/python:__pkg__"],
visibility = ["@com_google_protobuf//python:__pkg__"],
)
"""

View File

@ -1,9 +1,9 @@
"""upb_c_proto_library() exposes upb's generated C API for protobuf (foo.upb.h)"""
load("//upb/bazel:upb_minitable_proto_library.bzl", "UpbMinitableCcInfo", "upb_minitable_proto_library_aspect")
load("//upb/bazel:upb_proto_library_internal/aspect.bzl", "upb_proto_aspect_impl")
load("//upb/bazel:upb_proto_library_internal/cc_library_func.bzl", "upb_use_cpp_toolchain")
load("//upb/bazel:upb_proto_library_internal/rule.bzl", "upb_proto_rule_impl")
load("//bazel:upb_minitable_proto_library.bzl", "UpbMinitableCcInfo", "upb_minitable_proto_library_aspect")
load("//bazel:upb_proto_library_internal/aspect.bzl", "upb_proto_aspect_impl")
load("//bazel:upb_proto_library_internal/cc_library_func.bzl", "upb_use_cpp_toolchain")
load("//bazel:upb_proto_library_internal/rule.bzl", "upb_proto_rule_impl")
UpbWrappedCcInfo = provider(
"Provider for cc_info for protos",
@ -34,7 +34,7 @@ upb_c_proto_library_aspect = aspect(
"_gen_upb": attr.label(
executable = True,
cfg = "exec",
default = "//upb/upbc:protoc-gen-upb_stage1",
default = "//upbc:protoc-gen-upb_stage1",
),
"_protoc": attr.label(
executable = True,

View File

@ -1,8 +1,8 @@
"""upb_minitable_proto_library() exposes upb's generated minitables (foo.upb_minitable.h)"""
load("//upb/bazel:upb_proto_library_internal/aspect.bzl", "upb_proto_aspect_impl")
load("//upb/bazel:upb_proto_library_internal/cc_library_func.bzl", "upb_use_cpp_toolchain")
load("//upb/bazel:upb_proto_library_internal/rule.bzl", "upb_proto_rule_impl")
load("//bazel:upb_proto_library_internal/aspect.bzl", "upb_proto_aspect_impl")
load("//bazel:upb_proto_library_internal/cc_library_func.bzl", "upb_use_cpp_toolchain")
load("//bazel:upb_proto_library_internal/rule.bzl", "upb_proto_rule_impl")
UpbMinitableCcInfo = provider(
"Provider for cc_info for protos",
@ -46,7 +46,7 @@ upb_minitable_proto_library_aspect = aspect(
"_gen_upb_minitable": attr.label(
executable = True,
cfg = "exec",
default = "//upb/upbc:protoc-gen-upb_minitable_stage1",
default = "//upbc:protoc-gen-upb_minitable_stage1",
),
"_protoc": attr.label(
executable = True,

View File

@ -11,17 +11,17 @@
"""
load(
"//upb/bazel:upb_c_proto_library.bzl",
"//bazel:upb_c_proto_library.bzl",
_UpbWrappedCcInfo = "UpbWrappedCcInfo",
_upb_c_proto_library = "upb_c_proto_library",
_upb_c_proto_library_aspect = "upb_c_proto_library_aspect",
)
load(
"//upb/bazel:upb_proto_library_internal/aspect.bzl",
"//bazel:upb_proto_library_internal/aspect.bzl",
_GeneratedSrcsInfo = "GeneratedSrcsInfo",
)
load(
"//upb/bazel:upb_proto_reflection_library.bzl",
"//bazel:upb_proto_reflection_library.bzl",
_upb_proto_reflection_library = "upb_proto_reflection_library",
)

View File

@ -1,8 +1,8 @@
"""Implementation of the aspect that powers the upb_*_proto_library() rules."""
load("@bazel_skylib//lib:paths.bzl", "paths")
load("//upb/bazel:upb_proto_library_internal/cc_library_func.bzl", "cc_library_func")
load("//upb/bazel:upb_proto_library_internal/copts.bzl", "UpbProtoLibraryCoptsInfo")
load("//bazel:upb_proto_library_internal/cc_library_func.bzl", "cc_library_func")
load("//bazel:upb_proto_library_internal/copts.bzl", "UpbProtoLibraryCoptsInfo")
# begin:github_only
_is_google3 = False

View File

@ -1,9 +1,9 @@
"""upb_c_proto_reflection_library() exposes upb reflection for protobuf (foo.upbdefs.h)"""
load("//upb/bazel:upb_minitable_proto_library.bzl", "UpbMinitableCcInfo", "upb_minitable_proto_library_aspect")
load("//upb/bazel:upb_proto_library_internal/aspect.bzl", "upb_proto_aspect_impl")
load("//upb/bazel:upb_proto_library_internal/cc_library_func.bzl", "upb_use_cpp_toolchain")
load("//upb/bazel:upb_proto_library_internal/rule.bzl", "upb_proto_rule_impl")
load("//bazel:upb_minitable_proto_library.bzl", "UpbMinitableCcInfo", "upb_minitable_proto_library_aspect")
load("//bazel:upb_proto_library_internal/aspect.bzl", "upb_proto_aspect_impl")
load("//bazel:upb_proto_library_internal/cc_library_func.bzl", "upb_use_cpp_toolchain")
load("//bazel:upb_proto_library_internal/rule.bzl", "upb_proto_rule_impl")
_UpbDefsWrappedCcInfo = provider("Provider for cc_info for protos", fields = ["cc_info"])
@ -31,7 +31,7 @@ _upb_proto_reflection_library_aspect = aspect(
"_gen_upbdefs": attr.label(
executable = True,
cfg = "exec",
default = "//upb/upbc:protoc-gen-upbdefs",
default = "//upbc:protoc-gen-upbdefs",
),
"_protoc": attr.label(
executable = True,

View File

@ -1,6 +1,6 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//upb/bazel:python_downloads.bzl", "python_nuget_package", "python_source_archive")
load("//bazel:python_downloads.bzl", "python_nuget_package", "python_source_archive")
def _github_archive(repo, commit, **kwargs):
repo_name = repo.split("/")[-1]

View File

@ -12,7 +12,7 @@ load("@rules_python//python:defs.bzl", "py_binary")
# end:google_only
load(
"//upb/bazel:upb_proto_library.bzl",
"//bazel:upb_proto_library.bzl",
"upb_proto_library",
"upb_proto_reflection_library",
)
@ -76,6 +76,7 @@ cc_test(
":benchmark_descriptor_upb_proto",
":benchmark_descriptor_upb_proto_reflection",
"//:protobuf",
"@com_google_googletest//:gtest_main",
"//upb:base",
"//upb:base_internal",
"//upb:descriptor_upb_proto",

View File

@ -38,15 +38,15 @@
#include "google/protobuf/descriptor.pb.h"
#include "absl/container/flat_hash_set.h"
#include "google/protobuf/dynamic_message.h"
#include "upb/benchmarks/descriptor.pb.h"
#include "upb/benchmarks/descriptor.upb.h"
#include "upb/benchmarks/descriptor.upbdefs.h"
#include "upb/benchmarks/descriptor_sv.pb.h"
#include "upb/upb/base/internal/log2.h"
#include "upb/upb/mem/arena.h"
#include "upb/upb/reflection/def.hpp"
#include "benchmarks/descriptor.pb.h"
#include "benchmarks/descriptor.upb.h"
#include "benchmarks/descriptor.upbdefs.h"
#include "benchmarks/descriptor_sv.pb.h"
#include "upb/base/internal/log2.h"
#include "upb/mem/arena.h"
#include "upb/reflection/def.hpp"
upb_StringView descriptor = upb_benchmarks_descriptor_proto_upbdefinit.descriptor;
upb_StringView descriptor = benchmarks_descriptor_proto_upbdefinit.descriptor;
namespace protobuf = ::google::protobuf;
// A buffer big enough to parse descriptor.proto without going to heap.

View File

@ -89,7 +89,7 @@ selects.config_setting_group(
match_any = [
":config_win32",
":config_win64",
]
],
)
config_setting(
@ -107,7 +107,7 @@ selects.config_setting_group(
match_any = [
":config_osx_aarch64",
":config_osx_x86_64",
]
],
)
# Internal testing:

View File

@ -4,13 +4,13 @@ load("//build_defs:internal_shell.bzl", "inline_sh_test")
inline_sh_test(
name = "tests",
srcs = ["test.sh"],
cmd = "$(location test.sh) 3.0.0 $(rootpath //:protoc)",
tools = ["//:protoc"],
deps = glob([
"src/**/*.cs*", # .cs and .csproj
"protos/**/*.proto",
"src/**/*.cs*", # .cs and .csproj
"protos/**/*.proto",
]) + [
"//csharp:srcs",
"//:well_known_protos",
"//:well_known_protos",
"//csharp:srcs",
],
cmd = "$(location test.sh) 3.0.0 $(rootpath //:protoc)"
)

View File

@ -129,7 +129,7 @@ build horizon issues since GCL parses protos in prod).
Rev'ing `descriptor.proto` is a far more intrusive change that affects many
downstream systems. Many systems access descriptors through either a descriptor
API (for example, `proto2::Descriptor` in C++) or by directly accessing a proto
API (for example, `google::protobuf::Descriptor` in C++) or by directly accessing a proto
from `descriptor.proto` (eg. `google.protobuf.DescriptorProto`). Any changes
here need to be managed much more delicately.

View File

@ -7,7 +7,7 @@
## Background
On 2023-02-10, a CL [@mcy](https://github.com/mcy) submitted to delete
`proto2::Reflection::SupportsUnknownEnumValue()`. Oddly, this function used the
`google::protobuf::Reflection::SupportsUnknownEnumValue()`. Oddly, this function used the
containing message's `syntax`, rather than the enum field's, to determine
whether the enum was open.

View File

@ -173,8 +173,8 @@ class MyMessage(_message.Message):
To use reflection-based access:
1. Load and access descriptor data using the interfaces in upb/upb/reflection/def.h.
2. Access message data using the interfaces in upb/upb/reflection/message.h.
1. Load and access descriptor data using the interfaces in upb/reflection/def.h.
2. Access message data using the interfaces in upb/reflection/message.h.
### MiniTables
@ -234,8 +234,8 @@ APIs to do this do not exist yet.
To use MiniTable-based access:
1. Load and access MiniDescriptors data using the interfaces in upb/upb/mini_descriptor/decode.h.
2. Access message data using the interfaces in upb/upb/message/accessors.h.
1. Load and access MiniDescriptors data using the interfaces in upb/mini_descriptor/decode.h.
2. Access message data using the interfaces in upb/message/accessors.h.
## Memory Management

View File

@ -4,11 +4,6 @@ load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
sh_test(
name = "linkage_monitor",
size = "large",
tags = [
# Exclude this target from wildcard expansion (//...) because it may
# take unnecessary time.
"manual",
],
srcs = [
":linkage_monitor.sh",
],
@ -28,6 +23,11 @@ sh_test(
"*/pom.xml",
"test/linkage-monitor-check-bom/pom.xml",
]),
tags = [
# Exclude this target from wildcard expansion (//...) because it may
# take unnecessary time.
"manual",
],
)
test_suite(

View File

@ -59,8 +59,8 @@ kt_jvm_export(
maven_coordinates = "com.google.protobuf:protobuf-kotlin:%s" % PROTOBUF_JAVA_VERSION,
pom_template = "//java/kotlin:pom_template.xml",
resources = [
"//src/google/protobuf:descriptor_proto_srcs",
"//:well_known_type_protos",
"//src/google/protobuf:descriptor_proto_srcs",
],
tags = ["manual"],
runtime_deps = [

View File

@ -6,12 +6,12 @@
# https://developers.google.com/open-source/licenses/bsd
load(
"//upb/bazel:build_defs.bzl",
"//bazel:build_defs.bzl",
"UPB_DEFAULT_COPTS",
"UPB_DEFAULT_CPPOPTS",
)
load(
"//upb/lua:lua_proto_library.bzl",
"//lua:lua_proto_library.bzl",
"lua_proto_library",
)
@ -58,6 +58,7 @@ cc_test(
copts = UPB_DEFAULT_COPTS,
data = [
"test_upb.lua",
"upb.lua",
":descriptor_proto_lua",
":empty_proto_lua",
":test_messages_proto2_proto_lua",
@ -67,11 +68,10 @@ cc_test(
"//conformance:conformance_proto",
"//third_party/lunit:console.lua",
"//third_party/lunit:lunit.lua",
"//upb/lua:upb.lua",
],
linkstatic = 1,
deps = [
"//upb/lua:lupb",
":lupb",
"@lua//:liblua",
],
)

View File

@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/upb/reflection/def.h"
#include "upb/reflection/def.h"
#include <float.h>
#include <math.h>
@ -36,8 +36,8 @@
#include <string.h>
#include "lauxlib.h"
#include "upb/lua/upb.h"
#include "upb/upb/reflection/message.h"
#include "lua/upb.h"
#include "upb/reflection/message.h"
#define LUPB_ENUMDEF "lupb.enumdef"
#define LUPB_ENUMVALDEF "lupb.enumvaldef"

View File

@ -109,7 +109,7 @@ _lua_proto_library_aspect = aspect(
"_upbc": attr.label(
executable = True,
cfg = "exec",
default = "//upb/lua:protoc-gen-lua",
default = "//lua:protoc-gen-lua",
),
"_protoc": attr.label(
executable = True,

View File

@ -33,7 +33,7 @@
#include <lualib.h>
#include <signal.h>
#include "upb/lua/upb.h"
#include "lua/upb.h"
lua_State* L;
@ -59,14 +59,14 @@ const char* init =
"bazel-bin/?.lua;"
"bazel-bin/external/com_google_protobuf/src/?.lua;"
"bazel-bin/external/com_google_protobuf/?.lua;"
"upb/lua/?.lua;"
"lua/?.lua;"
// These additional paths handle the case where this test is invoked from
// the protobuf repo's Bazel workspace.
"external/upb/?.lua;"
"external/upb/third_party/lunit/?.lua;"
"external/?.lua;"
"external/third_party/lunit/?.lua;"
"src/?.lua;"
"bazel-bin/external/upb/?.lua;"
"external/upb/lua/?.lua"
"bazel-bin/external/?.lua;"
"external/lua/?.lua"
"'";
int main(int argc, char** argv) {

View File

@ -39,14 +39,14 @@
#include <string.h>
#include "lauxlib.h"
#include "upb/lua/upb.h"
#include "upb/upb/collections/map.h"
#include "upb/upb/json/decode.h"
#include "upb/upb/json/encode.h"
#include "upb/upb/message/message.h"
#include "upb/upb/port/def.inc"
#include "upb/upb/reflection/message.h"
#include "upb/upb/text/encode.h"
#include "lua/upb.h"
#include "upb/collections/map.h"
#include "upb/json/decode.h"
#include "upb/json/encode.h"
#include "upb/message/message.h"
#include "upb/port/def.inc"
#include "upb/reflection/message.h"
#include "upb/text/encode.h"
/*
* Message/Map/Array objects. These objects form a directed graph: a message

View File

@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
local upb = require "lupb"
local lunit = require "lunit"
local upb_test = require "upb.lua.test_pb"
local upb_test = require "lua.test_pb"
local test_messages_proto3 = require "google.protobuf.test_messages_proto3_pb"
local test_messages_proto2 = require "google.protobuf.test_messages_proto2_pb"
local descriptor = require "google.protobuf.descriptor_pb"

View File

@ -50,7 +50,7 @@
* domain of [u]int64 values.
*/
#include "upb/lua/upb.h"
#include "lua/upb.h"
#include <float.h>
#include <math.h>
@ -59,7 +59,7 @@
#include <string.h>
#include "lauxlib.h"
#include "upb/upb/message/message.h"
#include "upb/message/message.h"
/* Lua compatibility code *****************************************************/

View File

@ -36,9 +36,9 @@
#define UPB_LUA_UPB_H_
#include "lauxlib.h"
#include "upb/upb/message/message.h"
#include "upb/upb/reflection/def.h"
#include "upb/upb/reflection/message.h"
#include "upb/message/message.h"
#include "upb/reflection/def.h"
#include "upb/reflection/message.h"
/* Lua changes its API in incompatible ways in every minor release.
* This is some shim code to paper over the differences. */

View File

@ -42,8 +42,8 @@ genrule(
for wkt in _OBJC_WKT_NAMES
for ext in _OBJC_EXTS
]),
tools = ["//:protoc"],
tags = ["manual"],
tools = ["//:protoc"],
)
staleness_test(

View File

@ -2,7 +2,7 @@
#
# See also code generation logic under /src/google/protobuf/compiler/php.
load("@rules_pkg//:mappings.bzl", "pkg_files", "pkg_filegroup", "strip_prefix")
load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("//upb/cmake:build_defs.bzl", "staleness_test")
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
@ -11,10 +11,6 @@ load("//:protobuf_version.bzl", "PROTOBUF_PHP_VERSION", "PROTOC_VERSION")
filegroup(
name = "source_files",
visibility = [
"//conformance:__pkg__",
"//php:__pkg__",
],
srcs = glob([
"src/GPBMetadata/Google/Protobuf/**/*.php",
"src/Google/Protobuf/**/*.php",
@ -22,6 +18,10 @@ filegroup(
"composer.json",
":php_ext_source_files",
],
visibility = [
"//conformance:__pkg__",
"//php:__pkg__",
],
)
################################################################################
@ -48,12 +48,12 @@ genrule(
":source_files",
"@utf8_range//:utf8_range_srcs",
],
tools = [":build_extension"],
outs = ["protobuf.so"],
cmd = """
./$(execpath :build_extension) $@
cp php/ext/google/protobuf/modules/protobuf.so $(OUTS)
""",
tools = [":build_extension"],
visibility = ["//visibility:public"],
)
@ -64,23 +64,23 @@ genrule(
conformance_test(
name = "conformance_test",
failure_list = "//conformance:failure_list_php.txt",
testee = "//conformance:conformance_php",
text_format_failure_list = "//conformance:text_format_failure_list_php.txt",
target_compatible_with = select({
"@platforms//os:osx": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
testee = "//conformance:conformance_php",
text_format_failure_list = "//conformance:text_format_failure_list_php.txt",
)
conformance_test(
name = "conformance_test_c",
failure_list = "//conformance:failure_list_php_c.txt",
testee = "//conformance:conformance_php_c",
text_format_failure_list = "//conformance:text_format_failure_list_php.txt",
target_compatible_with = select({
"@platforms//os:osx": [],
"//conditions:default": ["@platforms//:incompatible"],
}),
testee = "//conformance:conformance_php_c",
text_format_failure_list = "//conformance:text_format_failure_list_php.txt",
)
genrule(
@ -100,8 +100,8 @@ genrule(
staleness_test(
name = "test_amalgamation_staleness",
outs = [
"ext/google/protobuf/php-upb.h",
"ext/google/protobuf/php-upb.c",
"ext/google/protobuf/php-upb.h",
],
generated_pattern = "generated-in/%s",
tags = ["manual"],
@ -121,7 +121,6 @@ pkg_files(
"tests/proto/**/*.proto",
"tests/proto_previous/*.proto",
]) + [
":source_files",
"BUILD.bazel",
"README.md",
"REFCOUNTING.md",
@ -131,6 +130,7 @@ pkg_files(
"release.sh",
"src/phpdoc.dist.xml",
"tests/valgrind.supp",
":source_files",
],
prefix = "php",
strip_prefix = strip_prefix.from_pkg(""),
@ -142,71 +142,71 @@ pkg_files(
################################################################################
pkg_files(
name = "php_ext_source_files",
srcs = glob([
"ext/google/protobuf/*.h",
"ext/google/protobuf/*.c",
]) + [
"//:LICENSE",
"ext/google/protobuf/config.m4",
"ext/google/protobuf/config.w32",
"ext/google/protobuf/wkt.inc",
],
name = "php_ext_source_files",
srcs = glob([
"ext/google/protobuf/*.h",
"ext/google/protobuf/*.c",
]) + [
"ext/google/protobuf/config.m4",
"ext/google/protobuf/config.w32",
"ext/google/protobuf/wkt.inc",
"//:LICENSE",
],
)
pkg_files(
name = "utf8_range_files",
srcs = [
"@utf8_range//:utf8_range_srcs",
"@utf8_range//:LICENSE",
],
prefix = "third_party/utf8_range",
name = "utf8_range_files",
srcs = [
"@utf8_range//:LICENSE",
"@utf8_range//:utf8_range_srcs",
],
prefix = "third_party/utf8_range",
)
pkg_filegroup(
name = "pecl_release_files",
srcs = [
":php_ext_source_files",
":utf8_range_files",
],
prefix = "protobuf-%s" % PROTOBUF_PHP_VERSION,
name = "pecl_release_files",
srcs = [
":php_ext_source_files",
":utf8_range_files",
],
prefix = "protobuf-%s" % PROTOBUF_PHP_VERSION,
)
# PECL .tgz without package.xml
pkg_tar(
name = "release_without_package",
extension = "tgz",
srcs = [
":pecl_release_files",
],
out = "release_without_package.tgz",
name = "release_without_package",
srcs = [
":pecl_release_files",
],
out = "release_without_package.tgz",
extension = "tgz",
)
# Generate PECL package.xml
genrule(
name = "generate_package_xml",
srcs = [
":release_without_package",
"ext/google/protobuf/template_package.xml",
":release_without_package",
"ext/google/protobuf/template_package.xml",
],
outs = ["package.xml"],
cmd = " ".join([
"$(location ext/google/protobuf/generate_package_xml.sh)",
"$(location ext/google/protobuf/template_package.xml)",
PROTOBUF_PHP_VERSION,
PROTOC_VERSION,
"$$(tar -tf $(location :release_without_package) | sed -z -e 's;\\n;,;g')",
"$(location package.xml)"
"$(location ext/google/protobuf/generate_package_xml.sh)",
"$(location ext/google/protobuf/template_package.xml)",
PROTOBUF_PHP_VERSION,
PROTOC_VERSION,
"$$(tar -tf $(location :release_without_package) | sed -z -e 's;\\n;,;g')",
"$(location package.xml)",
]),
tools = ["ext/google/protobuf/generate_package_xml.sh"],
)
pkg_tar(
name = "release",
extension = "tgz",
srcs = [
":pecl_release_files",
":generate_package_xml",
],
out = "protobuf-%s.tgz" % PROTOBUF_PHP_VERSION,
name = "release",
srcs = [
":generate_package_xml",
":pecl_release_files",
],
out = "protobuf-%s.tgz" % PROTOBUF_PHP_VERSION,
extension = "tgz",
)

View File

@ -234,10 +234,10 @@ cc_dist_library(
],
tags = ["manual"],
deps = [
"//src/google/protobuf:internal_visibility_for_testing",
"//src/google/protobuf:test_textproto",
"//src/google/protobuf/compiler:command_line_interface_tester",
"//src/google/protobuf/compiler:mock_code_generator",
"//src/google/protobuf/testing",
"//src/google/protobuf:internal_visibility_for_testing",
],
)

View File

@ -6,11 +6,11 @@
# https://developers.google.com/open-source/licenses/bsd
load(
"//upb/bazel:build_defs.bzl",
"//bazel:build_defs.bzl",
"UPB_DEFAULT_CPPOPTS",
)
load(
"//upb/protos/bazel:upb_cc_proto_library.bzl",
"//protos/bazel:upb_cc_proto_library.bzl",
"upb_cc_proto_library_copts",
)
@ -133,10 +133,10 @@ cc_test(
copts = UPB_DEFAULT_CPPOPTS,
deps = [
":protos_internal",
"//upb:mem",
"//upb/protos_generator/tests:test_model_upb_cc_proto",
"//upb/protos_generator/tests:test_model_upb_proto",
"@com_google_googletest//:gtest_main",
"//upb:mem",
"//protos_generator/tests:test_model_upb_cc_proto",
"//protos_generator/tests:test_model_upb_proto",
],
)
@ -159,12 +159,12 @@ cc_test(
name = "protos_extension_lock_test",
srcs = ["protos_extension_lock_test.cc"],
deps = [
"@com_google_googletest//:gtest_main",
"//upb:mem",
"//upb/protos",
"//upb/protos:protos_extension_lock",
"//upb/protos_generator/tests:test_model_upb_cc_proto",
"//protos",
"//protos:protos_extension_lock",
"//protos_generator/tests:test_model_upb_cc_proto",
"@com_google_absl//absl/hash",
"@com_google_absl//absl/log:absl_check",
"@com_google_googletest//:gtest_main",
],
)

7
protos/README.md Normal file
View File

@ -0,0 +1,7 @@
`protos` C++ API
===============
`protos` is a C++ protobuf implementation backed by μpb, introduced in 2022.
The API is currently experimental and may undergo incompatible changes without
notice. The supported C++ implementation is
[here](https://github.com/protocolbuffers/protobuf/tree/main/src).

View File

@ -18,8 +18,8 @@ bzl_library(
srcs = ["upb_cc_proto_library.bzl"],
visibility = ["//visibility:public"],
deps = [
"//upb/bazel:upb_proto_library_bzl",
"@bazel_skylib//lib:paths",
"//bazel:upb_proto_library_bzl",
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
],
)

View File

@ -10,7 +10,7 @@
"""
load("@bazel_skylib//lib:paths.bzl", "paths")
load("//upb/bazel:upb_proto_library.bzl", "GeneratedSrcsInfo", "UpbWrappedCcInfo", "upb_proto_library_aspect")
load("//bazel:upb_proto_library.bzl", "GeneratedSrcsInfo", "UpbWrappedCcInfo", "upb_proto_library_aspect")
# begin:google_only
# load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
@ -229,12 +229,12 @@ def _upb_cc_proto_library_aspect_impl(target, ctx):
_upb_cc_proto_library_aspect = aspect(
attrs = {
"_ccopts": attr.label(
default = "//upb/protos:upb_cc_proto_library_copts__for_generated_code_only_do_not_use",
default = "//protos:upb_cc_proto_library_copts__for_generated_code_only_do_not_use",
),
"_gen_upbprotos": attr.label(
executable = True,
cfg = "exec",
default = "//upb/protos_generator:protoc-gen-upb-protos",
default = "//protos_generator:protoc-gen-upb-protos",
),
"_protoc": attr.label(
executable = True,
@ -248,11 +248,11 @@ _upb_cc_proto_library_aspect = aspect(
default = [
# TODO: Add dependencies for cc runtime (absl/string etc..)
"//upb:generated_cpp_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
"//upb/protos:generated_protos_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
"//protos:generated_protos_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/status:statusor",
"//upb/protos",
"//upb/protos:repeated_field",
"//protos",
"//protos:repeated_field",
],
),
},
@ -283,7 +283,7 @@ upb_cc_proto_library = rule(
providers = [ProtoInfo],
),
"_ccopts": attr.label(
default = "//upb/protos:upb_cc_proto_library_copts__for_generated_code_only_do_not_use",
default = "//protos:upb_cc_proto_library_copts__for_generated_code_only_do_not_use",
),
},
)

View File

@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos/protos.h"
#include "protos/protos.h"
#include <atomic>
#include <cstddef>
@ -37,17 +37,17 @@
#include "absl/status/statusor.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "upb/protos/protos_extension_lock.h"
#include "upb/upb/mem/arena.h"
#include "upb/upb/message/copy.h"
#include "upb/upb/message/internal/extension.h"
#include "upb/upb/message/promote.h"
#include "upb/upb/message/types.h"
#include "upb/upb/mini_table/extension.h"
#include "upb/upb/mini_table/extension_registry.h"
#include "upb/upb/mini_table/message.h"
#include "upb/upb/wire/decode.h"
#include "upb/upb/wire/encode.h"
#include "protos/protos_extension_lock.h"
#include "upb/mem/arena.h"
#include "upb/message/copy.h"
#include "upb/message/internal/extension.h"
#include "upb/message/promote.h"
#include "upb/message/types.h"
#include "upb/mini_table/extension.h"
#include "upb/mini_table/extension_registry.h"
#include "upb/mini_table/message.h"
#include "upb/wire/decode.h"
#include "upb/wire/encode.h"
namespace protos {

View File

@ -36,13 +36,13 @@
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "upb/upb/base/status.hpp"
#include "upb/upb/mem/arena.hpp"
#include "upb/upb/message/copy.h"
#include "upb/upb/message/internal/accessors.h"
#include "upb/upb/message/internal/extension.h"
#include "upb/upb/wire/decode.h"
#include "upb/upb/wire/encode.h"
#include "upb/base/status.hpp"
#include "upb/mem/arena.hpp"
#include "upb/message/copy.h"
#include "upb/message/internal/accessors.h"
#include "upb/message/internal/extension.h"
#include "upb/wire/decode.h"
#include "upb/wire/encode.h"
namespace protos {

View File

@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos/protos_extension_lock.h"
#include "protos/protos_extension_lock.h"
#include <atomic>

View File

@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos/protos_extension_lock.h"
#include "protos/protos_extension_lock.h"
#include <atomic>
#include <mutex>
@ -39,9 +39,9 @@
#include <gtest/gtest.h>
#include "absl/hash/hash.h"
#include "absl/log/absl_check.h"
#include "upb/protos/protos.h"
#include "upb/protos_generator/tests/test_model.upb.proto.h"
#include "upb/upb/mem/arena.hpp"
#include "protos/protos.h"
#include "protos_generator/tests/test_model.upb.proto.h"
#include "upb/mem/arena.hpp"
#ifndef ASSERT_OK
#define ASSERT_OK(x) ASSERT_TRUE(x.ok())

View File

@ -31,8 +31,8 @@
#ifndef UPB_PROTOS_PROTOS_INTERNAL_H_
#define UPB_PROTOS_PROTOS_INTERNAL_H_
#include "upb/upb/mem/arena.h"
#include "upb/upb/message/message.h"
#include "upb/mem/arena.h"
#include "upb/message/message.h"
namespace protos::internal {

View File

@ -28,13 +28,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos/protos_internal.h"
#include "protos/protos_internal.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "upb/protos_generator/tests/test_model.upb.h"
#include "upb/protos_generator/tests/test_model.upb.proto.h"
#include "upb/upb/mem/arena.h"
#include "protos_generator/tests/test_model.upb.h"
#include "protos_generator/tests/test_model.upb.proto.h"
#include "upb/mem/arena.h"
namespace protos::testing {
namespace {

View File

@ -36,17 +36,17 @@
#include <type_traits>
#include "absl/strings/string_view.h"
#include "upb/protos/protos.h"
#include "upb/protos/protos_traits.h"
#include "upb/protos/repeated_field_iterator.h"
#include "upb/upb/base/string_view.h"
#include "upb/upb/collections/array.h"
#include "upb/upb/mem/arena.h"
#include "upb/upb/message/copy.h"
#include "upb/upb/message/types.h"
#include "protos/protos.h"
#include "protos/protos_traits.h"
#include "protos/repeated_field_iterator.h"
#include "upb/base/string_view.h"
#include "upb/collections/array.h"
#include "upb/mem/arena.h"
#include "upb/message/copy.h"
#include "upb/message/types.h"
// Must be last:
#include "upb/upb/port/def.inc"
#include "upb/port/def.inc"
namespace protos {
@ -320,6 +320,6 @@ class RepeatedField {
} // namespace protos
#include "upb/upb/port/undef.inc"
#include "upb/port/undef.inc"
#endif // UPB_PROTOS_REPEATED_FIELD_H_

View File

@ -36,15 +36,15 @@
#include <type_traits>
#include "absl/strings/string_view.h"
#include "upb/protos/protos.h"
#include "upb/upb/base/string_view.h"
#include "upb/upb/collections/array.h"
#include "upb/upb/mem/arena.h"
#include "upb/upb/message/copy.h"
#include "protos/protos.h"
#include "upb/base/string_view.h"
#include "upb/collections/array.h"
#include "upb/mem/arena.h"
#include "upb/message/copy.h"
// Must be last:
#include "upb/upb/message/types.h"
#include "upb/upb/port/def.inc"
#include "upb/message/types.h"
#include "upb/port/def.inc"
namespace protos {
namespace internal {

View File

@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos/repeated_field_iterator.h"
#include "protos/repeated_field_iterator.h"
#include <algorithm>
#include <array>

View File

@ -6,7 +6,7 @@
# https://developers.google.com/open-source/licenses/bsd
load(
"//upb/bazel:build_defs.bzl",
"//bazel:build_defs.bzl",
"UPB_DEFAULT_CPPOPTS",
)
@ -30,7 +30,7 @@ cc_binary(
":output",
"//:protobuf",
"//src/google/protobuf/compiler:code_generator",
"//upb/upbc:file_layout",
"//upbc:file_layout",
],
)
@ -56,12 +56,12 @@ cc_library(
":names",
":output",
"//:protobuf",
"//upb/upbc:common",
"//upb/upbc:file_layout",
"//upb/upbc:keywords",
"//upb/upbc:names",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",
"//upbc:common",
"//upbc:file_layout",
"//upbc:keywords",
"//upbc:names",
],
)
@ -96,6 +96,6 @@ cc_library(
visibility = ["//visibility:private"],
deps = [
":output",
"//upb/upbc:keywords",
"//upbc:keywords",
],
)

View File

@ -0,0 +1,8 @@
`protos` Generator
==================
This directory contains the generator for the [`protos`
API](https://github.com/protocolbuffers/protobuf/tree/main/protos), an
experimental C++ protobuf implementation. Most users should use the standard
C++ implementation
[here](https://github.com/protocolbuffers/protobuf/tree/main/src).

View File

@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos_generator/gen_accessors.h"
#include "protos_generator/gen_accessors.h"
#include <string>
@ -37,13 +37,13 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/descriptor.h"
#include "upb/protos_generator/gen_repeated_fields.h"
#include "upb/protos_generator/gen_utils.h"
#include "upb/protos_generator/names.h"
#include "upb/protos_generator/output.h"
#include "upb/upbc/common.h"
#include "upb/upbc/keywords.h"
#include "upb/upbc/names.h"
#include "protos_generator/gen_repeated_fields.h"
#include "protos_generator/gen_utils.h"
#include "protos_generator/names.h"
#include "protos_generator/output.h"
#include "upbc/common.h"
#include "upbc/keywords.h"
#include "upbc/names.h"
namespace protos_generator {

View File

@ -32,8 +32,8 @@
#define UPB_PROTOS_GENERATOR_ACCESSORS_H_
#include "google/protobuf/descriptor.h"
#include "upb/protos_generator/gen_utils.h"
#include "upb/protos_generator/output.h"
#include "protos_generator/gen_utils.h"
#include "protos_generator/output.h"
namespace protos_generator {

View File

@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos_generator/gen_enums.h"
#include "protos_generator/gen_enums.h"
#include <algorithm>
#include <limits>
@ -37,8 +37,8 @@
#include "google/protobuf/descriptor.pb.h"
#include "google/protobuf/descriptor.h"
#include "upb/protos_generator/gen_utils.h"
#include "upb/protos_generator/names.h"
#include "protos_generator/gen_utils.h"
#include "protos_generator/names.h"
namespace protos_generator {

View File

@ -32,7 +32,7 @@
#define UPB_PROTOS_GENERATOR_ENUMS_H_
#include "google/protobuf/descriptor.h"
#include "upb/protos_generator/output.h"
#include "protos_generator/output.h"
namespace protos_generator {

View File

@ -28,11 +28,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos_generator/gen_extensions.h"
#include "protos_generator/gen_extensions.h"
#include "absl/strings/str_cat.h"
#include "upb/protos_generator/gen_utils.h"
#include "upb/protos_generator/names.h"
#include "protos_generator/gen_utils.h"
#include "protos_generator/names.h"
namespace protos_generator {

View File

@ -32,7 +32,7 @@
#define UPB_PROTOS_GENERATOR_GEN_EXTENSIONS_H_
#include "google/protobuf/descriptor.h"
#include "upb/protos_generator/output.h"
#include "protos_generator/output.h"
namespace protos_generator {

View File

@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos_generator/gen_messages.h"
#include "protos_generator/gen_messages.h"
#include <string>
#include <vector>
@ -36,14 +36,14 @@
#include "google/protobuf/descriptor.pb.h"
#include "absl/strings/str_cat.h"
#include "google/protobuf/descriptor.h"
#include "upb/protos_generator/gen_accessors.h"
#include "upb/protos_generator/gen_enums.h"
#include "upb/protos_generator/gen_extensions.h"
#include "upb/protos_generator/gen_utils.h"
#include "upb/protos_generator/names.h"
#include "upb/protos_generator/output.h"
#include "upb/upbc/common.h"
#include "upb/upbc/file_layout.h"
#include "protos_generator/gen_accessors.h"
#include "protos_generator/gen_enums.h"
#include "protos_generator/gen_extensions.h"
#include "protos_generator/gen_utils.h"
#include "protos_generator/names.h"
#include "protos_generator/output.h"
#include "upbc/common.h"
#include "upbc/file_layout.h"
namespace protos_generator {

View File

@ -32,7 +32,7 @@
#define UPB_PROTOS_GENERATOR_GEN_MESSAGES_H_
#include "google/protobuf/descriptor.h"
#include "upb/protos_generator/output.h"
#include "protos_generator/output.h"
namespace protos_generator {
namespace protobuf = ::google::protobuf;

View File

@ -27,7 +27,7 @@
// 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.
#include "upb/protos_generator/gen_repeated_fields.h"
#include "protos_generator/gen_repeated_fields.h"
#include <string>
#include <vector>
@ -35,15 +35,15 @@
#include "google/protobuf/descriptor.pb.h"
#include "absl/strings/string_view.h"
#include "google/protobuf/descriptor.h"
#include "upb/protos_generator/gen_accessors.h"
#include "upb/protos_generator/gen_enums.h"
#include "upb/protos_generator/gen_extensions.h"
#include "upb/protos_generator/gen_utils.h"
#include "upb/protos_generator/names.h"
#include "upb/protos_generator/output.h"
#include "upb/upbc/common.h"
#include "upb/upbc/file_layout.h"
#include "upb/upbc/names.h"
#include "protos_generator/gen_accessors.h"
#include "protos_generator/gen_enums.h"
#include "protos_generator/gen_extensions.h"
#include "protos_generator/gen_utils.h"
#include "protos_generator/names.h"
#include "protos_generator/output.h"
#include "upbc/common.h"
#include "upbc/file_layout.h"
#include "upbc/names.h"
namespace protos_generator {
namespace protobuf = ::google::protobuf;

View File

@ -33,7 +33,7 @@
#include "absl/strings/string_view.h"
#include "google/protobuf/descriptor.h"
#include "upb/protos_generator/output.h"
#include "protos_generator/output.h"
namespace protos_generator {
namespace protobuf = ::google::protobuf;

View File

@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos_generator/gen_utils.h"
#include "protos_generator/gen_utils.h"
#include <algorithm>
#include <string>

View File

@ -28,11 +28,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos_generator/names.h"
#include "protos_generator/names.h"
#include <string>
#include "upb/upbc/keywords.h"
#include "upbc/keywords.h"
namespace protos_generator {

View File

@ -34,7 +34,7 @@
#include <string>
#include "google/protobuf/descriptor.pb.h"
#include "upb/protos_generator/output.h"
#include "protos_generator/output.h"
namespace protos_generator {

View File

@ -28,7 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "upb/protos_generator/output.h"
#include "protos_generator/output.h"
#include <string>

View File

@ -34,13 +34,13 @@
#include "google/protobuf/compiler/code_generator.h"
#include "google/protobuf/compiler/plugin.h"
#include "google/protobuf/descriptor.h"
#include "upb/protos_generator/gen_enums.h"
#include "upb/protos_generator/gen_extensions.h"
#include "upb/protos_generator/gen_messages.h"
#include "upb/protos_generator/gen_utils.h"
#include "upb/protos_generator/names.h"
#include "upb/protos_generator/output.h"
#include "upb/upbc/file_layout.h"
#include "protos_generator/gen_enums.h"
#include "protos_generator/gen_extensions.h"
#include "protos_generator/gen_messages.h"
#include "protos_generator/gen_utils.h"
#include "protos_generator/names.h"
#include "protos_generator/output.h"
#include "upbc/file_layout.h"
namespace protos_generator {
namespace {
@ -138,9 +138,9 @@ void WriteHeader(const protobuf::FileDescriptor* file, Output& output) {
#ifndef $0_UPB_PROTO_H_
#define $0_UPB_PROTO_H_
#include "upb/protos/protos.h"
#include "upb/protos/protos_internal.h"
#include "upb/protos/repeated_field.h"
#include "protos/protos.h"
#include "protos/protos_internal.h"
#include "protos/repeated_field.h"
#include "absl/strings/string_view.h"
#include "absl/status/statusor.h"
@ -158,7 +158,7 @@ void WriteHeader(const protobuf::FileDescriptor* file, Output& output) {
}
}
output("#include \"upb/upb/port/def.inc\"\n");
output("#include \"upb/port/def.inc\"\n");
const std::vector<const protobuf::Descriptor*> this_file_messages =
SortedMessages(file);
@ -190,7 +190,7 @@ void WriteHeader(const protobuf::FileDescriptor* file, Output& output) {
WriteEndNamespace(file, output);
output("\n#include \"upb/upb/port/undef.inc\"\n\n");
output("\n#include \"upb/port/undef.inc\"\n\n");
// End of "C" section.
output("#endif /* $0_UPB_PROTO_H_ */\n", ToPreproc(file->name()));
@ -205,7 +205,7 @@ void WriteSource(const protobuf::FileDescriptor* file, Output& output,
R"cc(
#include <stddef.h>
#include "absl/strings/string_view.h"
#include "upb/protos/protos.h"
#include "protos/protos.h"
#include "$0"
)cc",
CppHeaderFilename(file));
@ -213,7 +213,7 @@ void WriteSource(const protobuf::FileDescriptor* file, Output& output,
for (int i = 0; i < file->dependency_count(); i++) {
output("#include \"$0\"\n", CppHeaderFilename(file->dependency(i)));
}
output("#include \"upb/upb/port/def.inc\"\n");
output("#include \"upb/port/def.inc\"\n");
WriteStartNamespace(file, output);
WriteMessageImplementations(file, output);
@ -222,7 +222,7 @@ void WriteSource(const protobuf::FileDescriptor* file, Output& output,
WriteExtensionIdentifiers(this_file_exts, output);
WriteEndNamespace(file, output);
output("#include \"upb/upb/port/undef.inc\"\n\n");
output("#include \"upb/port/undef.inc\"\n\n");
}
void WriteMessageImplementations(const protobuf::FileDescriptor* file,

View File

@ -6,15 +6,15 @@
# https://developers.google.com/open-source/licenses/bsd
load(
"//upb/bazel:build_defs.bzl",
"//bazel:build_defs.bzl",
"UPB_DEFAULT_CPPOPTS",
)
load(
"//upb/bazel:upb_proto_library.bzl",
"//bazel:upb_proto_library.bzl",
"upb_proto_library",
)
load(
"//upb/protos/bazel:upb_cc_proto_library.bzl",
"//protos/bazel:upb_cc_proto_library.bzl",
"upb_cc_proto_library",
)
load(
@ -63,14 +63,14 @@ proto_library(
upb_proto_library(
name = "test_model_upb_proto",
visibility = [
"//upb/protos:__pkg__",
"//protos:__pkg__",
],
deps = [":test_model_proto"],
)
upb_cc_proto_library(
name = "test_model_upb_cc_proto",
visibility = ["//upb/protos:__pkg__"],
visibility = ["//protos:__pkg__"],
deps = [":test_model_proto"],
)
@ -133,8 +133,8 @@ cc_test(
"@com_google_googletest//:gtest_main",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"//upb/protos",
"//protos",
"//upb:mem",
"//upb/protos:repeated_field",
"//protos:repeated_field",
],
)

Some files were not shown because too many files have changed in this diff Show More