Browse Source

Make qtprotobuf compatible with protoc version less than 3.5

Viktor Kopp 6 years ago
parent
commit
aa126e01a3
2 changed files with 9 additions and 1 deletions
  1. 8 1
      src/generator/generator.cpp
  2. 1 0
      src/generator/generator.h

+ 8 - 1
src/generator/generator.cpp

@@ -37,7 +37,6 @@
 #include <google/protobuf/io/zero_copy_stream.h>
 #include <google/protobuf/descriptor.h>
 
-
 using namespace ::qtprotobuf::generator;
 using namespace ::google::protobuf;
 using namespace ::google::protobuf::compiler;
@@ -153,6 +152,14 @@ bool QtGenerator::GenerateAll(const std::vector<const FileDescriptor *> &files,
                                  std::move(std::unique_ptr<io::ZeroCopyOutputStream>(generatorContext->Open(globalEnumsFilename))));
     enumGen.run();
 
+    // FIXME: not sure about the actual protobuf version where GenerateAll was actually implemented
+#if GOOGLE_PROTOBUF_VERSION < 3006000
+    CodeGenerator::GenerateAll(files, parameter, generatorContext, error);
+    *error = "";
+    return true;
+#else
     return CodeGenerator::GenerateAll(files, parameter, generatorContext, error);
+#endif
+
 }
 

+ 1 - 0
src/generator/generator.h

@@ -49,6 +49,7 @@ class QtGenerator : public ::google::protobuf::compiler::CodeGenerator
                              const std::string &parameter,
                              ::google::protobuf::compiler::GeneratorContext *generatorContext,
                              std::string *error) const override;
+      virtual bool HasGenerateAll() const override { return true; }
 };
 
 } //namespace generator