valentina/qbs/imports/VToolApp.qbs

198 lines
7.7 KiB
QML
Raw Normal View History

2023-01-11 12:03:32 +01:00
import qbs.FileInfo
2023-01-25 17:31:18 +01:00
import qbs.File
import qbs.Utilities
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-27 21:08:47 +01:00
Depends { name: "windeployqt"; condition: qbs.targetOS.contains("windows") }
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-09-12 16:50:15 +02:00
version: buildconfig.projectVersion
2023-01-10 09:39:50 +01:00
install: true
2023-01-25 17:13:45 +01:00
installDir: buildconfig.installBinaryPath
installDebugInformation: qbs.buildVariant !== "release"
consoleApplication: false
2023-01-28 07:07:12 +01:00
2023-01-27 18:07:24 +01:00
property bool primaryApp: false
2023-01-28 07:07:12 +01:00
Properties {
2023-01-28 15:57:32 +01:00
condition: qbs.targetOS.contains("macos")
2023-01-28 07:07:12 +01:00
// Breakpoints do not work if debug the app inside of bundle. In debug mode we turn off creating a bundle.
// Probably it will breake some dependencies. Version for Mac designed to work inside an app bundle.
bundle.isBundle: qbs.buildVariant === "release"
2023-01-28 15:57:32 +01:00
bundle.identifierPrefix: 'ua.com.smart-pattern'
bundle.infoPlist:({
"NSHumanReadableCopyright": buildconfig.valentina_copyright_string
})
2023-01-28 07:07:12 +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 14:08:32 +01:00
Group {
name: "Translations"
2023-05-12 19:00:09 +02:00
condition: product.primaryApp || (qbs.targetOS.contains("macos") && (!bundle.isBundle || (bundle.isBundle && buildconfig.enableMultiBundle)))
prefix: project.sourceDirectory + "/share/translations/"
2023-01-11 14:08:32 +01:00
files: {
var files = [];
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");
}
return files;
}
}
2023-01-18 14:04:26 +01:00
2023-01-25 17:31:18 +01:00
Group {
2023-01-28 15:57:32 +01:00
condition: product.primaryApp || (qbs.targetOS.contains("macos") && (!bundle.isBundle || (bundle.isBundle && buildconfig.enableMultiBundle)))
2023-01-25 17:31:18 +01:00
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-27 21:08:47 +01:00
Properties {
condition: qbs.targetOS.contains("windows") && Utilities.versionCompare(Qt.core.version, "6.5") < 0
2023-01-27 21:08:47 +01:00
windeployqt.noVirtualkeyboard: true
}
2023-01-18 14:04:26 +01:00
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 {
2023-01-28 07:07:12 +01:00
condition: qbs.targetOS.contains("windows") && i18nconfig.limitDeploymentOfQtTranslations
2023-01-18 14:04:26 +01:00
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
}