Browse Source

Change generated code suffices to qpb

- Change file suffices for generated code to qpb to avoid
  conflicts with genuine C/C++ protobuf generators
Alexey Edelev 5 years ago
parent
commit
215f1ccf7f

+ 1 - 1
README.md

@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
 
 **For each generated class you also need to call 'qRegisterProtobufType<GeneratedClassName>' to enable serialization and QML support**
 
-**Other option is to include common "qtprotobuf_global.pb.h" file and call apptopriate qRegisterProtobufTypes() method for you package**
+**Other option is to include common "qtprotobuf_global.qpb.h" file and call apptopriate qRegisterProtobufTypes() method for you package**
 
 ## CMake functions reference
 

+ 2 - 2
examples/addressbook/addressbookengine.cpp

@@ -25,8 +25,8 @@
 
 #include "addressbookengine.h"
 
-#include "addressbook.pb.h"
-#include "addressbook_grpc.pb.h"
+#include "addressbook.qpb.h"
+#include "addressbook_grpc.qpb.h"
 
 #include <QGrpcHttp2Channel>
 #include <QGrpcUserPasswordCredentials>

+ 1 - 1
examples/addressbook/addressbookengine.h

@@ -26,7 +26,7 @@
 #pragma once
 
 #include <QObject>
-#include "addressbook.pb.h"
+#include "addressbook.qpb.h"
 
 #include "universallistmodel.h"
 

+ 2 - 2
examples/addressbook/main.cpp

@@ -30,8 +30,8 @@
 #include <QQmlContext>
 
 #include "addressbookengine.h"
-#include "addressbook.pb.h"
-#include "qtprotobuf_global.pb.h"
+#include "addressbook.qpb.h"
+#include "qtprotobuf_global.qpb.h"
 
 #include <QMetaProperty>
 #include <QQmlPropertyMap>

+ 2 - 2
examples/simplechat/main.cpp

@@ -29,8 +29,8 @@
 #include <QQmlApplicationEngine>
 #include <QQmlContext>
 
-#include "simplechat.pb.h"
-#include "qtprotobuf_global.pb.h"
+#include "simplechat.qpb.h"
+#include "qtprotobuf_global.qpb.h"
 
 #include "simplechatengine.h"
 

+ 1 - 1
examples/simplechat/simplechatengine.cpp

@@ -25,7 +25,7 @@
 
 #include "simplechatengine.h"
 
-#include "simplechat_grpc.pb.h"
+#include "simplechat_grpc.qpb.h"
 
 #include <QGrpcHttp2Channel>
 #include <QGrpcUserPasswordCredentials>

+ 2 - 2
examples/simplechat/simplechatengine.h

@@ -27,8 +27,8 @@
 
 #include <QObject>
 
-#include "simplechat.pb.h"
-#include "simplechat_grpc.pb.h"
+#include "simplechat.qpb.h"
+#include "simplechat_grpc.qpb.h"
 
 #include "universallistmodel.h"
 

+ 1 - 1
src/generator/templates.cpp

@@ -298,7 +298,7 @@ const std::unordered_map<::google::protobuf::FieldDescriptor::Type, std::string>
     {::google::protobuf::FieldDescriptor::TYPE_SINT64, "sint64"}     //Limited usage see https://doc.qt.io/qt-5/qtqml-typesystem-basictypes.html
 };
 
-const char *Templates::ProtoFileSuffix = ".pb";
+const char *Templates::ProtoFileSuffix = ".qpb";
 const char *Templates::GrpcFileSuffix = "_grpc";
 
 const std::string Templates::GlobalDeclarationsFilename = std::string("qtprotobuf_global");

+ 4 - 2
src/protobuf/QtProtobufGen.cmake.in

@@ -1,6 +1,6 @@
 function(generate_qtprotobuf)
     set(options)
-    set(oneValueArgs OUT_DIR TARGET MULTI QML)
+    set(oneValueArgs OUT_DIR TARGET MULTI QML GENERATED_HEADERS_VAR)
     set(multiValueArgs GENERATED_HEADERS EXCLUDE_HEADERS PROTO_FILES)
     cmake_parse_arguments(generate_qtprotobuf "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
 
@@ -85,7 +85,9 @@ function(generate_qtprotobuf)
     )
 
     add_custom_target(${GEN_TARGET} DEPENDS ${QTPROTOBUF_GENERATED_SOURCES} ${QTPROTOBUF_GENERATED_HEADERS} ${generate_qtprotobuf_PROTO_FILES})
