diff --git a/src/google/protobuf/compiler/BUILD.bazel b/src/google/protobuf/compiler/BUILD.bazel index ce8635759c..273dae00b4 100644 --- a/src/google/protobuf/compiler/BUILD.bazel +++ b/src/google/protobuf/compiler/BUILD.bazel @@ -82,7 +82,10 @@ cc_library( cc_library( name = "versions", - hdrs = ["versions.h"], + hdrs = [ + "versions.h", + "versions_suffix.h", + ], copts = COPTS, include_prefix = "google/protobuf/compiler", visibility = [ diff --git a/src/google/protobuf/compiler/cpp/file.cc b/src/google/protobuf/compiler/cpp/file.cc index 700b0c95c4..da1c6c768e 100644 --- a/src/google/protobuf/compiler/cpp/file.cc +++ b/src/google/protobuf/compiler/cpp/file.cc @@ -314,7 +314,7 @@ void FileGenerator::GenerateFile(io::Printer* p, GeneratedFileType file_type, "// source: $filename$\n"); if (options_.opensource_runtime) { p->Print("// Protobuf C++ Version: $protobuf_cpp_version$\n", - "protobuf_cpp_version", internal::kProtoCppVersionString); + "protobuf_cpp_version", PROTOBUF_CPP_VERSION_STRING); } p->Print("\n"); p->Emit({{"cb", cb}, {"guard", guard}}, R"( diff --git a/src/google/protobuf/compiler/java/file.cc b/src/google/protobuf/compiler/java/file.cc index b86bb58f43..f116c1781c 100644 --- a/src/google/protobuf/compiler/java/file.cc +++ b/src/google/protobuf/compiler/java/file.cc @@ -248,7 +248,7 @@ void FileGenerator::Generate(io::Printer* printer) { "filename", file_->name()); if (options_.opensource_runtime) { printer->Print("// Protobuf Java Version: $protobuf_java_version$\n", - "protobuf_java_version", internal::kProtoJavaVersionString); + "protobuf_java_version", PROTOBUF_JAVA_VERSION_STRING); } if (!java_package_.empty()) { printer->Print( @@ -608,7 +608,7 @@ static void GenerateSibling( "\n", "filename", descriptor->file()->name()); printer.Print("// Protobuf Java Version: $protobuf_java_version$\n", - "protobuf_java_version", internal::kProtoJavaVersionString); + "protobuf_java_version", PROTOBUF_JAVA_VERSION_STRING); if (!java_package.empty()) { printer.Print( "package $package$;\n" diff --git a/src/google/protobuf/compiler/plugin.pb.h b/src/google/protobuf/compiler/plugin.pb.h index 81b3706012..00736191c6 100644 --- a/src/google/protobuf/compiler/plugin.pb.h +++ b/src/google/protobuf/compiler/plugin.pb.h @@ -1,6 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/compiler/plugin.proto -// Protobuf C++ Version: 4.25-main +// Protobuf C++ Version: 4.24.0-main #ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto_2epb_2eh #define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcompiler_2fplugin_2eproto_2epb_2eh diff --git a/src/google/protobuf/compiler/python/generator.cc b/src/google/protobuf/compiler/python/generator.cc index cbc6c5b5bd..f3cce736d6 100644 --- a/src/google/protobuf/compiler/python/generator.cc +++ b/src/google/protobuf/compiler/python/generator.cc @@ -341,8 +341,7 @@ void Generator::PrintTopBoilerplate() const { "filename", file_->name()); if (opensource_runtime_) { printer_->Print("# Protobuf Python Version: $protobuf_python_version$\n", - "protobuf_python_version", - internal::kProtoPythonVersionString); + "protobuf_python_version", PROTOBUF_PYTHON_VERSION_STRING); } printer_->Print("\"\"\"Generated protocol buffer code.\"\"\"\n"); if (!opensource_runtime_) { diff --git a/src/google/protobuf/compiler/versions.h b/src/google/protobuf/compiler/versions.h index 31f1d45e73..615944f8be 100644 --- a/src/google/protobuf/compiler/versions.h +++ b/src/google/protobuf/compiler/versions.h @@ -31,22 +31,10 @@ #ifndef GOOGLE_PROTOBUF_VERSIONS_H__ #define GOOGLE_PROTOBUF_VERSIONS_H__ -#include "absl/strings/string_view.h" +#include "google/protobuf/compiler/versions_suffix.h" -namespace google { -namespace protobuf { -namespace compiler { -namespace internal { // Defines compiler version strings for Protobuf code generators. // -// Note that the version suffix "-main" implies the main branch. For example, -// 4.25-main reflects a main branch version under development towards 25.x -// release, and thus should not be used for production. -// -// Unlike other repo versions, this file should be updated together with -// version.json whenever possible and reflect the correct version numbers -// correspondingly. -// // Currently, they are embedded into comments at each gencode for public // Protobuf C++, Java and Python. Further, we will add version strings for rest // of languages in version.json, and they will be used to validate version @@ -58,11 +46,8 @@ namespace internal { // // Please avoid changing them manually, as they should be updated automatically // by Protobuf release process. -constexpr absl::string_view kProtoCppVersionString = "4.25-main"; -constexpr absl::string_view kProtoJavaVersionString = "3.25-main"; -constexpr absl::string_view kProtoPythonVersionString = "4.25-main"; -} // namespace internal -} // namespace compiler -} // namespace protobuf -} // namespace google +#define PROTOBUF_CPP_VERSION_STRING "4.24.0" PROTOBUF_GENCODE_VERSION_SUFFIX +#define PROTOBUF_JAVA_VERSION_STRING "3.24.0" PROTOBUF_GENCODE_VERSION_SUFFIX +#define PROTOBUF_PYTHON_VERSION_STRING "4.24.0" PROTOBUF_GENCODE_VERSION_SUFFIX + #endif // GOOGLE_PROTOBUF_VERSIONS_H__ diff --git a/src/google/protobuf/compiler/versions_suffix.h b/src/google/protobuf/compiler/versions_suffix.h new file mode 100644 index 0000000000..5fd30faf0d --- /dev/null +++ b/src/google/protobuf/compiler/versions_suffix.h @@ -0,0 +1,26 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +#ifndef GOOGLE_PROTOBUF_COMPILER_VERSIONS_SUFFIX_H__ +#define GOOGLE_PROTOBUF_COMPILER_VERSIONS_SUFFIX_H__ + +// Defines compiler version suffix for Protobuf code generators. +// +// It is defined separately from the language-specific version strings that are +// in versions.h to prevent it from being overwritten when merging Protobuf +// release branches back to main, as the suffix "-main" should stay in the +// Protobuf github main branch. +// +// Note that the version suffix "-main" implies the main branch. For example, +// 4.25-main reflects a main branch version under development towards 25.x +// release, and thus should not be used for production. +// +// Please avoid changing it manually, as they should be updated automatically by +// the Protobuf release process. +#define PROTOBUF_GENCODE_VERSION_SUFFIX "-main" + +#endif // GOOGLE_PROTOBUF_COMPILER_VERSIONS_SUFFIX_H__ diff --git a/src/google/protobuf/cpp_features.pb.h b/src/google/protobuf/cpp_features.pb.h index e49a5d6577..2d409211d3 100644 --- a/src/google/protobuf/cpp_features.pb.h +++ b/src/google/protobuf/cpp_features.pb.h @@ -1,6 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/cpp_features.proto -// Protobuf C++ Version: 4.25-main +// Protobuf C++ Version: 4.24.0-main #ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcpp_5ffeatures_2eproto_2epb_2eh #define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fcpp_5ffeatures_2eproto_2epb_2eh diff --git a/src/google/protobuf/descriptor.pb.h b/src/google/protobuf/descriptor.pb.h index 63a8dd00f0..3f4c38a042 100644 --- a/src/google/protobuf/descriptor.pb.h +++ b/src/google/protobuf/descriptor.pb.h @@ -1,6 +1,6 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/descriptor.proto -// Protobuf C++ Version: 4.25-main +// Protobuf C++ Version: 4.24.0-main #ifndef GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto_2epb_2eh #define GOOGLE_PROTOBUF_INCLUDED_google_2fprotobuf_2fdescriptor_2eproto_2epb_2eh