New module to generate external binary resources.

This commit is contained in:
Roman Telezhynskyi 2023-01-11 14:01:16 +02:00
parent 89aab8cb92
commit 47db665c21
3 changed files with 81 additions and 0 deletions

61
qbs/modules/ebr/ebr.qbs Normal file
View File

@ -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;
}
}
}

13
qbs/modules/ebr/rcc.js Normal file
View File

@ -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));
}

View File

@ -7,6 +7,7 @@ VTestApp {
Depends { name: "IFCLib" } Depends { name: "IFCLib" }
Depends { name: "VDXFLib" } Depends { name: "VDXFLib" }
Depends { name: "VFormatLib" } Depends { name: "VFormatLib" }
Depends { name: "ebr" }
name: "ValentinaTest" name: "ValentinaTest"
buildconfig.appTarget: qbs.targetOS.contains("macos") ? "ValentinaTest" : "valentinaTest" buildconfig.appTarget: qbs.targetOS.contains("macos") ? "ValentinaTest" : "valentinaTest"
@ -63,4 +64,10 @@ VTestApp {
"tst_vabstractpiece.h", "tst_vabstractpiece.h",
"tst_vtooluniondetails.h", "tst_vtooluniondetails.h",
] ]
Group {
name: "Test data"
files: "share/test_data.qrc"
fileTags: "ebr.external_qrc"
}
} }