-
+    if(NOT "${generate_qtprotobuf_GENERATED_HEADERS_VAR}" STREQUAL "")
+        set(${generate_qtprotobuf_GENERATED_HEADERS_VAR} ${QTPROTOBUF_GENERATED_HEADERS} PARENT_SCOPE)
+    endif()
     qt5_wrap_cpp(MOC_SOURCES ${QTPROTOBUF_GENERATED_HEADERS})
     list(APPEND GENERATED_SOURCES ${MOC_SOURCES})
     set_source_files_properties(${QTPROTOBUF_GENERATED_SOURCES} PROPERTIES GENERATED TRUE)

+ 2 - 2
src/protobuf/parsemessages.go

@@ -69,11 +69,11 @@ func main() {
 		}
 
 		if messageFound {
-			fmt.Printf("%s.pb.h;", basename)
+			fmt.Printf("%s.qpb.h;", basename)
 		}
 
 		if serviceFound {
-			fmt.Printf("%s_grpc.pb.h;", basename)
+			fmt.Printf("%s_grpc.qpb.h;", basename)
 		}
 	}
 

+ 2 - 2
tests/test_grpc/clienttest.cpp

@@ -23,8 +23,8 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include "testservice_grpc.pb.h"
-#include "qtprotobuf_global.pb.h"
+#include "testservice_grpc.qpb.h"
+#include "qtprotobuf_global.qpb.h"
 #include <QGrpcHttp2Channel>
 #include <QGrpcCredentials>
 #include <QGrpcInsecureCredentials>

+ 1 - 1
tests/test_grpc/sslclienttest.cpp

@@ -23,7 +23,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include "testservice_grpc.pb.h"
+#include "testservice_grpc.qpb.h"
 
 #include <QGrpcHttp2Channel>
 #include <QGrpcSslCredentials>

+ 2 - 2
tests/test_protobuf/deserializationtest.cpp

@@ -25,8 +25,8 @@
 
 #include "deserializationtest.h"
 
-#include "simpletest.pb.h"
-#include "qtprotobuf_global.pb.h"
+#include "simpletest.qpb.h"
+#include "qtprotobuf_global.qpb.h"
 
 using namespace qtprotobufnamespace::tests;
 using namespace QtProtobuf::tests;

+ 2 - 2
tests/test_protobuf/jsonserializationtest.cpp

@@ -29,8 +29,8 @@
 
 #include <qprotobufjsonserializer.h>
 
-#include "simpletest.pb.h"
-#include "qtprotobuf_global.pb.h"
+#include "simpletest.qpb.h"
+#include "qtprotobuf_global.qpb.h"
 
 using namespace qtprotobufnamespace::tests;
 

+ 1 - 1
tests/test_protobuf/serializationcomplexmessagemap.cpp

@@ -25,7 +25,7 @@
 
 #include "serializationtest.h"
 
-#include "simpletest.pb.h"
+#include "simpletest.qpb.h"
 
 using namespace qtprotobufnamespace::tests;
 using namespace QtProtobuf::tests;

+ 2 - 2
tests/test_protobuf/serializationtest.cpp

@@ -25,8 +25,8 @@
 
 #include "serializationtest.h"
 
-#include "simpletest.pb.h"
-#include "qtprotobuf_global.pb.h"
+#include "simpletest.qpb.h"
+#include "qtprotobuf_global.qpb.h"
 
 using namespace qtprotobufnamespace::tests;
 using namespace QtProtobuf::tests;

+ 1 - 1
tests/test_protobuf/simpletest.cpp

@@ -23,6 +23,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include "simpletest.pb.h"
+#include "simpletest.qpb.h"
 
 #include "./simpletest.cpp.inc"

+ 1 - 1
tests/test_protobuf/simpletest.cpp.inc

@@ -29,7 +29,7 @@
 
 #include <gtest/gtest.h>
 
-#include "qtprotobuf_global.pb.h"
+#include "qtprotobuf_global.qpb.h"
 
 using namespace qtprotobufnamespace::tests;
 

+ 2 - 2
tests/test_qml/main.cpp

@@ -25,8 +25,8 @@
 
 #include <QtQuickTest/quicktest.h>
 
-#include "simpletest.pb.h"
-#include "qtprotobuf_global.pb.h"
+#include "simpletest.qpb.h"
+#include "qtprotobuf_global.qpb.h"
 
 using namespace qtprotobufnamespace::tests;