aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Van Lenten <thomasvl@google.com>2016-09-15 17:36:08 -0400
committerGitHub <noreply@github.com>2016-09-15 17:36:08 -0400
commitb4235ac79c0d3e932f2fb24d2dc8b81fbc0de45a (patch)
treec0f07258e6db745658eefb949f5673f1e813cc76 /src
parente0e54661f76183684dca66694967a60cbb10f04e (diff)
parent1aa65000568422f0187d2eb4fef00bcdca0cc125 (diff)
downloadprotobuf-b4235ac79c0d3e932f2fb24d2dc8b81fbc0de45a.tar.gz
protobuf-b4235ac79c0d3e932f2fb24d2dc8b81fbc0de45a.tar.bz2
protobuf-b4235ac79c0d3e932f2fb24d2dc8b81fbc0de45a.zip
Merge pull request #2123 from thomasvl/objc_better_versioning_take2
Update the ObjC version checks to support a min and current version.
Diffstat (limited to 'src')
-rw-r--r--src/google/protobuf/compiler/objectivec/objectivec_file.cc24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/google/protobuf/compiler/objectivec/objectivec_file.cc b/src/google/protobuf/compiler/objectivec/objectivec_file.cc
index 878a3743..7ad127bb 100644
--- a/src/google/protobuf/compiler/objectivec/objectivec_file.cc
+++ b/src/google/protobuf/compiler/objectivec/objectivec_file.cc
@@ -51,10 +51,8 @@ namespace objectivec {
namespace {
-// This is also found in GPBBootstrap.h, and needs to be kept in sync. It
-// is the version check done to ensure generated code works with the current
-// runtime being used.
-const int32 GOOGLE_PROTOBUF_OBJC_GEN_VERSION = 30002;
+// This is also found in GPBBootstrap.h, and needs to be kept in sync.
+const int32 GOOGLE_PROTOBUF_OBJC_VERSION = 30002;
const char* kHeaderExtension = ".pbobjc.h";
@@ -192,13 +190,19 @@ void FileGenerator::GenerateHeader(io::Printer *printer) {
// Add some verification that the generated code matches the source the
// code is being compiled with.
+ // NOTE: This captures the raw numeric values at the time the generator was
+ // compiled, since that will be the versions for the ObjC runtime at that
+ // time. The constants in the generated code will then get their values at
+ // at compile time (so checking against the headers being used to compile).
printer->Print(
- "#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != $protoc_gen_objc_version$\n"
- "#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.\n"
+ "#if GOOGLE_PROTOBUF_OBJC_VERSION < $google_protobuf_objc_version$\n"
+ "#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.\n"
+ "#endif\n"
+ "#if $google_protobuf_objc_version$ < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION\n"
+ "#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.\n"
"#endif\n"
"\n",
- "protoc_gen_objc_version",
- SimpleItoa(GOOGLE_PROTOBUF_OBJC_GEN_VERSION));
+ "google_protobuf_objc_version", SimpleItoa(GOOGLE_PROTOBUF_OBJC_VERSION));
// #import any headers for "public imports" in the proto file.
{
@@ -392,7 +396,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) {
" // about thread safety and initialization of registry.\n"
" static GPBExtensionRegistry* registry = nil;\n"
" if (!registry) {\n"
- " GPBDebugCheckRuntimeVersion();\n"
+ " GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n"
" registry = [[GPBExtensionRegistry alloc] init];\n");
printer->Indent();
@@ -487,7 +491,7 @@ void FileGenerator::GenerateSource(io::Printer *printer) {
" // about thread safety of the singleton.\n"
" static GPBFileDescriptor *descriptor = NULL;\n"
" if (!descriptor) {\n"
- " GPBDebugCheckRuntimeVersion();\n");
+ " GPB_DEBUG_CHECK_RUNTIME_VERSIONS();\n");
if (vars["objc_prefix"].size() > 0) {
printer->Print(
vars,