diff --git a/.gitignore b/.gitignore index cedd476..47a74da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pro.user* +*.qbs.user* debug release *.autosave diff --git a/examples/examples.qbs b/examples/examples.qbs new file mode 100644 index 0000000..17430ae --- /dev/null +++ b/examples/examples.qbs @@ -0,0 +1,9 @@ +import qbs + +Project { + name: "Examples" + + references: [ + "mqtt" + ] +} diff --git a/examples/mqtt/client/client.qbs b/examples/mqtt/client/client.qbs new file mode 100644 index 0000000..d91b36c --- /dev/null +++ b/examples/mqtt/client/client.qbs @@ -0,0 +1,28 @@ +import qbs + +QtApplication { + name: "Client" + targetName: "qmqtt_example" + + files: [ + "example.cpp" + ] + + Depends { + name: "Qt" + submodules: [ + "core", + "network", + ] + } + + Depends { + name: "qmqtt" + } + + Group { + fileTagsFilter: "application" + qbs.install: true + qbs.installDir: "bin" + } +} diff --git a/examples/mqtt/mqtt.qbs b/examples/mqtt/mqtt.qbs new file mode 100644 index 0000000..cce9d1a --- /dev/null +++ b/examples/mqtt/mqtt.qbs @@ -0,0 +1,9 @@ +import qbs + +Project { + name: "mqtt" + + references: [ + "client" + ] +} diff --git a/qmqtt.qbs b/qmqtt.qbs new file mode 100644 index 0000000..689ef3f --- /dev/null +++ b/qmqtt.qbs @@ -0,0 +1,11 @@ +import qbs + +Project { + name: "QMQTT" + + references: [ + "examples", + "src", + "tests", + ] +} diff --git a/src/mqtt/mqtt.qbs b/src/mqtt/mqtt.qbs new file mode 100644 index 0000000..1fe76db --- /dev/null +++ b/src/mqtt/mqtt.qbs @@ -0,0 +1,111 @@ +import qbs +import qbs.TextFile + +Product { + name: "qmqtt" + type: [ + libraryType, + "mqttmodule", + ] + property string libraryType: "dynamiclibrary" + targetName: "qmqtt" + + cpp.defines: [ + "QT_BUILD_MQTT_LIB", + "QT_NO_CAST_TO_ASCII", + "QT_NO_CAST_FROM_ASCII", + ] + + cpp.includePaths: sourceDirectory + + files: [ + "*.cpp", + "*_p.h", + ] + + Group { + name: "Public Headers" + fileTags: [ + "hpp", + "public_headers" + ] + files: [ + "*.h" + ] + excludeFiles: parent.files + } + + Group { + name: "mqtt Module Template" + fileTags: [ + "mqttmoduletemplate" + ] + files: "mqttModule.qbs" + } + + Group { + fileTagsFilter: libraryType + qbs.install: true + qbs.installDir: "lib" + } + + Group { + fileTagsFilter: "public_headers" + qbs.install: true + qbs.installDir: "include/"+product.name + } + + Rule { + /* TODO: copy mqtt-module in module directory */ + inputs: "mqttmoduletemplate" + Artifact { + filePath: "mqtt/"+input.fileName + fileTags: "mqttmodule" + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "Create Mqtt Module"; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + var file = new TextFile(input.filePath); + var content = file.readAll(); + file.close() + content = content.replace(/dummyIncludePath/g, '"'+input.moduleProperty("qbs", "installRoot")+'/include/'+product.targetName+'"'); + content = content.replace(/dummyLibraryPath/g, '"'+input.moduleProperty("qbs", "installRoot")+'/lib"'); + content = content.replace(/dummyLibrary/g, product.libraryType === "dynamiclibrary" ? "dynamicLibraries" : "staticLibraries"); + file = new TextFile(output.filePath, TextFile.WriteOnly); + file.write(content); + file.close(); + } + return cmd; + } + } + + Depends { + name: "cpp" + } + + Depends { + name: "Qt" + submodules: [ + "core", + "network", + ] + } + + Export { + Depends { + name: "cpp" + } + + Depends { + name: "Qt" + submodules: [ + "core", + "network", + ] + } + + cpp.includePaths: product.sourceDirectory + } +} diff --git a/src/mqtt/mqttModule.qbs b/src/mqtt/mqttModule.qbs new file mode 100644 index 0000000..42b9e02 --- /dev/null +++ b/src/mqtt/mqttModule.qbs @@ -0,0 +1,19 @@ +import qbs + +Module { + Depends { + name: "cpp" + } + + Depends { + name: "Qt" + submodules: [ + "core", + "network", + ] + } + + cpp.includePaths: dummyIncludePath + cpp.libraryPaths: dummyLibraryPath + cpp.dummyLibrary: "mqtt" +} diff --git a/src/src.qbs b/src/src.qbs new file mode 100644 index 0000000..28ea746 --- /dev/null +++ b/src/src.qbs @@ -0,0 +1,9 @@ +import qbs + +Project { + name: "Sources" + + references: [ + "mqtt/mqtt.qbs" + ] +} diff --git a/tests/auto/auto.qbs b/tests/auto/auto.qbs new file mode 100644 index 0000000..39dc0bc --- /dev/null +++ b/tests/auto/auto.qbs @@ -0,0 +1,9 @@ +import qbs + +Project { + name: "Auto" + + references: [ + "cmake" + ] +} diff --git a/tests/auto/cmake/cmake.qbs b/tests/auto/cmake/cmake.qbs new file mode 100644 index 0000000..7545d5f --- /dev/null +++ b/tests/auto/cmake/cmake.qbs @@ -0,0 +1,6 @@ +import qbs + +/* TODO: add cmake test */ +Product { + name: "CMake" +} diff --git a/tests/gtest/gtest.qbs b/tests/gtest/gtest.qbs new file mode 100644 index 0000000..a4f92f5 --- /dev/null +++ b/tests/gtest/gtest.qbs @@ -0,0 +1,25 @@ +import qbs + +Project { + name: "GTest" + property bool runUnitTests: true + + references: [ + "gtest", + "tests", + ] + + AutotestRunner { + condition: runUnitTests && qbs.targetOS.contains("unix") + + Properties { + condition: qbs.targetOS.contains("macx") + + /* TODO: if needed, add "install_name_tool" usage */ + } + + Depends { + name: "Google-Test" + } + } +} diff --git a/tests/gtest/gtest/gtest.qbs b/tests/gtest/gtest/gtest.qbs new file mode 100644 index 0000000..d3565fc --- /dev/null +++ b/tests/gtest/gtest/gtest.qbs @@ -0,0 +1,40 @@ +import qbs + +DynamicLibrary { + name: "Google-Test" + targetName: "gtest" + + cpp.defines: [ + "GTEST_LIBRARY" + ] + + files: [ + "googletest/googletest/src/gtest-all.cc", + "googletest/googlemock/src/gmock-all.cc", + ] + + cpp.includePaths: [ + "googletest/googletest/include", + "googletest/googletest", + "googletest/googlemock/include", + "googletest/googlemock", + ] + + Depends { + name: "Qt" + submodules: [ + "core" + ] + } + + Export { + Depends { + name: "cpp" + } + + cpp.includePaths: [ + "googletest/googletest/include", + "googletest/googlemock/include", + ] + } +} diff --git a/tests/gtest/tests/tests.qbs b/tests/gtest/tests/tests.qbs new file mode 100644 index 0000000..cde72c3 --- /dev/null +++ b/tests/gtest/tests/tests.qbs @@ -0,0 +1,53 @@ +import qbs +import qbs.Process + +Product { + name: "Tests" + type: [ + "application", + ] + targetName: "qmqtt_tests" + + cpp.defines: [ + "QMQTT_LIBRARY_TESTS" + ] + + files: [ + "clienttest.cpp", + "tcpserver.cpp", + "main.cpp", + "customprinter.cpp", + "networktest.cpp", + "messagetest.cpp", + "frametest.cpp", + "sockettest.cpp", + "tcpserver.h", + "customprinter.h", + "networkmock.h", + "socketmock.h", + "timermock.h", + "iodevicemock.h", + ] + + Depends { + name: "Qt" + submodules: [ + "core", + "network", + "testlib", + ] + } + + Depends { + name: "Google-Test" + } + + Depends { + name: "qmqtt" + } + + Depends { + /* TODO: if needed, create mqtt-private */ + name: "mqtt-private" + } +} diff --git a/tests/tests.qbs b/tests/tests.qbs new file mode 100644 index 0000000..dd7e1da --- /dev/null +++ b/tests/tests.qbs @@ -0,0 +1,18 @@ +import qbs + +Project { + name: "Tests" + /* NOTE: to change this just add "Tests.buildUnitTests:false" or "Tests.buildUnitTests:true" to qbs call */ + property bool buildUnitTests: true + + references: [ + "auto" + ] + + SubProject { + filePath: "gtest/gtest.qbs" + Properties { + condition: qbs.targetOS.contains("unix") && buildUnitTests + } + } +}