diff --git a/qbs/modules/ebr/ebr.qbs b/qbs/modules/ebr/ebr.qbs new file mode 100644 index 000000000..567009342 --- /dev/null +++ b/qbs/modules/ebr/ebr.qbs @@ -0,0 +1,61 @@ +import "rcc.js" as Rcc + +Module { + + additionalProductTypes: "ebr.rcc" + + property bool enableCompression: true + property int thresholdLevel: 70 + property string compressAlgorithm: "zstd" + property int compressLevel: -1 + + Rule { + inputs: ["ebr.external_qrc"] + outputFileTags: ["ebr.rcc"] + outputArtifacts: { + var artifact = { + filePath: input.completeBaseName + ".rcc", + fileTags: ["ebr.rcc"] + }; + return [artifact]; + } + prepare: { + var args = ["-binary", input.filePath, "-o", output.filePath]; + var enableCompression = input.moduleProperty("ebr", "enableCompression"); + if (enableCompression) { + var compressAlgorithm = input.moduleProperty("ebr", "compressAlgorithm"); + if (product.Qt.core.versionMajor >= 5 && product.Qt.core.versionMinor >= 13) { + // Since Qt 5.13 we have option to select compress algorithm + if (compressAlgorithm !== "zstd") + args.push("-compress-algo", compressAlgorithm); + } else { + if (compressAlgorithm !== "zlib") + compressAlgorithm = "zlib"; + } + + var thresholdLevel = input.moduleProperty("ebr", "thresholdLevel"); + if (thresholdLevel !== 70) + args.push("-threshold", thresholdLevel); + + var compressLevel = input.moduleProperty("ebr", "compressLevel"); + if (compressLevel !== -1) { + // rcc will silently ignore incorrect values + if (compressAlgorithm === "zstd") + compressLevel = Rcc.bound(0, compressLevel, 19); + else if (compressAlgorithm === "zlib") + compressLevel = Rcc.bound(1, compressLevel, 9); + } + + if (compressLevel !== -1) + args.push("-compress", compressLevel); + } else { + args.push("-no-compress"); + } + + var cmd = new Command(Rcc.fullPath(product), args); + cmd.description = "rcc (external) "+ input.fileName; + cmd.highlight = 'filegen'; + return cmd; + } + } +} diff --git a/qbs/modules/ebr/rcc.js b/qbs/modules/ebr/rcc.js new file mode 100644 index 000000000..906d1f263 --- /dev/null +++ b/qbs/modules/ebr/rcc.js @@ -0,0 +1,13 @@ +var Utilities = require("qbs.Utilities"); + +function fullPath(product) +{ + if (Utilities.versionCompare(product.Qt.core.version, "6.1") < 0) + return product.Qt.core.binPath + '/' + product.Qt.core.rccName; + return product.Qt.core.libExecPath + '/' + product.Qt.core.rccName; +} + +function bound(min, val, max) +{ + return Math.max(min, Math.min(max, val)); +} diff --git a/src/test/ValentinaTest/ValentinaTest.qbs b/src/test/ValentinaTest/ValentinaTest.qbs index 9febfe377..6f08262cd 100644 --- a/src/test/ValentinaTest/ValentinaTest.qbs +++ b/src/test/ValentinaTest/ValentinaTest.qbs @@ -7,6 +7,7 @@ VTestApp { Depends { name: "IFCLib" } Depends { name: "VDXFLib" } Depends { name: "VFormatLib" } + Depends { name: "ebr" } name: "ValentinaTest" buildconfig.appTarget: qbs.targetOS.contains("macos") ? "ValentinaTest" : "valentinaTest" @@ -63,4 +64,10 @@ VTestApp { "tst_vabstractpiece.h", "tst_vtooluniondetails.h", ] + + Group { + name: "Test data" + files: "share/test_data.qrc" + fileTags: "ebr.external_qrc" + } }