diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc
index 4b7c5c9d912b1..5288fa321270b 100644
--- a/src/google/protobuf/compiler/cpp/helpers.cc
+++ b/src/google/protobuf/compiler/cpp/helpers.cc
@@ -72,6 +72,14 @@ namespace {
static const char kAnyMessageName[] = "Any";
static const char kAnyProtoFile[] = "google/protobuf/any.proto";
+// TODO(crbug.com/332939935): This is used to allow generating an AnyLite proto
+// compatible with /third_party/medialite instead of checking in compiled
+// protobufs that complicate rolling.
+// Upstream should be fixed so that we don't need to generate a separate
+// AnyLite, then this patch/change should be dropped.
+static const char kAnyLiteMessageName[] = "AnyLite";
+static const char kAnyLiteProtoFile[] = "google/protobuf/any_lite.proto";
+
std::string DotsToColons(const std::string& name) {
return StringReplace(name, ".", "::", true);
}
@@ -1082,11 +1090,13 @@ FieldOptions::CType EffectiveStringCType(const FieldDescriptor* field,
}
bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options) {
- return descriptor->name() == kAnyProtoFile;
+ return descriptor->name() == kAnyProtoFile ||
+ descriptor->name() == kAnyLiteProtoFile;
}
bool IsAnyMessage(const Descriptor* descriptor, const Options& options) {
- return descriptor->name() == kAnyMessageName &&
+ return (descriptor->name() == kAnyMessageName ||
+ descriptor->name() == kAnyLiteMessageName) &&
IsAnyMessage(descriptor->file(), options);
}
diff --git a/src/google/protobuf/compiler/cpp/message.cc b/src/google/protobuf/compiler/cpp/message.cc
index dd1daa30b080f..24e303c55e54a 100644
--- a/src/google/protobuf/compiler/cpp/message.cc
+++ b/src/google/protobuf/compiler/cpp/message.cc
@@ -2085,13 +2085,17 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) {
" message, type_url_field, value_field);\n"
"}\n");
}
- format(
- "bool $classname$::ParseAnyTypeUrl(\n"
- " ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,\n"
- " std::string* full_type_name) {\n"
- " return ::_pbi::ParseAnyTypeUrl(type_url, full_type_name);\n"
- "}\n"
- "\n");
+ // TODO(crbug.com/332939935): Remove this workaround when the AnyLite patch
+ // can go away.
+ if (descriptor_->name() != "AnyLite") {
+ format(
+ "bool $classname$::ParseAnyTypeUrl(\n"
+ " ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,\n"
+ " std::string* full_type_name) {\n"
+ " return ::_pbi::ParseAnyTypeUrl(type_url, full_type_name);\n"
+ "}\n"
+ "\n");
+ }
}
format(