2023-01-11 12:03:32 +01:00
|
|
|
import qbs.FileInfo
|
2023-01-25 17:31:18 +01:00
|
|
|
import qbs.File
|
2023-01-11 12:03:32 +01:00
|
|
|
|
2023-01-10 09:39:50 +01:00
|
|
|
VApp {
|
2023-01-11 12:03:32 +01:00
|
|
|
Depends { name: "freedesktop2" }
|
2023-01-11 13:02:35 +01:00
|
|
|
Depends { name: "tenv" }
|
2023-01-18 14:04:26 +01:00
|
|
|
Depends { name: "windeployqt"; }
|
2023-01-18 14:00:43 +01:00
|
|
|
Depends { name: "i18nconfig"; }
|
2023-01-25 17:31:18 +01:00
|
|
|
Depends { name: "i18n"; }
|
2023-01-25 17:13:07 +01:00
|
|
|
Depends { name: "ib"; condition: qbs.targetOS.contains("macos") }
|
2023-01-11 12:03:32 +01:00
|
|
|
|
2023-01-10 09:39:50 +01:00
|
|
|
version: "0.7.52"
|
|
|
|
install: true
|
2023-01-25 17:13:45 +01:00
|
|
|
installDir: buildconfig.installBinaryPath
|
|
|
|
installDebugInformation: qbs.buildVariant !== "release"
|
2023-01-18 14:02:51 +01:00
|
|
|
consoleApplication: false
|
2023-01-25 17:31:18 +01:00
|
|
|
bundle.isBundle: qbs.buildVariant === "release"
|
2023-01-25 17:09:45 +01:00
|
|
|
bundle.identifierPrefix: 'ua.com.smart-pattern'
|
2023-01-11 12:03:32 +01:00
|
|
|
|
2023-01-27 18:07:24 +01:00
|
|
|
property bool primaryApp: false
|
|
|
|
|
2023-01-25 17:09:45 +01:00
|
|
|
bundle.infoPlist:({
|
|
|
|
"NSHumanReadableCopyright": buildconfig.valentina_copyright_string
|
|
|
|
})
|
2023-01-11 13:02:35 +01:00
|
|
|
|
2023-01-10 18:35:39 +01:00
|
|
|
Properties {
|
|
|
|
condition: buildconfig.enableAppImage && qbs.targetOS.contains("unix") && !qbs.targetOS.contains("macos")
|
|
|
|
cpp.dynamicLibraries: ["icudata", "icui18n", "icuuc"]
|
|
|
|
}
|
|
|
|
|
2023-01-11 12:03:32 +01:00
|
|
|
Group {
|
|
|
|
name: "freedesktop"
|
2023-01-17 11:00:35 +01:00
|
|
|
prefix: project.sourceDirectory + "/dist/"
|
2023-01-11 12:03:32 +01:00
|
|
|
files: [
|
2023-01-13 16:12:13 +01:00
|
|
|
"ua.com.smart-pattern." + product.targetName + ".desktop"
|
2023-01-11 12:03:32 +01:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
freedesktop2.desktopKeys: ({
|
|
|
|
'Exec': FileInfo.joinPaths(qbs.installPrefix,
|
|
|
|
product.installDir,
|
|
|
|
product.targetName) + ' %F',
|
|
|
|
'X-Application-Version': product.version,
|
|
|
|
})
|
2023-01-11 14:08:32 +01:00
|
|
|
|
|
|
|
Group {
|
|
|
|
name: "Translations"
|
2023-01-17 11:00:35 +01:00
|
|
|
prefix: project.sourceDirectory + "/share/translations/"
|
2023-01-11 14:08:32 +01:00
|
|
|
files: {
|
|
|
|
var files = [];
|
|
|
|
|
2023-01-18 14:00:43 +01:00
|
|
|
var locales = i18nconfig.translationLocales;
|
2023-01-11 14:08:32 +01:00
|
|
|
|
|
|
|
for (var i = 0; i < locales.length; i++) {
|
|
|
|
files.push("valentina_" + locales[i] + ".ts");
|
|
|
|
}
|
|
|
|
|
2023-01-18 14:00:43 +01:00
|
|
|
var pmSystems = i18nconfig.pmSystems;
|
2023-01-11 14:08:32 +01:00
|
|
|
|
|
|
|
for (var i = 0; i < pmSystems.length; i++) {
|
|
|
|
for (var j = 0; j < locales.length; j++) {
|
|
|
|
files.push("measurements_" + pmSystems[i] + "_" + locales[j] + ".ts");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
}
|
2023-01-18 14:04:26 +01:00
|
|
|
|
2023-01-25 17:31:18 +01:00
|
|
|
Group {
|
|
|
|
condition: !qbs.targetOS.contains("macos") || (qbs.targetOS.contains("macos") && !bundle.isBundle)
|
|
|
|
fileTagsFilter: "qm"
|
|
|
|
qbs.install: true
|
|
|
|
qbs.installDir: buildconfig.installDataPath + "/translations"
|
|
|
|
}
|
|
|
|
|
|
|
|
Rule {
|
|
|
|
multiplex: true
|
2023-01-27 18:07:24 +01:00
|
|
|
condition: qbs.targetOS.contains("macos") && bundle.isBundle && (buildconfig.enableMultiBundle || primaryApp)
|
2023-01-25 17:31:18 +01:00
|
|
|
inputs: ["qm"]
|
|
|
|
outputFileTags: ["bundle.qm", "bundle.content"]
|
|
|
|
outputArtifacts: {
|
|
|
|
var locales = product.i18nconfig.translationLocales;
|
|
|
|
var artifactNames = [];
|
|
|
|
|
|
|
|
for (var i = 0; i < locales.length; i++) {
|
|
|
|
const lprojDir = FileInfo.joinPaths(product.buildDirectory, product.bundle.bundleName,
|
|
|
|
"Contents", "Resources", "translations", locales[i] + product.bundle.localizedResourcesFolderSuffix);
|
|
|
|
|
|
|
|
var qmRex = new RegExp('.*_' + locales[i] + '\.qm$', 'g');
|
|
|
|
artifactNames = artifactNames.concat((inputs["qm"] || []).filter(function(file){
|
|
|
|
return qmRex.exec(file.fileName);
|
|
|
|
}).map(function(file){
|
|
|
|
return FileInfo.joinPaths(lprojDir, file.fileName);
|
|
|
|
}));
|
|
|
|
|
|
|
|
artifactNames.push(FileInfo.joinPaths(lprojDir, "Localizable.strings"));
|
|
|
|
|
|
|
|
const qtTranslationsMask = [
|
|
|
|
"qt_",
|
|
|
|
"qtbase_",
|
|
|
|
"qtxmlpatterns_"
|
|
|
|
];
|
|
|
|
|
|
|
|
qtTranslationsMask.forEach(function(mask) {
|
|
|
|
var qmFile = FileInfo.joinPaths(product.i18n.qtTranslationsPath, mask + locales[i] + ".qm");
|
|
|
|
if (File.exists(qmFile)) {
|
|
|
|
artifactNames.push(FileInfo.joinPaths(lprojDir, mask + locales[i] + ".qm"));
|
|
|
|
} else {
|
|
|
|
const lang = locales[i].split('_')[0];
|
|
|
|
qmFile = FileInfo.joinPaths(product.i18n.qtTranslationsPath, mask + lang + ".qm");
|
|
|
|
if (File.exists(qmFile))
|
|
|
|
artifactNames.push(FileInfo.joinPaths(lprojDir, mask + lang + ".qm"));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
var artifacts = artifactNames.map(function(art){
|
|
|
|
var a = {
|
|
|
|
filePath: art,
|
|
|
|
fileTags: ["bundle.qm", "bundle.content"]
|
|
|
|
}
|
|
|
|
return a;
|
|
|
|
});
|
|
|
|
return artifacts;
|
|
|
|
}
|
|
|
|
prepare: {
|
|
|
|
var cmd = new JavaScriptCommand();
|
|
|
|
cmd.description = "Preparing Valentina translations";
|
|
|
|
cmd.highlight = "filegen";
|
|
|
|
|
|
|
|
var data = [];
|
|
|
|
const locales = product.i18nconfig.translationLocales;
|
|
|
|
|
|
|
|
for (var i = 0; i < locales.length; i++) {
|
|
|
|
const qmRex = new RegExp('.*_' + locales[i] + '.qm$', 'g');
|
|
|
|
const src = (inputs["qm"] || []).filter(function(file){
|
|
|
|
return qmRex.exec(file.fileName);
|
|
|
|
});
|
|
|
|
|
|
|
|
const lprojDir = FileInfo.joinPaths(product.buildDirectory, product.bundle.bundleName,
|
|
|
|
"Contents", "Resources", "translations", locales[i] + product.bundle.localizedResourcesFolderSuffix);
|
|
|
|
|
|
|
|
for (var j = 0; j < src.length; j++) {
|
|
|
|
data.push({
|
|
|
|
"source" : src[j].filePath,
|
|
|
|
"destination": FileInfo.joinPaths(lprojDir, src[j].fileName)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
data.push({
|
|
|
|
"source" : FileInfo.joinPaths(project.sourceDirectory, "share", "translations", "Localizable.strings"),
|
|
|
|
"destination": FileInfo.joinPaths(lprojDir, "Localizable.strings")
|
|
|
|
});
|
|
|
|
|
|
|
|
const qtTranslationsMask = [
|
|
|
|
"qt_",
|
|
|
|
"qtbase_",
|
|
|
|
"qtxmlpatterns_"
|
|
|
|
];
|
|
|
|
|
|
|
|
qtTranslationsMask.forEach(function(mask) {
|
|
|
|
var qmFile = FileInfo.joinPaths(product.i18n.qtTranslationsPath, mask + locales[i] + ".qm");
|
|
|
|
if (File.exists(qmFile)) {
|
|
|
|
data.push({
|
|
|
|
"source" : qmFile,
|
|
|
|
"destination": FileInfo.joinPaths(lprojDir, mask + locales[i] + ".qm")
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
const lang = locales[i].split('_')[0];
|
|
|
|
qmFile = FileInfo.joinPaths(product.i18n.qtTranslationsPath, mask + lang + ".qm");
|
|
|
|
if (File.exists(qmFile)) {
|
|
|
|
data.push({
|
|
|
|
"source" : qmFile,
|
|
|
|
"destination": FileInfo.joinPaths(lprojDir, mask + lang + ".qm")
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
cmd.data = data;
|
|
|
|
|
|
|
|
cmd.sourceCode = function() {
|
|
|
|
data.forEach(function(copyData) {
|
|
|
|
File.copy(copyData.source, copyData.destination);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
return [cmd];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-18 14:04:26 +01:00
|
|
|
windeployqt.noVirtualkeyboard: true
|
|
|
|
|
2023-01-25 17:13:07 +01:00
|
|
|
Properties {
|
|
|
|
condition: qbs.targetOS.contains("macos")
|
|
|
|
ib.appIconName: targetName
|
|
|
|
}
|
|
|
|
|
2023-01-18 14:04:26 +01:00
|
|
|
Properties {
|
|
|
|
condition: i18nconfig.limitDeploymentOfQtTranslations
|
|
|
|
windeployqt.languages: i18nconfig.qtTranslationLocales.join(',')
|
|
|
|
}
|
2023-01-25 16:59:49 +01:00
|
|
|
|
|
|
|
Group {
|
|
|
|
condition: qbs.targetOS.contains("macos") && bundle.isBundle
|
|
|
|
fileTagsFilter: "bundle.content"
|
|
|
|
qbs.install: true
|
|
|
|
qbs.installDir: buildconfig.installAppPath
|
|
|
|
qbs.installSourceBase: destinationDirectory
|
|
|
|
}
|
2023-01-10 09:39:50 +01:00
|
|
|
}
|