Migrated upb to use Copybara-standard stripping.

This CL is mostly a no-op, except that now google3-only code is actually stripped from OSS, instead of being preserved in `# begin:google_only` blocks.

This follows the conventions of the greater Copybara ecosystem.

PiperOrigin-RevId: 669513564
pull/18058/head
Joshua Haberman 7 months ago committed by Copybara-Service
parent e4449ba248
commit 8422e9795f
  1. 6
      bazel/private/upb_proto_library_internal/aspect.bzl
  2. 26
      bazel/private/upb_proto_library_internal/cc_library_func.bzl
  3. 6
      benchmarks/build_defs.bzl
  4. 4
      hpb/BUILD
  5. 4
      hpb/backend/upb/BUILD
  6. 26
      hpb/bazel/upb_cc_proto_library.bzl
  7. 48
      hpb/hpb.cc
  8. 20
      hpb/hpb.h
  9. 4
      hpb/internal/BUILD
  10. 4
      hpb_generator/BUILD
  11. 150
      hpb_generator/tests/BUILD
  12. 16
      lua/lua_proto_library.bzl
  13. 23
      protos/BUILD
  14. 15
      python/BUILD.bazel
  15. 23
      python/dist/py_proto_library.bzl
  16. 6
      python/pb_unit_tests/BUILD
  17. 8
      python/pb_unit_tests/descriptor_pool_test_wrapper.py
  18. 26
      python/pb_unit_tests/pyproto_test_wrapper.bzl
  19. 6
      python/protobuf.c
  20. 9
      python/protobuf.h
  21. 6
      rust/BUILD
  22. 5
      rust/upb/BUILD
  23. 58
      upb/BUILD
  24. 2
      upb/base/BUILD
  25. 10
      upb/bazel/BUILD
  26. 10
      upb/bazel/build_defs.bzl
  27. 4
      upb/hash/BUILD
  28. 21
      upb/json/BUILD
  29. 4
      upb/lex/BUILD
  30. 4
      upb/mem/BUILD
  31. 4
      upb/message/BUILD
  32. 197
      upb/message/test.cc
  33. 54
      upb/message/utf8_test.cc
  34. 4
      upb/message/utf8_test.proto
  35. 4
      upb/mini_descriptor/BUILD
  36. 22
      upb/mini_descriptor/internal/encode_test.cc
  37. 4
      upb/mini_table/BUILD
  38. 2
      upb/port/BUILD
  39. 5
      upb/port/def.inc
  40. 30
      upb/reflection/BUILD
  41. 14
      upb/reflection/field_def.c
  42. 2
      upb/test/BUILD
  43. 2
      upb/text/BUILD
  44. 7
      upb/text/encode.c
  45. 17
      upb/util/BUILD
  46. 22
      upb/util/def_to_proto_test.cc
  47. 4
      upb/wire/BUILD
  48. 315
      upb/wire/eps_copy_input_stream_test.cc
  49. 18
      upb_generator/bootstrap_compiler.bzl
  50. 2
      upb_generator/c/generator.cc

