[Fix][Compiler] Plugins fall back to the edition 2023 for older protobuf (#41357)

Fixes the issue with gRPC protobuf plugins declaring the support for `protobuf::Edition::EDITION_2024`, which is higher than the one supported by the protobuf we're using at the moment: `EDITION_2023` at google/protobuf@74211c0dfc.

Related:
- Effectively undoes #40957

Closes #41357

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/41357 from sergiitk:fix/compiler/protobuf-edition-2023 c3d7b9b27ead199e5e4c66052d4d91d32a7370c6
PiperOrigin-RevId: 853371790
This commit is contained in:
Sergii Tkachenko
2026-01-07 12:37:00 -08:00
committed by Copybara-Service
parent 518f4a5ef0
commit 9b77c0d4df
6 changed files with 36 additions and 0 deletions

View File

@@ -45,7 +45,13 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
return grpc::protobuf::Edition::EDITION_PROTO2;
}
grpc::protobuf::Edition GetMaximumEdition() const override {
// TODO(yuanweiz): Remove when the protobuf is updated to a version
// that supports edition 2024.
#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000
return grpc::protobuf::Edition::EDITION_2024;
#else
return grpc::protobuf::Edition::EDITION_2023;
#endif
}
#endif

View File

@@ -42,7 +42,13 @@ class CSharpGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
return grpc::protobuf::Edition::EDITION_PROTO2;
}
grpc::protobuf::Edition GetMaximumEdition() const override {
// TODO(yuanweiz): Remove when the protobuf is updated to a version
// that supports edition 2024.
#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000
return grpc::protobuf::Edition::EDITION_2024;
#else
return grpc::protobuf::Edition::EDITION_2023;
#endif
}
#endif

View File

@@ -93,7 +93,13 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
return grpc::protobuf::Edition::EDITION_PROTO2;
}
grpc::protobuf::Edition GetMaximumEdition() const override {
// TODO(yuanweiz): Remove when the protobuf is updated to a version
// that supports edition 2024.
#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000
return grpc::protobuf::Edition::EDITION_2024;
#else
return grpc::protobuf::Edition::EDITION_2023;
#endif
}
#endif

View File

@@ -46,7 +46,13 @@ class PHPGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
return grpc::protobuf::Edition::EDITION_PROTO2;
}
grpc::protobuf::Edition GetMaximumEdition() const override {
// TODO(yuanweiz): Remove when the protobuf is updated to a version
// that supports edition 2024.
#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000
return grpc::protobuf::Edition::EDITION_2024;
#else
return grpc::protobuf::Edition::EDITION_2023;
#endif
}
#endif

View File

@@ -59,7 +59,13 @@ class PythonGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
return grpc::protobuf::Edition::EDITION_PROTO2;
}
grpc::protobuf::Edition GetMaximumEdition() const override {
// TODO(yuanweiz): Remove when the protobuf is updated to a version
// that supports edition 2024.
#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000
return grpc::protobuf::Edition::EDITION_2024;
#else
return grpc::protobuf::Edition::EDITION_2023;
#endif
}
#endif

View File

@@ -42,7 +42,13 @@ class RubyGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
return grpc::protobuf::Edition::EDITION_PROTO2;
}
grpc::protobuf::Edition GetMaximumEdition() const override {
// TODO(yuanweiz): Remove when the protobuf is updated to a version
// that supports edition 2024.
#if !defined(GOOGLE_PROTOBUF_VERSION) || GOOGLE_PROTOBUF_VERSION >= 6032000
return grpc::protobuf::Edition::EDITION_2024;
#else
return grpc::protobuf::Edition::EDITION_2023;
#endif
}
#endif