Skip to content

Commit f3ca14c

Browse files
tonyliaosscopybara-github
authored andcommitted
Add the ability to build Edition 2026 codegen with protoc.
PiperOrigin-RevId: 902280590
1 parent e3370c2 commit f3ca14c

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

editions/BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,24 @@ cc_proto_library(
401401
deps = [":test_editions_2024_default_features_proto"],
402402
)
403403

404+
proto_library(
405+
name = "test_editions_2026_default_features_proto",
406+
testonly = True,
407+
srcs = ["input/test_editions_2026_default_features.proto"],
408+
)
409+
410+
cc_proto_library(
411+
name = "test_editions_2026_default_features_cc_proto",
412+
testonly = True,
413+
deps = [":test_editions_2026_default_features_proto"],
414+
)
415+
404416
cc_test(
405417
name = "generated_files_test",
406418
srcs = ["generated_files_test.cc"],
407419
deps = [
408420
":test_editions_2024_default_features_cc_proto",
421+
":test_editions_2026_default_features_cc_proto",
409422
":test_editions_default_features_cc_proto",
410423
":test_messages_proto2_editions_cc_proto",
411424
":test_messages_proto3_editions_cc_proto",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
edition = "2026";
2+
3+
package protobuf_editions_test;
4+
5+
// This file tests the default Edition2024 features in the absence of any
6+
// dependencies.
7+
8+
enum Editions2026DefaultEnum {
9+
EDITIONS2026_DEFAULT_ENUM_UNKNOWN = 0;
10+
EDITIONS2026_DEFAULT_ENUM_VALUE1 = 1;
11+
}
12+
13+
message Editions2026DefaultMessage {
14+
int32 int32_field = 1;
15+
string string_field = 2;
16+
Editions2026DefaultEnum enum_field = 3;
17+
18+
repeated int32 repeated_int32_field = 4;
19+
20+
message SubMessage {
21+
int32 nested_int32_field = 1;
22+
}
23+
SubMessage sub_message_field = 6;
24+
}

src/google/protobuf/compiler/code_generator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,12 @@ class PROTOC_EXPORT CodeGenerator {
179179
// The minimum edition supported by protoc.
180180
constexpr auto ProtocMinimumEdition() { return Edition::EDITION_PROTO2; }
181181
// The maximum edition supported by protoc.
182-
constexpr auto ProtocMaximumEdition() { return Edition::EDITION_2024; }
182+
constexpr auto ProtocMaximumEdition() { return Edition::EDITION_2026; }
183183

184184
// The maximum edition known to protoc, which may or may not be officially
185185
// supported yet. During development of a new edition, this will typically be
186186
// set to that.
187-
constexpr auto MaximumKnownEdition() { return Edition::EDITION_2024; }
187+
constexpr auto MaximumKnownEdition() { return Edition::EDITION_2026; }
188188

189189
// CodeGenerators generate one or more files in a given directory. This
190190
// abstract interface represents the directory to which the CodeGenerator is

src/google/protobuf/compiler/java/java_features.pb.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/protobuf/cpp_features.pb.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)