@ -6,13 +6,7 @@ load("//bazel/common:proto_info.bzl", "ProtoInfo")
load(":upb_proto_library_internal/cc_library_func.bzl", "cc_library_func")
load(":upb_proto_library_internal/copts.bzl", "UpbProtoLibraryCoptsInfo")
# begin:github_only
_is_google3 = False
# end:github_only
# begin:google_only
# _is_google3 = True
# end:google_only
GeneratedSrcsInfo = provider(
"Provides generated headers and sources",

@ -2,25 +2,9 @@
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
# begin:google_only
#
# def upb_use_cpp_toolchain():
# # TODO: We shouldn't need to add this to the result of use_cpp_toolchain().
# return [
# config_common.toolchain_type(
# "@bazel_tools//tools/cpp:cc_runtimes_toolchain_type",
# mandatory = False,
# ),
# ] + use_cpp_toolchain()
#
# end:google_only
# begin:github_only
def upb_use_cpp_toolchain():
return use_cpp_toolchain()
# end:github_only
def cc_library_func(ctx, name, hdrs, srcs, copts, includes, dep_ccinfos):
"""Like cc_library(), but callable from rules.
@ -37,16 +21,6 @@ def cc_library_func(ctx, name, hdrs, srcs, copts, includes, dep_ccinfos):
CcInfo provider for this compilation.
"""
# begin:google_only
# cc_runtimes_toolchain = ctx.toolchains["@bazel_tools//tools/cpp:cc_runtimes_toolchain_type"]
# if cc_runtimes_toolchain:
# dep_ccinfos += [
# target[CcInfo]
# for target in cc_runtimes_toolchain.cc_runtimes_info.runtimes
# ]
#
# end:google_only
compilation_contexts = [info.compilation_context for info in dep_ccinfos]
linking_contexts = [info.linking_context for info in dep_ccinfos]
toolchain = find_cpp_toolchain(ctx)

@ -8,13 +8,7 @@
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
# begin:google_only
# _is_google3 = True
# end:google_only
# begin:github_only
_is_google3 = False
# end:github_only
def tmpl_cc_binary(name, gen, args, replacements = [], **kwargs):
srcs = [name + ".cc"]

@ -14,9 +14,7 @@ load(
"UPB_DEFAULT_CPPOPTS",
)
# begin:google_only
# package(default_applicable_licenses = ["//:license"])
# end:google_only
package(default_applicable_licenses = ["//:license"])
licenses(["notice"])

@ -5,9 +5,7 @@
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
# begin:google_only
# package(default_applicable_licenses = ["//:license"])
# end:google_only
package(default_applicable_licenses = ["//:license"])
cc_library(
name = "upb",

@ -13,25 +13,9 @@ load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
load("//bazel:upb_proto_library.bzl", "GeneratedSrcsInfo", "UpbWrappedCcInfo", "upb_proto_library_aspect")
# begin:google_only
#
# def upb_use_cpp_toolchain():
# # TODO: We shouldn't need to add this to the result of use_cpp_toolchain().
# return [
# config_common.toolchain_type(
# "@bazel_tools//tools/cpp:cc_runtimes_toolchain_type",
# mandatory = False,
# ),
# ] + use_cpp_toolchain()
#
# end:google_only
# begin:github_only
def upb_use_cpp_toolchain():
return use_cpp_toolchain()
# end:github_only
# Generic support code #########################################################
def _get_real_short_path(file):
@ -80,16 +64,6 @@ def _cc_library_func(ctx, name, hdrs, srcs, copts, dep_ccinfos):
CcInfo provider for this compilation.
"""
# begin:google_only
# cc_runtimes_toolchain = ctx.toolchains["@bazel_tools//tools/cpp:cc_runtimes_toolchain_type"]
# if cc_runtimes_toolchain:
# dep_ccinfos += [
# target[CcInfo]
# for target in cc_runtimes_toolchain.cc_runtimes_info.runtimes
# ]
#
# end:google_only
compilation_contexts = [info.compilation_context for info in dep_ccinfos]
linking_contexts = [info.linking_context for info in dep_ccinfos]
toolchain = find_cpp_toolchain(ctx)

@ -29,57 +29,25 @@
namespace hpb {
// begin:google_only
absl::Status MessageAllocationError(SourceLocation loc) {
return absl::Status(absl::StatusCode::kInternal,
"Upb message allocation error", loc);
return absl::Status(absl::StatusCode::kUnknown,
"Upb message allocation error");
}
absl::Status ExtensionNotFoundError(int extension_number, SourceLocation loc) {
return absl::Status(
absl::StatusCode::kInternal,
absl::StrFormat("Extension %d not found", extension_number), loc);
absl::Status ExtensionNotFoundError(int ext_number, SourceLocation loc) {
return absl::Status(absl::StatusCode::kUnknown,
absl::StrFormat("Extension %d not found", ext_number));
}
absl::Status MessageEncodeError(upb_EncodeStatus status, SourceLocation loc) {
return absl::Status(absl::StatusCode::kInternal,
absl::StrFormat("Upb message encoding error %d", status),
loc
);
absl::Status MessageEncodeError(upb_EncodeStatus s, SourceLocation loc) {
return absl::Status(absl::StatusCode::kUnknown, "Encoding error");
}
absl::Status MessageDecodeError(upb_DecodeStatus status, SourceLocation loc
) {
return absl::Status(absl::StatusCode::kInternal,
absl::StrFormat("Upb message parse error %d", status), loc
);
return absl::Status(absl::StatusCode::kUnknown, "Upb message parse error");
}
// end:google_only
// begin:github_only
// absl::Status MessageAllocationError(SourceLocation loc) {
// return absl::Status(absl::StatusCode::kUnknown,
// "Upb message allocation error");
// }
//
// absl::Status ExtensionNotFoundError(int ext_number, SourceLocation loc) {
// return absl::Status(absl::StatusCode::kUnknown,
// absl::StrFormat("Extension %d not found", ext_number));
// }
//
// absl::Status MessageEncodeError(upb_EncodeStatus s, SourceLocation loc) {
// return absl::Status(absl::StatusCode::kUnknown, "Encoding error");
// }
//
// absl::Status MessageDecodeError(upb_DecodeStatus status, SourceLocation loc
//
// ) {
// return absl::Status(absl::StatusCode::kUnknown, "Upb message parse error");
// }
// end:github_only
namespace internal {

@ -51,19 +51,13 @@ inline upb_StringView UpbStrFromStringView(absl::string_view str,
return upb_StringView_FromDataAndSize(buffer, str_size);
}
// begin:github_only
// // This type exists to work around an absl type that has not yet been
// // released.
// struct SourceLocation {
// static SourceLocation current() { return {}; }
// absl::string_view file_name() { return "<unknown>"; }
// int line() { return 0; }
// };
// end:github_only
// begin:google_only
using SourceLocation = absl::SourceLocation;
// end:google_only
// This type exists to work around an absl type that has not yet been
// released.
struct SourceLocation {
static SourceLocation current() { return {}; }
absl::string_view file_name() { return "<unknown>"; }
int line() { return 0; }
};
absl::Status MessageAllocationError(
SourceLocation loc = SourceLocation::current());

@ -10,9 +10,7 @@ load(
"UPB_DEFAULT_CPPOPTS",
)
# begin:google_only
# package(default_applicable_licenses = ["//:license"])
# end:google_only
package(default_applicable_licenses = ["//:license"])
cc_library(
name = "template_help",

@ -10,9 +10,7 @@ load(
"UPB_DEFAULT_CPPOPTS",
)
# begin:google_only
# package(default_applicable_licenses = ["//:license"])
# end:google_only
package(default_applicable_licenses = ["//:license"])
licenses(["notice"])

@ -6,157 +6,7 @@
# https://developers.google.com/open-source/licenses/bsd
# todo: re-add post migration
# begin:google_only
# load(
# "//bazel:cc_proto_library.bzl",
# "cc_proto_library",
# )
# load(
# "//hpb/bazel:upb_cc_proto_library.bzl",
# "upb_cc_proto_library",
# )
# load(
# "//bazel:upb_proto_library.bzl",
# "upb_c_proto_library",
# )
# load(
# "//upb/bazel:build_defs.bzl",
# "UPB_DEFAULT_CPPOPTS",
# )
# end:google_only
package(default_applicable_licenses = ["//:license"])
# todo: re-add post migration
# begin:google_only
# licenses(["notice"])
#
# proto_library(
# name = "test_model_proto",
# srcs = [
# "child_model.proto",
# "test_enum.proto",
# "test_extension.proto",
# "test_model.proto",
# ],
# )
#
# proto_library(
# name = "no_package_proto",
# srcs = [
# "no_package.proto",
# ],
# )
#
# proto_library(
# name = "naming_conflict_proto",
# srcs = [
# "naming_conflict.proto",
# ],
# )
#
# proto_library(
# name = "no_package_enum_user_proto",
# srcs = [
# "no_package_enum_user.proto",
# ],
# deps = [":no_package_proto"],
# )
#
# upb_c_proto_library(
# name = "test_model_upb_proto",
# visibility = [
# "//hpb:__subpackages__",
# "//protos:__pkg__",
# ],
# deps = [":test_model_proto"],
# )
#
# upb_cc_proto_library(
# name = "test_model_upb_cc_proto",
# visibility = [
# "//hpb:__subpackages__",
# "//protos:__pkg__",
# ],
# deps = [":test_model_proto"],
# )
#
# upb_cc_proto_library(
# name = "naming_conflict_upb_cc_proto",
# visibility = ["//visibility:private"],
# deps = [":naming_conflict_proto"],
# )
#
# upb_cc_proto_library(
# name = "no_package_upb_cc_proto",
# deps = [
# ":no_package_proto",
# ],
# )
#
# upb_cc_proto_library(
# name = "no_package_enum_user_upb_cc_proto",
# deps = [
# ":no_package_enum_user_proto",
# ],
# )
#
# cc_proto_library(
# name = "test_model_cc_proto",
# deps = [":test_model_proto"],
# )
# end:google_only
# begin:google_only
# proto_library(
# name = "legacy_name_proto",
# srcs = [
# "legacy-name.proto",
# ],
# )
#
# upb_cc_proto_library(
# name = "legacy_name_test_proto",
# visibility = ["//visibility:private"],
# deps = [":legacy_name_proto"],
# )
#
# proto_library(
# name = "basic_editions_proto",
# srcs = [
# "basic_test_editions.proto",
# ],
# )
#
# upb_cc_proto_library(
# name = "basic_test_editions_proto",
# visibility = ["//visibility:private"],
# deps = [":basic_editions_proto"],
# )
# end:google_only
# todo: re-add post migration
# begin:google_only
# cc_test(
# name = "test_generated_cc_code",
# srcs = ["test_generated.cc"],
# copts = UPB_DEFAULT_CPPOPTS,
# deps = [
# # google_only_begin_legacy_marker
# ":legacy_name_test_proto",
# # google_only_end_legacy_marker
# ":no_package_upb_cc_proto",
# ":test_model_upb_cc_proto",
# ":test_model_upb_proto",
# ":naming_conflict_upb_cc_proto",
# "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main",
# "@com_google_absl//absl/status:statusor",
# "@com_google_absl//absl/strings",
# "//hpb:requires",
# "//hpb",
# "//hpb:repeated_field",
# "//protos",
# "//upb:mem",
# ],
# )
# end:google_only

@ -11,14 +11,6 @@ load("//bazel/common:proto_info.bzl", "ProtoInfo")
# Generic support code #########################################################
# begin:github_only
_is_google3 = False
# end:github_only
# begin:google_only
# _is_google3 = True
# end:google_only
def _get_real_short_path(file):
# For some reason, files from other archives have short paths that look like:
# ../com_google_protobuf/google/protobuf/descriptor.proto
@ -39,14 +31,18 @@ def _get_real_short_path(file):
def _get_real_root(ctx, file):
real_short_path = _get_real_short_path(file)
root = file.path[:-len(real_short_path) - 1]
if not _is_google3 and ctx.rule.attr.strip_import_prefix:
if ctx.rule.attr.strip_import_prefix:
root = paths.join(root, ctx.rule.attr.strip_import_prefix[1:])
return root
def _generate_output_file(ctx, src, extension):
package = ctx.label.package
if not _is_google3 and ctx.rule.attr.strip_import_prefix and ctx.rule.attr.strip_import_prefix != "/":
if ctx.rule.attr.strip_import_prefix and ctx.rule.attr.strip_import_prefix != "/":
package = package[len(ctx.rule.attr.strip_import_prefix):]
real_short_path = _get_real_short_path(src)
real_short_path = paths.relativize(real_short_path, package)
output_filename = paths.replace_extension(real_short_path, extension)

@ -4,26 +4,3 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
# begin:google_only
# load(
# "//upb/bazel:build_defs.bzl",
# "UPB_DEFAULT_CPPOPTS",
# )
#
# package(default_applicable_licenses = ["//:license"])
#
# licenses(["notice"])
#
# cc_library(
# name = "protos",
# hdrs = [
# "protos.h",
# ],
# copts = UPB_DEFAULT_CPPOPTS,
# visibility = ["//visibility:public"],
# deps = [
# "//hpb",
# ],
# )
# end:google_only

@ -7,15 +7,12 @@
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
# begin:github_only
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
load("//python:build_targets.bzl", "build_targets")
load("//python:py_extension.bzl", "py_extension")
load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_COPTS")
build_targets(name = "python")
# end:github_only
licenses(["notice"])
@ -133,7 +130,6 @@ selects.config_setting_group(
],
)
# begin:github_only
_message_target_compatible_with = {
"@platforms//os:windows": ["@platforms//:incompatible"],
"@system_python//:none": ["@platforms//:incompatible"],
@ -141,14 +137,6 @@ _message_target_compatible_with = {
"//conditions:default": [],
}
# end:github_only
# begin:google_only
# _message_target_compatible_with = {
# "@platforms//os:windows": ["@platforms//:incompatible"],
# "//conditions:default": [],
# }
# end:google_only
filegroup(
name = "message_srcs",
srcs = [
@ -174,9 +162,6 @@ filegroup(
"unknown_fields.c",
"unknown_fields.h",
],
# begin:google_only
# compatible_with = ["//buildenv/target:non_prod"],
# end:google_only
)
py_extension(

@ -21,14 +21,6 @@ load("//bazel/common:proto_info.bzl", "ProtoInfo")
# Generic support code #########################################################
# begin:github_only
_is_google3 = False
# end:github_only
# begin:google_only
# _is_google3 = True
# end:google_only
def _get_real_short_path(file):
# For some reason, files from other archives have short paths that look like:
# ../com_google_protobuf/google/protobuf/descriptor.proto
@ -50,18 +42,19 @@ def _get_real_root(ctx, file):
real_short_path = _get_real_short_path(file)
root = file.path[:-len(real_short_path) - 1]
if not _is_google3 and ctx.rule.attr.strip_import_prefix:
if ctx.rule.attr.strip_import_prefix:
root = paths.join(root, ctx.rule.attr.strip_import_prefix[1:])
return root
def _generate_output_file(ctx, src, extension):
package = ctx.label.package
if not _is_google3:
strip_import_prefix = ctx.rule.attr.strip_import_prefix
if strip_import_prefix and strip_import_prefix != "/":
if not package.startswith(strip_import_prefix[1:]):
fail("%s does not begin with prefix %s" % (package, strip_import_prefix))
package = package[len(strip_import_prefix):]
strip_import_prefix = ctx.rule.attr.strip_import_prefix
if strip_import_prefix and strip_import_prefix != "/":
if not package.startswith(strip_import_prefix[1:]):
fail("%s does not begin with prefix %s" % (package, strip_import_prefix))
package = package[len(strip_import_prefix):]
real_short_path = _get_real_short_path(src)
real_short_path = paths.relativize(real_short_path, package)

@ -5,10 +5,6 @@
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
# begin:github_only
load("@pip_deps//:requirements.bzl", "requirement")
# end:github_only
load(":pyproto_test_wrapper.bzl", "pyproto_test_wrapper")
package(default_applicable_licenses = ["//:license"])
@ -19,9 +15,7 @@ pyproto_test_wrapper(name = "descriptor_pool_test")
pyproto_test_wrapper(name = "descriptor_test")
# begin:github_only
pyproto_test_wrapper(name = "generator_test")
# end:github_only
pyproto_test_wrapper(name = "message_factory_test")

@ -33,13 +33,5 @@ from google.protobuf.internal.descriptor_pool_test import *
SecondaryDescriptorFromDescriptorDB.testErrorCollector.__unittest_expecting_failure__ = True
# begin:github_only
if __name__ == '__main__':
unittest.main(verbosity=2)
# end:github_only
# begin:google_only
# from absl import app
# if __name__ == '__main__':
# app.run(lambda argv: unittest.main(verbosity=2))
# end:google_only

@ -1,4 +1,4 @@
# begin:github_only
"""Wrapper for another py_test to run with upb, possibly with a set of expected failures."""
def pyproto_test_wrapper(name, deps = []):
src = name + "_wrapper.py"
@ -20,27 +20,3 @@ def pyproto_test_wrapper(name, deps = []):
"//conditions:default": ["@platforms//:incompatible"],
}),
)
# end:github_only
# begin:google_only
#
# load("@rules_python//python:py_test.bzl", "py_test")
#
# def pyproto_test_wrapper(name):
# src = name + "_wrapper.py"
# py_test(
# name = name,
# srcs = [src],
# main = src,
# deps = [
# "//third_party/py/google/protobuf/internal:" + name + "_for_deps",
# "//third_party/py/google/protobuf:use_upb_protos",
# ],
# target_compatible_with = select({
# "@platforms//os:windows": ["@platforms//:incompatible"],
# "//conditions:default": [],
# }),
# )
#
# end:google_only

@ -203,11 +203,6 @@ typedef struct {
upb_Arena* arena;
} PyUpb_Arena;
// begin:google_only
// static upb_alloc* global_alloc = &upb_alloc_global;
// end:google_only
// begin:github_only
#ifdef __GLIBC__
#include <malloc.h> // malloc_trim()
#endif
@ -241,7 +236,6 @@ static void* upb_trim_allocfunc(upb_alloc* alloc, void* ptr, size_t oldsize,
}
static upb_alloc trim_alloc = {&upb_trim_allocfunc};
static upb_alloc* global_alloc = &trim_alloc;
// end:github_only
static upb_Arena* PyUpb_NewArena(void) {
return upb_Arena_Init(NULL, 0, global_alloc);

@ -14,19 +14,10 @@
#include "python/python_api.h"
#include "upb/hash/int_table.h"
// begin:github_only
#define PYUPB_PROTOBUF_PUBLIC_PACKAGE "google.protobuf"
#define PYUPB_PROTOBUF_INTERNAL_PACKAGE "google.protobuf.internal"
#define PYUPB_DESCRIPTOR_PROTO_PACKAGE "google.protobuf"
#define PYUPB_MODULE_NAME "google._upb._message"
// end:github_only
// begin:google_only
// #define PYUPB_PROTOBUF_PUBLIC_PACKAGE "google3.net.google.protobuf.python.public"
// #define PYUPB_PROTOBUF_INTERNAL_PACKAGE "google3.net.google.protobuf.python.internal"
// #define PYUPB_DESCRIPTOR_PROTO_PACKAGE "proto2"
// #define PYUPB_MODULE_NAME "google3.third_party.upb.python._message"
// end:google_only
#define PYUPB_DESCRIPTOR_MODULE "google.protobuf.descriptor_pb2"
#define PYUPB_RETURN_OOM return PyErr_SetNone(PyExc_MemoryError), NULL

@ -1,12 +1,8 @@
# Protobuf Rust runtime packages.
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
# begin:github_only
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
# end:github_only
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
@ -210,7 +206,6 @@ config_setting(
},
)
# begin:github_only
pkg_files(
name = "rust_protobuf_src",
srcs = glob(
@ -262,4 +257,3 @@ pkg_zip(
"//:LICENSE",
],
)
# end:github_only

@ -4,10 +4,7 @@
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
# begin:github_only
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
# end:github_only
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
package(default_applicable_licenses = ["//:license"])
@ -57,7 +54,6 @@ cc_library(
],
)
# begin:github_only
pkg_files(
name = "rust_protobuf_upb_src",
srcs = glob(
@ -68,4 +64,3 @@ pkg_files(
strip_prefix = strip_prefix.from_root("rust"),
visibility = ["//rust:__pkg__"],
)
# end:github_only

@ -8,18 +8,11 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@rules_python//python:defs.bzl", "py_binary")
load("//bazel/private:upb_proto_library_internal/copts.bzl", "upb_proto_library_copts")
load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_COPTS")
# begin:google_only
# load("//tools/build_defs/kotlin/native:rules.bzl", "kt_native_interop_hint")
# end:google_only
# begin:github_only
load(
"//upb/bazel:amalgamation.bzl",
"upb_amalgamation",
)
# end:github_only
load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_COPTS")
package(default_applicable_licenses = ["//:license"])
@ -225,8 +218,6 @@ alias(
# Amalgamation #################################################################
# begin:github_only
upb_amalgamation(
name = "gen_amalgamation",
outs = [
@ -433,50 +424,3 @@ filegroup(
],
visibility = ["//pkg:__pkg__"],
)
# end:github_only
# begin:google_only
#
# py_binary(
# name = "update_check_runs",
# srcs = ["update_check_runs.py"],
# main = "update_check_runs.py",
# deps = [
# "//third_party/py/absl:app",
# "//third_party/py/absl/flags",
# ],
# )
#
# kt_native_interop_hint(
# name = "upb_kotlin_native_hint",
# compatible_with = ["//buildenv/target:non_prod"],
# headers_to_exclude = glob([
# "**/*.hpp",
# ]),
# kotlin_package = "upb",
# no_string_conversion = [
# "_upb_MiniTable_Build",
# "upb_Decode",
# "upb_StringView_FromDataAndSize",
# ],
# strict_enums = [
# "upb_CType",
# "upb_DecodeStatus",
# "upb_EncodeStatus",
# "upb_FieldType",
# "upb_FindUnknown_Status",
# "upb_GetExtension_Status",
# "upb_GetExtensionAsBytes_Status",
# "upb_Label",
# "upb_MapInsertStatus",
# "upb_UnknownToMessage_Status",
# "upb_WireType",
# ],
# visibility = [
# "//third_party/bazel_rules/rules_kotlin/kotlin/native:__subpackages__",
# "//third_party/kotlin/protobuf:__subpackages__",
# "//upb:__subpackages__",
# ],
# )
#
# end:google_only

@ -37,7 +37,6 @@ cc_library(
deps = ["//upb:port"],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -52,4 +51,3 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only

@ -12,16 +12,6 @@ package(default_applicable_licenses = ["//:license"])
licenses(["notice"])
# begin:google_only
# selects.config_setting_group(
# name = "android_opt",
# match_all = [
# "//tools/cc_target_os:android",
# "//tools/compilation_mode:opt",
# ],
# )
# end:google_only
py_binary(
name = "amalgamate",
srcs = ["amalgamate.py"],

@ -10,7 +10,6 @@
_DEFAULT_CPPOPTS = []
_DEFAULT_COPTS = []
# begin:github_only
_DEFAULT_CPPOPTS.extend([
"-Wextra",
# "-Wshorten-64-to-32", # not in GCC (and my Kokoro images doesn't have Clang)
@ -26,24 +25,15 @@ _DEFAULT_COPTS.extend([
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
#"-Wno-maybe-uninitialized",
])
# end:github_only
UPB_DEFAULT_CPPOPTS = select({
"//upb:windows": [],
# begin:google_only
# # Override default -Oz for release builds on Android.
# "//upb/bazel:android_opt": _DEFAULT_CPPOPTS + ["-O2"],
# end:google_only
"//conditions:default": _DEFAULT_CPPOPTS,
})
UPB_DEFAULT_COPTS = select({
"//upb:windows": [],
"//upb:fasttable_enabled_setting": ["-std=gnu99", "-DUPB_ENABLE_FASTTABLE"],
# begin:google_only
# # Override default -Oz for release builds on Android.
# "//upb/bazel:android_opt": _DEFAULT_COPTS + ["-O2"],
# end:google_only
"//conditions:default": _DEFAULT_COPTS,
})

@ -42,7 +42,6 @@ cc_test(
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -56,9 +55,7 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only
# begin:github_only
filegroup(
name = "test_srcs",
srcs = glob(
@ -68,4 +65,3 @@ filegroup(
),
visibility = ["//pkg:__pkg__"],
)
# end:github_only

@ -91,26 +91,6 @@ upb_c_proto_library(
deps = ["//:struct_proto"],
)
# begin:google_only
# cc_test(
# name = "fuzz_test",
# srcs = ["fuzz_test.cc"],
# deps = [
# ":json",
# ":test_upb_proto",
# ":test_upb_proto_reflection",
# "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main",
# "//testing/fuzzing:fuzztest",
# "//upb:base",
# "//upb:mem",
# "//upb:message",
# "//upb:mini_table",
# "//upb:reflection",
# ],
# )
# end:google_only
# begin:github_only
filegroup(
name = "test_srcs",
srcs = glob(
@ -131,4 +111,3 @@ filegroup(
),
visibility = ["//upb:__pkg__"],
)
# end:github_only

@ -49,7 +49,6 @@ cc_test(
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -63,9 +62,7 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only
# begin:github_only
filegroup(
name = "test_srcs",
srcs = glob(
@ -75,4 +72,3 @@ filegroup(
),
visibility = ["//pkg:__pkg__"],
)
# end:github_only

@ -53,7 +53,6 @@ cc_test(
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -68,9 +67,7 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only
# begin:github_only
filegroup(
name = "test_srcs",
srcs = glob(
@ -80,4 +77,3 @@ filegroup(
),
visibility = ["//upb:__pkg__"],
)
# end:github_only

@ -430,7 +430,6 @@ cc_test(
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -444,9 +443,7 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only
# begin:github_only
filegroup(
name = "test_srcs",
srcs = glob(
@ -467,4 +464,3 @@ filegroup(
),
visibility = ["//upb:__pkg__"],
)
# end:github_only

@ -38,10 +38,6 @@
#include "upb/wire/decode.h"
#include "upb/wire/encode.h"
// begin:google_only
// #include "testing/fuzzing/fuzztest.h"
// end:google_only
void VerifyMessage(const upb_test_TestExtensions* ext_msg) {
EXPECT_TRUE(upb_test_TestExtensions_has_optional_int32_ext(ext_msg));
// EXPECT_FALSE(upb_test_TestExtensions_Nested_has_optional_int32_ext(ext_msg));
@ -583,196 +579,3 @@ TEST(MessageTest, Freeze) {
ASSERT_TRUE(upb_Message_IsFrozen(UPB_UPCAST(nest)));
}
}
// begin:google_only
//
// static void DecodeEncodeArbitrarySchemaAndPayload(
// const upb::fuzz::MiniTableFuzzInput& input, std::string_view proto_payload,
// int decode_options, int encode_options, bool length_prefixed = false) {
// // Lexan does not have setenv
// #ifndef _MSC_VER
// setenv("FUZZTEST_STACK_LIMIT", "262144", 1);
// #endif
// // The value of 80 used here is empirical and intended to roughly represent
// // the tiny 64K stack size used by the test framework. We still see the
// // occasional stack overflow at 90, so far 80 has worked 100% of the time.
// decode_options = upb_Decode_LimitDepth(decode_options, 80);
// encode_options = upb_Encode_LimitDepth(encode_options, 80);
//
// upb::Arena arena;
// upb_ExtensionRegistry* exts;
// const upb_MiniTable* mini_table =
// upb::fuzz::BuildMiniTable(input, &exts, arena.ptr());
// if (!mini_table) return;
// upb_Message* msg = upb_Message_New(mini_table, arena.ptr());
// if (length_prefixed) {
// size_t num_bytes_read = 0;
// upb_DecodeStatus status = upb_DecodeLengthPrefixed(
// proto_payload.data(), proto_payload.size(), msg, &num_bytes_read,
// mini_table, exts, decode_options, arena.ptr());
// ASSERT_TRUE(status != kUpb_DecodeStatus_Ok ||
// num_bytes_read <= proto_payload.size());
// } else {
// upb_Decode(proto_payload.data(), proto_payload.size(), msg, mini_table,
// exts, decode_options, arena.ptr());
// }
// char* ptr;
// size_t size;
// if (length_prefixed) {
// upb_EncodeLengthPrefixed(msg, mini_table, encode_options, arena.ptr(), &ptr,
// &size);
// } else {
// upb_Encode(msg, mini_table, encode_options, arena.ptr(), &ptr, &size);
// }
// }
// FUZZ_TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayload);
//
// TEST(FuzzTest, DecodeUnknownProto2EnumExtension) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\256\354Rt\216\3271\234", "\243\243\267\207\336gV\366w"},
// {"z"},
// "}\212\304d\371\363\341\2329\325B\264\377?\215\223\201\201\226y\201%"
// "\321\363\255;",
// {}},
// "\010", -724543908, -591643538);
// }
//
// TEST(FuzzTest, DecodeExtensionEnsurePresenceInitialized) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\031", "S", "\364", "", "", "j", "\303", "", "\224", "\277"},
// {},
// "_C-\236$*)C0C>",
// {4041515984, 2147483647, 1929379871, 0, 3715937258, 4294967295}},
// "\010\002", 342248070, -806315555);
// }
//
// TEST(FuzzTest, DecodeExtendMessageSetWithNonMessage) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\n"}, {""}, ".\244", {}}, "\013\032\005\212a#\365\336\020\001\226",
// 14803219, 670718349);
// }
//
// TEST(FuzzTest, DecodeExtendMessageSetWithNonMessage2) {
// DecodeEncodeArbitrarySchemaAndPayload({{"\n", "G", "\n", "\274", ""},
// {"", "\030"},
// "_@",
// {4294967295, 2147483647}},
// std::string("\013\032\000\220", 4),
// 279975758, 1647495141);
// }
//
// TEST(FuzzTest, DecodeExtendMessageSetWithNonMessage3) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\n"}, {"B", ""}, "\212:b", {11141121}},
// "\013\032\004\357;7\363\020\001\346\240\200\201\271", 399842149,
// -452966025);
// }
//
// TEST(FuzzTest, DecodeExtendMessageSetWithNonMessage4) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\n", "3\340", "\354"}, {}, "B}G", {4294967295, 4082331310}},
// "\013\032\004\244B\331\255\020\001\220\224\243\350\t", -561523015,
// 1683327312);
// }
//
// TEST(FuzzTest, DecodeExtendMessageSetWithNonMessage5) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\n"}, {""}, "kB", {0}},
// "x\203\251\006\013\032\002S\376\010\273\'\020\014\365\207\244\234",
// -696925610, -654590577);
// }
//
// TEST(FuzzTest, ExtendMessageSetWithEmptyExtension) {
// DecodeEncodeArbitrarySchemaAndPayload({{"\n"}, {}, "_", {}}, std::string(), 0,
// 0);
// }
//
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegression) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"\320", "\320", "\320", "\320", "\320", "%2%%%%%"},
// {"", "", "", "", "", "", "", "", "", "", "", "",
// "", "", "", "", "", "", "", "", "", "", ""},
// "\226\226\226\226\226\226\350\351\350\350\350\350\350\350\350\314",
// {4026531839}},
// std::string("\n\n\n\n\272\n======@@%%%%%%%%%%%%%%%@@@(("
// "qqqqqqqq5555555555qqqqqffq((((((((((((\335@@>"
// "\ru\360ncppppxxxxxxxxx\025\025\025xxxxxppppppp<="
// "\2165\275\275\315\217\361\010\t\000\016\013in\n\n\n\256\263",
// 130),
// 901979906, 65537);
// }
//
// // This test encodes a map field with extra cruft.
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegressionInvalidMap) {
// DecodeEncodeArbitrarySchemaAndPayload({{"%%%%///////"}, {}, "", {}},
// std::string("\035|", 2), 65536, 3);
// }
//
// // This test found a case where presence was unset for a mini table field.
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegressionMsan) {
// DecodeEncodeArbitrarySchemaAndPayload({{"%-#^#"}, {}, "", {}}, std::string(),
// -1960166338, 16809991);
// }
//
// // This test encodes a map containing a msg wrapping another, empty msg.
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegressionMapMap) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"%#G"}, {}, "", {}}, std::string("\022\002\022\000", 4), 0, 0);
// }
//
// TEST(FuzzTest, GroupMap) {
// // Groups should not be allowed as maps, but we previously failed to prevent
// // this.
// DecodeEncodeArbitrarySchemaAndPayload(
// {.mini_descriptors = {"$$FF$", "%-C"},
// .enum_mini_descriptors = {},
// .extensions = "",
// .links = {1}},
// std::string(
// "\023\020\030\233\000\204\330\372#\000`"
// "a\000\000\001\000\000\000ccccccc\030s\273sssssssss\030\030\030\030"
// "\030\030\030\030\215\215\215\215\215\215\215\215\030\030\232\253\253"
// "\232*\334\227\273\231\207\373\t\0051\305\265\335\224\226"),
// 0, 0);
// }
//
// TEST(FuzzTest, MapUnknownFieldSpanBuffers) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"$ 3", "%# "}, {}, "", {1}},
// std::string(
// "\"\002\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000",
// 17),
// 0, 0);
// }
//
// // Another test for mismatched submsg types.
// TEST(FuzzTest, DecodeEncodeArbitrarySchemaAndPayloadRegression22) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"$2222222222222222222222", "%,&"}, {}, "", {1}},
// std::string("\035\170\170\170\051\263\001\030\000\035\357\357\340\021\035"
// "\025\331\035\035\035\035\035\035\035\035",
// 25),
// 0, 0);
// }
//
// TEST(FuzzTest, ExtensionWithoutExt) {
// DecodeEncodeArbitrarySchemaAndPayload({{"$ 3", "", "%#F"}, {}, "", {2, 1}},
// std::string("\022\002\010\000", 4), 0,
// 0);
// }
//
// TEST(FuzzTest, MapFieldVerify) {
// DecodeEncodeArbitrarySchemaAndPayload({{"% ^!"}, {}, "", {}}, "", 0, 0);
// }
//
// TEST(FuzzTest, TooManyRequiredFields) {
// DecodeEncodeArbitrarySchemaAndPayload(
// {{"$ N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N "
// "N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N"},
// {},
// "",
// {}},
// "", 0, 4);
// }
//
// end:google_only

@ -168,58 +168,4 @@ TEST(Utf8Test, Proto2RepeatedFieldFailsValidation) {
ASSERT_EQ(kUpb_DecodeStatus_BadUtf8, status);
}
// begin:google_only
// TEST(Utf8Test, Proto3MixedFieldValidates) {
// upb::Arena arena;
// size_t size;
// char* data = GetBadUtf8Payload(arena.ptr(), &size);
//
// upb_test_TestUtf8Proto3StringMixed* msg =
// upb_test_TestUtf8Proto3StringMixed_new(arena.ptr());
//
// upb_DecodeStatus status = upb_Decode(
// data, size, UPB_UPCAST(msg),
// &upb_0test__TestUtf8Proto3StringMixed_msg_init, nullptr, 0, arena.ptr());
//
// // Parse fails, because proto3 string fields validate UTF-8.
// ASSERT_EQ(kUpb_DecodeStatus_BadUtf8, status);
// }
//
// TEST(Utf8Test, EnforceUtf8Options) {
// upb::Arena arena;
// size_t size;
// char* data = GetBadUtf8Payload(arena.ptr(), &size);
// upb_test_TestUtf8Proto3StringEnforceUtf8False* msg2 =
// upb_test_TestUtf8Proto3StringEnforceUtf8False_parse(data, size,
// arena.ptr());
//
// // Parse succeeds, because enforce_utf8=false inhibits utf-8 validation.
// ASSERT_TRUE(msg2 != nullptr);
// }
//
// TEST(Utf8Test, RepeatedEnforceUtf8Options) {
// upb::Arena arena;
// size_t size;
// char* data = GetBadUtf8Payload(arena.ptr(), &size);
// upb_test_TestUtf8RepeatedProto3StringEnforceUtf8False* msg2 =
// upb_test_TestUtf8RepeatedProto3StringEnforceUtf8False_parse(data, size,
// arena.ptr());
//
// // Parse succeeds, because enforce_utf8=false inhibits utf-8 validation.
// ASSERT_TRUE(msg2 != nullptr);
// }
//
// TEST(Utf8Test, EnforceUtf8OptionsMixed) {
// upb::Arena arena;
// size_t size;
// char* data = GetBadUtf8Payload(arena.ptr(), &size);
// upb_test_TestUtf8Proto3StringEnforceUtf8FalseMixed* msg2 =
// upb_test_TestUtf8Proto3StringEnforceUtf8FalseMixed_parse(data, size,
// arena.ptr());
//
// // Parse succeeds, because enforce_utf8=false inhibits utf-8 validation.
// ASSERT_TRUE(msg2 != nullptr);
// }
// end:google_only
} // namespace

@ -21,7 +21,7 @@ message TestUtf8RepeatedProto3String {
repeated string data = 1;
}
// begin:google_only
// copybara:strip_begin(enforce_utf8 option is not respected in OSS)
message TestUtf8Proto3StringMixed {
optional string data = 1;
@ -45,4 +45,4 @@ message TestUtf8Proto3StringEnforceUtf8FalseMixed {
// handle the mix.
optional string other_data = 2;
}
// end:google_only
// copybara:strip_end

@ -74,7 +74,6 @@ cc_test(
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -88,9 +87,7 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only
# begin:github_only
filegroup(
name = "test_srcs",
srcs = glob(
@ -100,4 +97,3 @@ filegroup(
),
visibility = ["//pkg:__pkg__"],
)
# end:github_only

@ -28,10 +28,6 @@
#include "upb/mini_table/message.h"
#include "upb/mini_table/sub.h"
// begin:google_only
// #include "testing/fuzzing/fuzztest.h"
// end:google_only
// Must be last.
#include "upb/port/def.inc"
@ -289,21 +285,3 @@ TEST_P(MiniTableTest, Extendible) {
EXPECT_EQ(kUpb_ExtMode_Extendable,
table->UPB_PRIVATE(ext) & kUpb_ExtMode_Extendable);
}
// begin:google_only
//
// static void BuildMiniTable(std::string_view s, bool is_32bit) {
// upb::Arena arena;
// upb::Status status;
// _upb_MiniTable_Build(
// s.data(), s.size(),
// is_32bit ? kUpb_MiniTablePlatform_32Bit : kUpb_MiniTablePlatform_64Bit,
// arena.ptr(), status.ptr());
// }
// FUZZ_TEST(FuzzTest, BuildMiniTable);
//
// TEST(FuzzTest, BuildMiniTableRegression) {
// BuildMiniTable("g}{v~fq{\271", false);
// }
//
// end:google_only

@ -93,7 +93,6 @@ cc_test(
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -107,9 +106,7 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only
# begin:github_only
filegroup(
name = "test_srcs",
srcs = glob(
@ -119,4 +116,3 @@ filegroup(
),
visibility = ["//upb:__pkg__"],
)
# end:github_only

@ -35,7 +35,6 @@ filegroup(
visibility = ["//visibility:public"],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -49,4 +48,3 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only

@ -334,10 +334,6 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
#define UPB_DEPRECATED
#endif
// begin:google_only
// #define UPB_IS_GOOGLE3
// end:google_only
#if defined(UPB_IS_GOOGLE3) && \
(!defined(UPB_BOOTSTRAP_STAGE) || UPB_BOOTSTRAP_STAGE != 0)
#define UPB_DESC(sym) proto2_##sym
@ -350,6 +346,7 @@ void __asan_unpoison_memory_region(void const volatile *addr, size_t size);
#define UPB_DESC_MINITABLE(sym) &google__protobuf__##sym##_msg_init
#endif
#undef UPB_IS_GOOGLE3
// Linker arrays combine elements from multiple translation units into a single
// array that can be iterated over at runtime.

@ -7,16 +7,12 @@
load("//bazel:upb_minitable_proto_library.bzl", "upb_minitable_proto_library")
load("//bazel:upb_proto_library.bzl", "upb_proto_reflection_library")
# end:github_only
load(
"//editions:defaults.bzl",
"compile_edition_defaults",
"embed_edition_defaults",
)
load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_COPTS")
# begin:github_only
load(
"//upb/cmake:build_defs.bzl",
"staleness_test",
@ -189,29 +185,6 @@ cc_test(
],
)
# begin:google_only
# compile_edition_defaults(
# name = "upb_edition_defaults",
# srcs = [
# "//:descriptor_proto",
# ],
# compatible_with = ["//buildenv/target:non_prod"],
# maximum_edition = "2023",
# minimum_edition = "PROTO2",
# )
#
# embed_edition_defaults(
# name = "embedded_upb_edition_defaults_generate",
# compatible_with = ["//buildenv/target:non_prod"],
# defaults = "upb_edition_defaults",
# output = "internal/upb_edition_defaults.h",
# placeholder = "DEFAULTS_VALUE",
# template = "internal/upb_edition_defaults.h.template",
# )
# end:google_only
# TODO Merge these once we deal with the whitespace issues with reversible stripping.
# begin:github_only
compile_edition_defaults(
name = "upb_edition_defaults",
srcs = [
@ -236,9 +209,7 @@ staleness_test(
tags = ["manual"],
target_files = ["internal/upb_edition_defaults.h"],
)
# end:github_only
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -257,4 +228,3 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only

@ -590,20 +590,6 @@ static bool _upb_FieldDef_InferLegacyFeatures(
ret = true;
}
// begin:google_only
// #if UPB_BOOTSTRAP_STAGE != 0
// if (syntax == kUpb_Syntax_Proto3 &&
// UPB_DESC(FieldOptions_has_enforce_utf8)(options) &&
// !UPB_DESC(FieldOptions_enforce_utf8)(options)) {
// int val = UPB_DESC(FeatureSet_UNVERIFIED);
// UPB_DESC(FeatureSet_set_utf8_validation(features, val));
// ret = true;
// }
// #endif
// // clang-format off
// end:google_only
// clang-format on
return ret;
}

@ -324,7 +324,6 @@ cc_test(
],
)
# begin:github_only
filegroup(
name = "test_srcs",
srcs = glob(
@ -355,4 +354,3 @@ filegroup(
),
visibility = ["//upb:__pkg__"],
)
# end:github_only

@ -103,7 +103,6 @@ cc_test(
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -117,4 +116,3 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only

@ -54,13 +54,6 @@ static void _upb_TextEncode_Field(txtenc* e, upb_MessageValue val,
const char* name = upb_FieldDef_Name(f);
if (ctype == kUpb_CType_Message) {
// begin:google_only
// // TODO: Turn this into a feature check and opensource it.
// if (_upb_FieldDef_IsGroupLike(f)) {
// const upb_MessageDef* m = upb_FieldDef_MessageSubDef(f);
// name = upb_MessageDef_Name(m);
// }
// end:google_only
if (is_ext) {
UPB_PRIVATE(_upb_TextEncode_Printf)(e, "[%s] {", full);
} else {

@ -83,19 +83,6 @@ cc_test(
],
)
# begin:google_only
# cc_test(
# name = "def_to_proto_fuzz_test",
# srcs = ["def_to_proto_fuzz_test.cc"],
# tags = ["clang_only"],
# deps = [
# ":def_to_proto_test_lib",
# "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main",
# "//testing/fuzzing:fuzztest",
# ],
# )
# end:google_only
# Required fields
cc_library(
@ -163,7 +150,6 @@ cc_test(
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = [
@ -174,9 +160,7 @@ filegroup(
],
visibility = ["//python/dist:__pkg__"],
)
# end:github_only
# begin:github_only
filegroup(
name = "test_srcs",
srcs = glob(
@ -207,4 +191,3 @@ filegroup(
),
visibility = ["//upb:__pkg__"],
)
# end:github_only

@ -276,28 +276,6 @@ TEST(FuzzTest, DefaultWithValidHexEscapePrintable) {
})pb"));
}
// begin:google_only
// TEST(FuzzTest, DependencyWithEmbeddedNull) {
// RoundTripDescriptor(ParseTextProtoOrDie(R"pb(file {
// name: "a"
// dependency: "a\000"
// options { cc_api_version: 0 }
// weak_dependency: 0
// })pb"));
// }
//
// TEST(FuzzTest, NanInOptions) {
// RoundTripDescriptor(
// ParseTextProtoOrDie(R"pb(file {
// name: ""
// service {
// name: "A"
// options { failure_detection_delay: nan }
// }
// })pb"));
// }
// end:google_only
TEST(FuzzTest, PackageStartsWithNumber) {
RoundTripDescriptor(
ParseTextProtoOrDie(R"pb(file { name: "" package: "0" })pb"));

@ -81,7 +81,6 @@ cc_test(
],
)
# begin:github_only
filegroup(
name = "source_files",
srcs = glob(
@ -95,9 +94,7 @@ filegroup(
"//upb/cmake:__pkg__",
],
)
# end:github_only
# begin:github_only
filegroup(
name = "test_srcs",
srcs = glob(
@ -107,4 +104,3 @@ filegroup(
),
visibility = ["//upb:__pkg__"],
)
# end:github_only

@ -13,9 +13,6 @@
#include <gtest/gtest.h>
#include "upb/mem/arena.hpp"
// begin:google_only
// #include "testing/fuzzing/fuzztest.h"
// end:google_only
namespace {
@ -27,316 +24,4 @@ TEST(EpsCopyInputStreamTest, ZeroSize) {
upb_EpsCopyInputStream_IsDoneWithCallback(&stream, &ptr, nullptr));
}
// begin:google_only
//
// // We create a simple, trivial implementation of the stream that we can test
// // our real implementation against.
//
// class FakeStream {
// public:
// explicit FakeStream(const std::string& data) : data_(data), offset_(0) {
// limits_.push_back(data.size());
// }
//
// // If we reached one or more limits correctly, returns the number of limits
// // ended. If we tried to read beyond the current limit, returns -1.
// // Otherwise, for simple success, returns 0.
// int ReadData(int n, std::string* data) {
// if (n > BytesUntilLimit()) return -1;
//
// data->assign(data_.data() + offset_, n);
// offset_ += n;
//
// int end_limit_count = 0;
//
// while (BytesUntilLimit() == 0) {
// if (PopLimit()) {
// end_limit_count++;
// } else {
// eof_ = true;
// break;
// }
// }
//
// return end_limit_count;
// }
//
// bool TryPushLimit(int limit) {
// if (!CheckSize(limit)) return false;
// limits_.push_back(offset_ + limit);
// return true;
// }
//
// bool IsEof() const { return eof_; }
//
// private:
// int BytesUntilLimit() const { return limits_.back() - offset_; }
// bool CheckSize(int size) const { return BytesUntilLimit() >= size; }
//
// // Return false on EOF.
// bool PopLimit() {
// limits_.pop_back();
// return !limits_.empty();
// }
//
// std::string data_;
// // Limits, specified in absolute stream terms.
// std::vector<int> limits_;
// int offset_;
// bool eof_ = false;
// };
//
// char tmp_buf[kUpb_EpsCopyInputStream_SlopBytes];
//
// class EpsStream {
// public:
// EpsStream(const std::string& data, bool enable_aliasing)
// : data_(data), enable_aliasing_(enable_aliasing) {
// ptr_ = data_.data();
// upb_EpsCopyInputStream_Init(&eps_, &ptr_, data_.size(), enable_aliasing);
// }
//
// // Returns false at EOF or error.
// int ReadData(int n, std::string* data) {
// EXPECT_LE(n, kUpb_EpsCopyInputStream_SlopBytes);
// if (enable_aliasing_) {
// EXPECT_TRUE(upb_EpsCopyInputStream_AliasingAvailable(&eps_, ptr_, n));
// }
// // We want to verify that we can read kUpb_EpsCopyInputStream_SlopBytes
// // safely, even if we haven't actually been requested to read that much.
// // We copy to a global buffer so the copy can't be optimized away.
// memcpy(&tmp_buf, ptr_, kUpb_EpsCopyInputStream_SlopBytes);
// data->assign(tmp_buf, n);
// ptr_ += n;
// if (enable_aliasing_) {
// EXPECT_TRUE(upb_EpsCopyInputStream_AliasingAvailable(&eps_, ptr_, 0));
// }
// return PopLimits();
// }
//
// int ReadString(int n, std::string* data) {
// if (!upb_EpsCopyInputStream_CheckSize(&eps_, ptr_, n)) return -1;
// const char* str_data = ptr_;
// if (enable_aliasing_) {
// EXPECT_TRUE(upb_EpsCopyInputStream_AliasingAvailable(&eps_, ptr_, n));
// }
// ptr_ = upb_EpsCopyInputStream_ReadString(&eps_, &str_data, n, arena_.ptr());
// if (!ptr_) return -1;
// if (enable_aliasing_ && n) {
// EXPECT_GE(reinterpret_cast<uintptr_t>(str_data),
// reinterpret_cast<uintptr_t>(data_.data()));
// EXPECT_LT(reinterpret_cast<uintptr_t>(str_data),
// reinterpret_cast<uintptr_t>(data_.data() + data_.size()));
// EXPECT_TRUE(upb_EpsCopyInputStream_AliasingAvailable(&eps_, ptr_, 0));
// }
// data->assign(str_data, n);
// return PopLimits();
// }
//
// bool TryPushLimit(int limit) {
// if (!upb_EpsCopyInputStream_CheckSize(&eps_, ptr_, limit)) return false;
// deltas_.push_back(upb_EpsCopyInputStream_PushLimit(&eps_, ptr_, limit));
// return true;
// }
//
// bool IsEof() const { return eof_; }
//
// private:
// int PopLimits() {
// int end_limit_count = 0;
//
// while (IsAtLimit()) {
// if (error_) return -1;
// if (PopLimit()) {
// end_limit_count++;
// } else {
// eof_ = true; // EOF.
// break;
// }
// }
//
// return error_ ? -1 : end_limit_count;
// }
//
// bool IsAtLimit() {
// return upb_EpsCopyInputStream_IsDoneWithCallback(
// &eps_, &ptr_, &EpsStream::IsDoneFallback);
// }
//
// // Return false on EOF.
// bool PopLimit() {
// if (deltas_.empty()) return false;
// upb_EpsCopyInputStream_PopLimit(&eps_, ptr_, deltas_.back());
// deltas_.pop_back();
// return true;
// }
//
// static const char* IsDoneFallback(upb_EpsCopyInputStream* e, const char* ptr,
// int overrun) {
// return _upb_EpsCopyInputStream_IsDoneFallbackInline(
// e, ptr, overrun, &EpsStream::BufferFlipCallback);
// }
//
// static const char* BufferFlipCallback(upb_EpsCopyInputStream* e,
// const char* old_end,
// const char* new_start) {
// EpsStream* stream = reinterpret_cast<EpsStream*>(e);
// if (!old_end) stream->error_ = true;
// return new_start;
// }
//
// upb_EpsCopyInputStream eps_;
// std::string data_;
// const char* ptr_;
// std::vector<int> deltas_;
// upb::Arena arena_;
// bool error_ = false;
// bool eof_ = false;
// bool enable_aliasing_;
// };
//
// // Reads N bytes from the given position.
// struct ReadOp {
// int bytes; // Must be <= kUpb_EpsCopyInputStream_SlopBytes.
// };
//
// struct ReadStringOp {
// int bytes;
// };
//
// // Pushes a new limit of N bytes from the current position.
// struct PushLimitOp {
// int bytes;
// };
//
// typedef std::variant<ReadOp, ReadStringOp, PushLimitOp> Op;
//
// struct EpsCopyTestScript {
// int data_size;
// bool enable_aliasing;
// std::vector<Op> ops;
// };
//
// auto ArbitraryEpsCopyTestScript() {
// using ::fuzztest::Arbitrary;
// using ::fuzztest::InRange;
// using ::fuzztest::NonNegative;
// using ::fuzztest::StructOf;
// using ::fuzztest::VariantOf;
// using ::fuzztest::VectorOf;
//
// int max_data_size = 512;
//
// return StructOf<EpsCopyTestScript>(
// InRange(0, max_data_size), // data_size
// Arbitrary<bool>(), // enable_aliasing
// VectorOf(VariantOf(
// // ReadOp
// StructOf<ReadOp>(InRange(0, kUpb_EpsCopyInputStream_SlopBytes)),
// // ReadStringOp
// StructOf<ReadStringOp>(NonNegative<int>()),
// // PushLimitOp
// StructOf<PushLimitOp>(NonNegative<int>()))));
// }
//
// // Run a test that creates both real stream and a fake stream, and validates
// // that they have the same behavior.
// void TestAgainstFakeStream(const EpsCopyTestScript& script) {
// std::string data(script.data_size, 'x');
// for (int i = 0; i < script.data_size; ++i) {
// data[i] = static_cast<char>(i & 0xff);
// }
//
// FakeStream fake_stream(data);
// EpsStream eps_stream(data, script.enable_aliasing);
//
// for (const auto& op : script.ops) {
// if (const ReadOp* read_op = std::get_if<ReadOp>(&op)) {
// std::string data_fake;
// std::string data_eps;
// int fake_result = fake_stream.ReadData(read_op->bytes, &data_fake);
// int eps_result = eps_stream.ReadData(read_op->bytes, &data_eps);
// EXPECT_EQ(fake_result, eps_result);
// if (fake_result == -1) break; // Error
// EXPECT_EQ(data_fake, data_eps);
// EXPECT_EQ(fake_stream.IsEof(), eps_stream.IsEof());
// if (fake_stream.IsEof()) break;
// } else if (const ReadStringOp* read_op = std::get_if<ReadStringOp>(&op)) {
// std::string data_fake;
// std::string data_eps;
// int fake_result = fake_stream.ReadData(read_op->bytes, &data_fake);
// int eps_result = eps_stream.ReadString(read_op->bytes, &data_eps);
// EXPECT_EQ(fake_result, eps_result);
// if (fake_result == -1) break; // Error
// EXPECT_EQ(data_fake, data_eps);
// EXPECT_EQ(fake_stream.IsEof(), eps_stream.IsEof());
// if (fake_stream.IsEof()) break;
// } else if (const PushLimitOp* push = std::get_if<PushLimitOp>(&op)) {
// EXPECT_EQ(fake_stream.TryPushLimit(push->bytes),
// eps_stream.TryPushLimit(push->bytes));
// } else {
// EXPECT_TRUE(false); // Unknown op.
// }
// }
// }
//
// // Test with:
// // $ bazel run --config=fuzztest third_party/upb:eps_copy_input_stream_test
// // -- --gunit_fuzz=
// FUZZ_TEST(EpsCopyFuzzTest, TestAgainstFakeStream)
// .WithDomains(ArbitraryEpsCopyTestScript());
//
// TEST(EpsCopyFuzzTest, TestAgainstFakeStreamRegression) {
// TestAgainstFakeStream({299,
// false,
// {
// PushLimitOp{2},
// ReadOp{14},
// }});
// }
//
// TEST(EpsCopyFuzzTest, AliasingEnabledZeroSizeReadString) {
// TestAgainstFakeStream({510, true, {ReadStringOp{0}}});
// }
//
// TEST(EpsCopyFuzzTest, AliasingDisabledZeroSizeReadString) {
// TestAgainstFakeStream({510, false, {ReadStringOp{0}}});
// }
//
// TEST(EpsCopyFuzzTest, ReadStringZero) {
// TestAgainstFakeStream({0, true, {ReadStringOp{0}}});
// }
//
// TEST(EpsCopyFuzzTest, ReadZero) {
// TestAgainstFakeStream({0, true, {ReadOp{0}}});
// }
//
// TEST(EpsCopyFuzzTest, ReadZeroTwice) {
// TestAgainstFakeStream({0, true, {ReadOp{0}, ReadOp{0}}});
// }
//
// TEST(EpsCopyFuzzTest, ReadStringZeroThenRead) {
// TestAgainstFakeStream({0, true, {ReadStringOp{0}, ReadOp{0}}});
// }
//
// TEST(EpsCopyFuzzTest, ReadStringOverflowsBufferButNotLimit) {
// TestAgainstFakeStream({351,
// false,
// {
// ReadOp{7},
// PushLimitOp{2147483647},
// ReadStringOp{344},
// }});
// }
//
// TEST(EpsCopyFuzzTest, LastBufferAliasing) {
// TestAgainstFakeStream({27, true, {ReadOp{12}, ReadStringOp{3}}});
// }
//
// TEST(EpsCopyFuzzTest, FirstBufferAliasing) {
// TestAgainstFakeStream({7, true, {ReadStringOp{3}}});
// }
//
// end:google_only
} // namespace

@ -1,12 +1,9 @@
"""Macros that implement bootstrapping for the upb code generator."""
# begin:github_only
load(
"//bazel:upb_minitable_proto_library.bzl",
"upb_minitable_proto_library",
)
# end:github_only
load(
"//bazel:upb_proto_library.bzl",
"upb_proto_library",
@ -19,24 +16,15 @@ load(
_stages = ["_stage0", "_stage1", ""]
_protoc = "//:protoc"
# begin:google_only
# _is_google3 = True
# _extra_proto_path = ""
# end:google_only
# begin:github_only
_is_google3 = False
_extra_proto_path = "-I$$(dirname $(location @com_google_protobuf//:descriptor_proto_srcs))/../.. "
# end:github_only
# This visibility is used automatically for anything used by the bootstrapping process.
_bootstrap_visibility = [
"//upb_generator:__subpackages__",
"//upb/reflection:__pkg__",
# begin:github_only
"//upb:__pkg__", # For the amalgamations.
"//python/dist:__pkg__", # For the Python source package.
# end:github_only
]
def _stage_visibility(stage, visibility):
@ -153,7 +141,6 @@ def _generate_stage1_proto(name, src_files, src_rules, generator, kwargs):
**kwargs
)
# begin:github_only
def _cmake_staleness_test(name, src_files, proto_lib_deps, **kwargs):
upb_minitable_proto_library(
name = name + "_minitable",
@ -189,8 +176,6 @@ def _cmake_staleness_test(name, src_files, proto_lib_deps, **kwargs):
tags = ["manual"],
)
# end:github_only
def bootstrap_upb_proto_library(
name,
bootstrap_hdr,
@ -285,7 +270,4 @@ def bootstrap_upb_proto_library(
**kwargs
)
# begin:github_only
_cmake_staleness_test(name, src_files, proto_lib_deps, **kwargs)
# end:github_only

@ -1164,9 +1164,7 @@ void GenerateFile(const DefPoolPair& pools, upb::FileDefPtr file,
// TODO: remove once we can figure out how to make both Blaze
// and Bazel happy with header-only libraries.
// begin:github_only
plugin->AddOutputFile(SourceFilename(file), "\n");
// end:github_only
}
}

Loading…
Cancel
Save