Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17

build:dbg --compilation_mode=dbg

Expand Down Expand Up @@ -26,3 +26,5 @@ build:ubsan --copt=-DUNDEFINED_SANITIZER=1
# Workaround for the fact that Bazel links with $CC, not $CXX
# https://github.com/bazelbuild/bazel/issues/11122#issuecomment-613746748
build:ubsan --copt=-fno-sanitize=function --copt=-fno-sanitize=vptr

common --enable_bzlmod
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.1.0
7.6.1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bazel-*
MODULE.bazel.lock
13 changes: 13 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module(
name = "proto-converter",
repo_name = "proto_converter",
)

bazel_dep(name = "abseil-cpp", version = "20240116.2", repo_name = "com_google_absl")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "protobuf", version = "29.3", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_cc", version = "0.0.16")
bazel_dep(name = "rules_pkg", version = "1.0.1")

bazel_dep(name = "googletest", version = "1.15.0", dev_dependency = True, repo_name = "com_google_googletest")
40 changes: 19 additions & 21 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,34 @@ workspace(name = "proto_converter")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "com_google_googletest",
sha256 = "730215d76eace9dd49bf74ce044e8daa065d175f1ac891cc1d6bb184ef94e565",
strip_prefix = "googletest-f53219cdcb7b084ef57414efea92ee5b71989558",
urls = [
"https://github.com/google/googletest/archive/f53219cdcb7b084ef57414efea92ee5b71989558.tar.gz", # 2023-03-16
],
name = "com_google_protobuf",
sha256 = "55912546338433f465a552e9ef09930c63b9eb697053937416890cff83a8622d",
strip_prefix = "protobuf-b407e8416e3893036aee5af9a12bd9b6a0e2b2e6",
urls = ["https://github.com/protocolbuffers/protobuf/archive/b407e8416e3893036aee5af9a12bd9b6a0e2b2e6.tar.gz"], # v29.3
)

load("@com_google_googletest//:googletest_deps.bzl", "googletest_deps")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

googletest_deps()
protobuf_deps()

http_archive(
name = "com_google_protobuf",
sha256 = "aa61db6ff113a1c76eac9408144c6e996c5e2d6b2410818fd7f1b0d222a50bf8",
strip_prefix = "protobuf-315ffb5be89460f2857387d20aefc59b76b8bdc3", # 5.31.2023
urls = ["https://github.com/protocolbuffers/protobuf/archive/315ffb5be89460f2857387d20aefc59b76b8bdc3.tar.gz"],
)
load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

load("@rules_python//python/pip_install:repositories.bzl", "pip_install_dependencies")

pip_install_dependencies()

http_archive(
name = "upb",
patches = ["@com_google_protobuf//build_defs:upb.patch"],
sha256 = "8c4f3a4fca45da3c7d808a48cb730ae12af6d97462a9ad60e529d29da24cca03",
strip_prefix = "upb-7a04b4027d737828c9c5b8be56c838d5db0db80f",
name = "com_google_googletest",
sha256 = "7315acb6bf10e99f332c8a43f00d5fbb1ee6ca48c52f6b936991b216c586aaad",
strip_prefix = "googletest-1.15.0",
urls = [
"https://github.com/protocolbuffers/upb/archive/7a04b4027d737828c9c5b8be56c838d5db0db80f.tar.gz",
"https://github.com/google/googletest/releases/download/v1.15.0/googletest-1.15.0.tar.gz", # 2024-07-15
],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@com_google_googletest//:googletest_deps.bzl", "googletest_deps")

protobuf_deps()
googletest_deps()

1 change: 1 addition & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspace(name = "proto_converter")
1 change: 0 additions & 1 deletion build_defs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Internal Starlark definitions for Protobuf.

load("@bazel_skylib//lib:selects.bzl", "selects")
load("@rules_cc//cc:defs.bzl", starlark_cc_proto_library = "cc_proto_library")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load(":compiler_config_setting.bzl", "create_compiler_config_setting")

Expand Down
2 changes: 1 addition & 1 deletion src/google/protobuf/stubs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")

package(
default_visibility = ["//:__subpackages__"],
default_visibility = ["//:__subpackages__"],
)

cc_library(
Expand Down
2 changes: 1 addition & 1 deletion src/google/protobuf/stubs/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace internal {

// The current version, represented as a single integer to make comparison
// easier: major * 10^6 + minor * 10^3 + micro
#define GOOGLE_PROTOBUF_VERSION 4022003
#define GOOGLE_PROTOBUF_VERSION 5029003

// A suffix string for alpha, beta or rc releases. Empty for stable releases.
#define GOOGLE_PROTOBUF_VERSION_SUFFIX ""
Expand Down
20 changes: 17 additions & 3 deletions src/google/protobuf/util/converter/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library", "cc_test")
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//build_defs:cpp_opts.bzl", "COPTS")

package(
Expand Down Expand Up @@ -79,6 +79,7 @@ cc_library(
":utility",
"//src/google/protobuf/stubs",
"//src/google/protobuf/util/converter:port_def",
"@com_google_absl//absl/container:flat_hash_set",
],
)

Expand Down Expand Up @@ -137,6 +138,7 @@ cc_library(
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_protobuf//:protobuf",
"@com_google_protobuf//third_party/utf8_range:utf8_validity",
],
)

Expand Down Expand Up @@ -194,6 +196,8 @@ cc_library(
deps = [
":utility",
"//src/google/protobuf/stubs",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_protobuf//:protobuf",
],
)
Expand Down Expand Up @@ -238,6 +242,9 @@ cc_library(
":type_info",
":utility",
"//src/google/protobuf/stubs",
"@com_google_absl//absl/container:btree",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",
"@com_google_protobuf//:protobuf",
],
Expand Down Expand Up @@ -295,6 +302,7 @@ cc_library(
deps = [
":constants",
"//src/google/protobuf/stubs",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",
"@com_google_protobuf//:protobuf",
],
Expand Down Expand Up @@ -360,6 +368,7 @@ proto_library(
testonly = 1,
srcs = ["testdata/default_value_test.proto"],
strip_import_prefix = "/src",
deps = ["@com_google_protobuf//:struct_proto"],
)

cc_proto_library(
Expand Down Expand Up @@ -419,6 +428,11 @@ proto_library(
testonly = 1,
srcs = ["testdata/proto3.proto"],
strip_import_prefix = "/src",
deps = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:wrappers_proto",
],
)

cc_proto_library(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void DefaultValueObjectWriter::Node::PopulateChildren(
absl::flat_hash_map<absl::string_view, int> orig_children_map;

// Creates a map of child nodes to speed up lookup.
for (int i = 0; i < children_.size(); ++i) {
for (size_t i = 0; i < children_.size(); ++i) {
orig_children_map.try_emplace(children_[i]->name_, i);
}

Expand Down Expand Up @@ -375,7 +375,7 @@ void DefaultValueObjectWriter::Node::PopulateChildren(
new_children.push_back(child.release());
}
// Adds all leftover nodes in children_ to the beginning of new_child.
for (int i = 0; i < children_.size(); ++i) {
for (size_t i = 0; i < children_.size(); ++i) {
if (children_[i] == nullptr) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
Node(const Node&) = delete;
Node& operator=(const Node&) = delete;
virtual ~Node() {
for (int i = 0; i < children_.size(); ++i) {
for (size_t i = 0; i < children_.size(); ++i) {
delete children_[i];
}
}
Expand Down
27 changes: 5 additions & 22 deletions src/google/protobuf/util/converter/port_def.inc
Original file line number Diff line number Diff line change
Expand Up @@ -221,25 +221,9 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),

#endif

#ifdef PROTOBUF_VERSION
#error PROTOBUF_VERSION was previously defined
#endif
#define PROTOBUF_VERSION 4023000

#ifdef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
#error PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC was previously defined
#endif
#define PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC 4023000

#ifdef PROTOBUF_MIN_PROTOC_VERSION
#error PROTOBUF_MIN_PROTOC_VERSION was previously defined
#endif
#define PROTOBUF_MIN_PROTOC_VERSION 4023000

#ifdef PROTOBUF_VERSION_SUFFIX
#error PROTOBUF_VERSION_SUFFIX was previously defined
#endif
#define PROTOBUF_VERSION_SUFFIX ""
// Note: PROTOBUF_VERSION and related macros are now defined by the external
// protobuf library's runtime_version.h. We don't redefine them here to avoid
// conflicts with the protobuf library's version checking.

#ifdef PROTOBUF_ALWAYS_INLINE
#error PROTOBUF_ALWAYS_INLINE was previously defined
Expand Down Expand Up @@ -447,9 +431,7 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
// which the offsets of the direct fields of a class are non-constant.
// Fields inherited from superclasses *can* have non-constant offsets,
// but that's not what this macro will be used for.
#ifdef PROTOBUF_FIELD_OFFSET
#error PROTOBUF_FIELD_OFFSET was previously defined
#endif
#ifndef PROTOBUF_FIELD_OFFSET
#if defined(__clang__)
// For Clang we use __builtin_offsetof() and suppress the warning,
// to avoid Control Flow Integrity and UBSan vptr sanitizers from
Expand All @@ -471,6 +453,7 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3),
&reinterpret_cast<const TYPE*>(16)->FIELD) - \
reinterpret_cast<const char*>(16))
#endif
#endif // PROTOBUF_FIELD_OFFSET

#ifdef PROTOBUF_EXPORT
#error PROTOBUF_EXPORT was previously defined
Expand Down
6 changes: 2 additions & 4 deletions src/google/protobuf/util/converter/port_undef.inc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
#undef PROTOBUF_RETURNS_NONNULL
#undef PROTOBUF_ATTRIBUTE_REINITIALIZES
#undef PROTOBUF_RTTI
#undef PROTOBUF_VERSION
#undef PROTOBUF_VERSION_SUFFIX
// Note: PROTOBUF_VERSION and related macros are not undefined here because
// they are now managed by the external protobuf library, not by our port_def.inc
#undef PROTOBUF_FIELD_OFFSET
#undef PROTOBUF_MIN_HEADER_VERSION_FOR_PROTOC
#undef PROTOBUF_MIN_PROTOC_VERSION
#undef PROTOBUF_PREDICT_TRUE
#undef PROTOBUF_PREDICT_FALSE
#undef PROTOBUF_FALLTHROUGH_INTENDED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void ProtoStreamObjectWriter::AnyWriter::StartAny(const DataPiece& value) {

// Now we know the proto type and can interpret all data fields we gathered
// before the "@type" field.
for (int i = 0; i < uninterpreted_events_.size(); ++i) {
for (size_t i = 0; i < uninterpreted_events_.size(); ++i) {
uninterpreted_events_[i].Replay(this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void TypeInfoTestHelper::ResetTypeInfo(
switch (type_) {
case USE_TYPE_RESOLVER: {
const DescriptorPool* pool = descriptors[0]->file()->pool();
for (int i = 1; i < descriptors.size(); ++i) {
for (size_t i = 1; i < descriptors.size(); ++i) {
ABSL_QCHECK(pool == descriptors[i]->file()->pool())
<< "Descriptors from different pools are not supported.";
}
Expand Down
2 changes: 1 addition & 1 deletion src/google/protobuf/util/converter/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ std::string GetFullTypeWithUrl(absl::string_view simple_type) {
const google::protobuf::Option* FindOptionOrNull(
const RepeatedPtrField<google::protobuf::Option>& options,
absl::string_view option_name) {
for (int i = 0; i < options.size(); ++i) {
for (size_t i = 0; i < options.size(); ++i) {
const google::protobuf::Option& opt = options.Get(i);
if (opt.name() == option_name) {
return &opt;
Expand Down