diff options
Diffstat (limited to 'qbs/imports')
-rw-r--r-- | qbs/imports/QtcFunctions/functions.js | 24 | ||||
-rw-r--r-- | qbs/imports/QtcLibrary.qbs | 38 | ||||
-rw-r--r-- | qbs/imports/QtcPlugin.qbs | 62 | ||||
-rw-r--r-- | qbs/imports/QtcTool.qbs | 19 |
4 files changed, 143 insertions, 0 deletions
diff --git a/qbs/imports/QtcFunctions/functions.js b/qbs/imports/QtcFunctions/functions.js new file mode 100644 index 0000000000..23a51f80e8 --- /dev/null +++ b/qbs/imports/QtcFunctions/functions.js @@ -0,0 +1,24 @@ +// see PluginSpecPrivate::loadLibrary() +function qtLibraryName(qbs, name) +{ + if (qbs.debugInformation) { + if (qbs.targetOS.contains("windows")) + return name + "d"; + else if (qbs.targetOS.contains("osx")) + return name + "_debug"; + } + return name; +} + +function versionIsAtLeast(actualVersion, expectedVersion) +{ + var actualVersionParts = actualVersion.split('.').map(function(item) { return parseInt(item, 10); }); + var expectedVersionParts = expectedVersion.split('.').map(function(item) { return parseInt(item, 10); }); + for (var i = 0; i < expectedVersionParts.length; ++i) { + if (actualVersionParts[i] > expectedVersionParts[i]) + return true; + if (actualVersionParts[i] < expectedVersionParts[i]) + return false; + } + return i === expectedVersionParts.length || expectedVersionParts[i] === 0; +} diff --git a/qbs/imports/QtcLibrary.qbs b/qbs/imports/QtcLibrary.qbs new file mode 100644 index 0000000000..f7272066fb --- /dev/null +++ b/qbs/imports/QtcLibrary.qbs @@ -0,0 +1,38 @@ +import qbs.base 1.0 +import QtcFunctions + +DynamicLibrary { + Depends { name: "cpp" } + Depends { + condition: project.testsEnabled + name: "Qt.test" + } + + targetName: QtcFunctions.qtLibraryName(qbs, name) + destinationDirectory: project.ide_library_path + + cpp.defines: project.generalDefines + cpp.linkerFlags: { + if (qbs.buildVariant == "release" && (qbs.toolchain.contains("gcc") || qbs.toolchain.contains("mingw"))) + return ["-Wl,-s"] + else if (qbs.buildVariant == "debug" && qbs.toolchain.contains("msvc")) + return ["/INCREMENTAL:NO"] // Speed up startup time when debugging with cdb + } + cpp.installNamePrefix: "@rpath/PlugIns/" + cpp.rpaths: qbs.targetOS.contains("osx") + ? ["@loader_path/..", "@executable_path/.."] + : ["$ORIGIN", "$ORIGIN/.."] + property string libIncludeBase: ".." // #include <lib/header.h> + cpp.includePaths: [libIncludeBase] + + Export { + Depends { name: "cpp" } + cpp.includePaths: [libIncludeBase] + } + + Group { + fileTagsFilter: product.type + qbs.install: true + qbs.installDir: project.ide_library_path + } +} diff --git a/qbs/imports/QtcPlugin.qbs b/qbs/imports/QtcPlugin.qbs new file mode 100644 index 0000000000..624d8bab7e --- /dev/null +++ b/qbs/imports/QtcPlugin.qbs @@ -0,0 +1,62 @@ +import qbs.base 1.0 +import qbs.FileInfo +import QtcFunctions + +Product { + type: ["dynamiclibrary", "pluginSpec"] + property string provider: 'QtProject' + property var pluginspecreplacements + property var pluginRecommends: [] + + Depends { name: "Qt.core" } + property string minimumQtVersion: "4.8" + condition: QtcFunctions.versionIsAtLeast(Qt.core.version, minimumQtVersion) + + targetName: QtcFunctions.qtLibraryName(qbs, name) + destinationDirectory: project.ide_plugin_path + '/' + provider + + Depends { name: "ExtensionSystem" } + Depends { name: "pluginspec" } + Depends { name: "cpp" } + Depends { + condition: project.testsEnabled + name: "Qt.test" + } + + cpp.defines: project.generalDefines.concat([name.toUpperCase() + "_LIBRARY"]) + cpp.installNamePrefix: "@rpath/PlugIns/" + provider + "/" + cpp.rpaths: qbs.targetOS.contains("osx") ? ["@loader_path/../..", "@executable_path/.."] + : ["$ORIGIN", "$ORIGIN/..", "$ORIGIN/../.."] + cpp.linkerFlags: { + if (qbs.buildVariant == "release" && (qbs.toolchain.contains("gcc") || qbs.toolchain.contains("mingw"))) + return ["-Wl,-s"] + else if (qbs.buildVariant == "debug" && qbs.toolchain.contains("msvc")) + return ["/INCREMENTAL:NO"] // Speed up startup time when debugging with cdb + } + + property string pluginIncludeBase: ".." // #include <plugin/header.h> + cpp.includePaths: [pluginIncludeBase] + + Group { + name: "PluginSpec" + files: [ product.name + ".pluginspec.in" ] + fileTags: ["pluginSpecIn"] + } + + Group { + name: "MimeTypes" + files: [ "*.mimetypes.xml" ] + } + + Group { + fileTagsFilter: product.type + qbs.install: true + qbs.installDir: project.ide_plugin_path + "/" + provider + } + + Export { + Depends { name: "ExtensionSystem" } + Depends { name: "cpp" } + cpp.includePaths: [pluginIncludeBase] + } +} diff --git a/qbs/imports/QtcTool.qbs b/qbs/imports/QtcTool.qbs new file mode 100644 index 0000000000..5494d0dc5d --- /dev/null +++ b/qbs/imports/QtcTool.qbs @@ -0,0 +1,19 @@ +import qbs.base 1.0 + +Application { + type: "application" // no Mac app bundle + Depends { name: "cpp" } + cpp.defines: project.generalDefines + cpp.linkerFlags: { + if (qbs.buildVariant == "release" && (qbs.toolchain.contains("gcc") || qbs.toolchain.contains("mingw"))) + return ["-Wl,-s"] + } + + property string toolInstallDir: project.ide_libexec_path + + Group { + fileTagsFilter: product.type + qbs.install: true + qbs.installDir: toolInstallDir + } +} |