Defines Protobuf compiler version strings as macros and separates out suffix string definition.

This conforms to the Protobuf release process so that suffix "-main" will stay in main and not be overwritten.

PiperOrigin-RevId: 570480115
pull/14263/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent 68fce2e22a
commit 3c59585bc1
  1. 5
      src/google/protobuf/compiler/BUILD.bazel
  2. 2
      src/google/protobuf/compiler/cpp/file.cc
  3. 4
      src/google/protobuf/compiler/java/file.cc
  4. 2
      src/google/protobuf/compiler/plugin.pb.h
  5. 3
      src/google/protobuf/compiler/python/generator.cc
  6. 25
      src/google/protobuf/compiler/versions.h
  7. 26
      src/google/protobuf/compiler/versions_suffix.h
  8. 2
      src/google/protobuf/cpp_features.pb.h
  9. 2
      src/google/protobuf/descriptor.pb.h

@ -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 = [

@ -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"(

@ -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"

@ -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

@ -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_) {

@ -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__

@ -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__

@ -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

@ -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

Loading…
Cancel
Save