From d96032d1a501d8d8ee2f581d0a9597d631797c5f Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Wed, 3 May 2023 08:20:20 -0700 Subject: [PATCH] Implement option retention for Ruby PiperOrigin-RevId: 529096272 --- src/google/protobuf/compiler/ruby/BUILD.bazel | 1 + src/google/protobuf/compiler/ruby/ruby_generator.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/compiler/ruby/BUILD.bazel b/src/google/protobuf/compiler/ruby/BUILD.bazel index 520b6919438f..2aee20e96e13 100644 --- a/src/google/protobuf/compiler/ruby/BUILD.bazel +++ b/src/google/protobuf/compiler/ruby/BUILD.bazel @@ -20,6 +20,7 @@ cc_library( "//src/google/protobuf:descriptor_legacy", "//src/google/protobuf:protobuf_nowkt", "//src/google/protobuf/compiler:code_generator", + "//src/google/protobuf/compiler:retention", ], ) diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.cc b/src/google/protobuf/compiler/ruby/ruby_generator.cc index 70a6a837d18e..f95ec0909940 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generator.cc +++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc @@ -39,6 +39,7 @@ #include "absl/log/absl_log.h" #include "absl/strings/escaping.h" #include "google/protobuf/compiler/plugin.h" +#include "google/protobuf/compiler/retention.h" #include "google/protobuf/descriptor.h" #include "google/protobuf/descriptor.pb.h" #include "google/protobuf/descriptor_legacy.h" @@ -238,8 +239,7 @@ void EndPackageModules(int levels, io::Printer* printer) { } std::string SerializedDescriptor(const FileDescriptor* file) { - FileDescriptorProto file_proto; - file->CopyTo(&file_proto); + FileDescriptorProto file_proto = StripSourceRetentionOptions(*file); std::string file_data; file_proto.SerializeToString(&file_data); return file_data;