From 61e1c030b28c3b3bc5849015cc19f2dbe01ed059 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 9 Feb 2024 13:37:12 -0800 Subject: [PATCH] [Protobuf] Absorb protobuf::MultiFileErrorCollector change (#35870) This is to absorb protobuf's breaking change introduce by https://github.com/protocolbuffers/protobuf/pull/15060. This is required to upgrade protobuf to v26. Internal b/324252829 Closes #35870 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35870 from veblush:protobuf-sv 46e29ee0d4cb586d5916af4028c508f633fc6b4a PiperOrigin-RevId: 605718900 --- tools/distrib/python/grpcio_tools/BUILD.bazel | 1 + .../python/grpcio_tools/grpc_tools/main.cc | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/distrib/python/grpcio_tools/BUILD.bazel b/tools/distrib/python/grpcio_tools/BUILD.bazel index 25cd7fe15b2..fac6bb3babd 100644 --- a/tools/distrib/python/grpcio_tools/BUILD.bazel +++ b/tools/distrib/python/grpcio_tools/BUILD.bazel @@ -28,6 +28,7 @@ cc_library( includes = ["."], deps = [ "//src/compiler:grpc_plugin_support", + "@com_google_absl//absl/strings", "@com_google_protobuf//:protoc_lib", ], ) diff --git a/tools/distrib/python/grpcio_tools/grpc_tools/main.cc b/tools/distrib/python/grpcio_tools/grpc_tools/main.cc index d49edd323a9..1d9749861bc 100644 --- a/tools/distrib/python/grpcio_tools/grpc_tools/main.cc +++ b/tools/distrib/python/grpcio_tools/grpc_tools/main.cc @@ -29,6 +29,8 @@ #include #include +#include "absl/strings/string_view.h" + #include "src/compiler/python_generator.h" using ::google::protobuf::FileDescriptor; @@ -105,14 +107,16 @@ class ErrorCollectorImpl : public MultiFileErrorCollector { std::vector<::grpc_tools::ProtocWarning>* warnings) : errors_(errors), warnings_(warnings) {} - void AddError(const std::string& filename, int line, int column, - const std::string& message) { - errors_->emplace_back(filename, line, column, message); + void RecordError(absl::string_view filename, int line, int column, + absl::string_view message) { + errors_->emplace_back(std::string(filename), line, column, + std::string(message)); } - void AddWarning(const std::string& filename, int line, int column, - const std::string& message) { - warnings_->emplace_back(filename, line, column, message); + void RecordWarning(absl::string_view filename, int line, int column, + absl::string_view message) { + warnings_->emplace_back(std::string(filename), line, column, + std::string(message)); } private: