diff --git a/Deploy/configparser.cpp b/Deploy/configparser.cpp index 17aa839e..92735ae6 100644 --- a/Deploy/configparser.cpp +++ b/Deploy/configparser.cpp @@ -319,8 +319,8 @@ bool ConfigParser::loadFromFile(const QString& confFile) { } auto obj = doc.object(); - - for (const auto &key: obj.keys()) { + const auto keys = obj.keys(); + for (const auto &key: keys) { readKey(key, obj, confFilePath); } @@ -387,6 +387,8 @@ bool ConfigParser::initDistroStruct() { auto extraData = QuasarAppUtils::Params::getStrArg("extraData"). split(DeployCore::getSeparator(0), splitbehavior); + auto trData = QuasarAppUtils::Params::getStrArg("tr"). + split(DeployCore::getSeparator(0), splitbehavior); // init distro stucts for all targets if (binOut.size() && !parsePackagesPrivate(mainDistro, binOut, &DistroModule::setBinOutDir)) { @@ -469,6 +471,11 @@ bool ConfigParser::initDistroStruct() { return false; } + if (trData.size() && !parsePackagesPrivate(mainDistro, trData, &DistroModule::addTr)) { + packagesErrorLog("tr"); + return false; + } + return true; } diff --git a/Deploy/deployconfig.cpp b/Deploy/deployconfig.cpp index 6a1beac2..fc1a9dc9 100644 --- a/Deploy/deployconfig.cpp +++ b/Deploy/deployconfig.cpp @@ -31,6 +31,18 @@ QString DeployConfig::getTargetDir(const QString &target) const { return targetDir; } +QString DeployConfig::getPackageTargetDir(const QString &package) const { + if (!_packages.contains(package)) { +#ifdef QT_DEBUG + abort(); +#endif + return ""; + } + + return targetDir + "/" + package; + +} + void DeployConfig::setTargetDir(const QString &target) { targetDir = target; diff --git a/Deploy/deployconfig.h b/Deploy/deployconfig.h index 5f583ef6..91389891 100644 --- a/Deploy/deployconfig.h +++ b/Deploy/deployconfig.h @@ -72,6 +72,13 @@ class DEPLOYSHARED_EXPORT DeployConfig { */ QString getTargetDir(const QString& target = "") const; + /** + * @brief getPackageTargetDir This method return the target dif of the package. + * @param package This is id of the package + * @return target diractory path + */ + QString getPackageTargetDir(const QString& package) const; + /** * @brief setTargetDir * @param target diff --git a/Deploy/deploycore.cpp b/Deploy/deploycore.cpp index 7e2759c9..dca02084 100644 --- a/Deploy/deploycore.cpp +++ b/Deploy/deploycore.cpp @@ -244,7 +244,6 @@ void DeployCore::help() { {"-runScript [list,parems]", "forces cqtdeployer swap default run script to new from the arguments of option." " This option copy all content from input file and insert all code into runScript.sh or .bat" " Example of use: cqtdeployer -runScript \"myTargetMame;path/to/my/myCustomLaunchScript.sh,myTargetSecondMame;path/to/my/mySecondCustomLaunchScript.sh\""}, - {"-verbose [0-3]", "Shows debug log"}, } @@ -270,6 +269,8 @@ void DeployCore::help() { {"-homePage [package;val,val]", "Sets the home page url for a package"}, {"-prefix [package;val,val]", "Sets the prefix for the package relatively a target directory "}, {"-extraData [package;val,val]", "Adds the extra files or directories like a target. The selected directory will be copy to the extraDataOut location with save own structure."}, + {"-tr [package;val,val]", "Adds qm files into the translations folder."}, + } }, @@ -364,7 +365,8 @@ QStringList DeployCore::helpKeys() { "deb", "allowEmptyPackages", "runScript", - "getDefaultTemplate" + "getDefaultTemplate", + "tr" }; } diff --git a/Deploy/distromodule.cpp b/Deploy/distromodule.cpp index 88f16d1d..5839fc05 100644 --- a/Deploy/distromodule.cpp +++ b/Deploy/distromodule.cpp @@ -156,6 +156,18 @@ void DistroModule::setKey(const QString &key) { _key = key; } +QSet DistroModule::tr() const { + return _tr; +} + +void DistroModule::setTr(const QSet &tr) { + _tr = tr; +} + +void DistroModule::addTr(const QString &tr) { + _tr += tr; +} + QSet DistroModule::extraData() const { return _extraData; } diff --git a/Deploy/distromodule.h b/Deploy/distromodule.h index 14ab9165..fdd8561d 100644 --- a/Deploy/distromodule.h +++ b/Deploy/distromodule.h @@ -73,6 +73,10 @@ class DEPLOYSHARED_EXPORT DistroModule: public DistroStruct void setExtraData(const QSet &extraFiles); void addExtraData(const QString &extraFile); + QSet tr() const; + void setTr(const QSet &tr); + void addTr(const QString &tr); + protected: void setKey(const QString &key); @@ -94,8 +98,14 @@ class DEPLOYSHARED_EXPORT DistroModule: public DistroStruct QSet _enabled; QSet _disabled; QSet _extraPlugins; + + // extra data QSet _extraData; + // extra translations + QSet _tr; + + }; #endif // DISTROMODULE_H diff --git a/Deploy/extracter.cpp b/Deploy/extracter.cpp index 5ffb4cd5..12ff7969 100644 --- a/Deploy/extracter.cpp +++ b/Deploy/extracter.cpp @@ -250,21 +250,28 @@ void Extracter::copyFiles() { } } -void Extracter::copyTr() { +bool Extracter::copyTr() { if (!QuasarAppUtils::Params::isEndable("noTranslations")) { auto cnf = DeployCore::_config; - for (auto i = cnf->packages().cbegin(); i != cnf->packages().cend(); ++i) { if (!copyTranslations(DeployCore::extractTranslation(_packageDependencyes[i.key()].neadedLibs()), i.key())) { QuasarAppUtils::Params::log("Failed to copy standard Qt translations", QuasarAppUtils::Warning); } - } + const auto trFiles = i->tr(); + for (const auto &tr: trFiles) { + if (!_fileManager->copyFile(tr, cnf->getPackageTargetDir(i.key()) + i->getTrOutDir())) { + return false; + } + } + } } + + return true; } bool Extracter::deploy() { @@ -287,7 +294,11 @@ bool Extracter::deploy() { copyFiles(); - copyTr(); + if (!copyTr()) { + QuasarAppUtils::Params::log("Fail to copy translations", QuasarAppUtils::Error); + + return false; + }; if (!extractWebEngine()) { QuasarAppUtils::Params::log("deploy webEngine failed", QuasarAppUtils::Error); diff --git a/Deploy/extracter.h b/Deploy/extracter.h index 7528d29a..5673d9f6 100644 --- a/Deploy/extracter.h +++ b/Deploy/extracter.h @@ -72,7 +72,7 @@ class DEPLOYSHARED_EXPORT Extracter { void extractPlugins(); void copyFiles(); - void copyTr(); + bool copyTr(); /** * @brief copyLibs This method copy input libraryes into libOut dir. diff --git a/UnitTests/res.qrc b/UnitTests/res.qrc index c2fba521..f3487651 100644 --- a/UnitTests/res.qrc +++ b/UnitTests/res.qrc @@ -18,5 +18,6 @@ testRes/TestQMLWidgets.sh testRes/testMultiPackageConfig.json testRes/customRunScript.sh + testRes/TestTr.qm diff --git a/UnitTests/testRes/TestTr.qm b/UnitTests/testRes/TestTr.qm new file mode 100755 index 00000000..50279046 --- /dev/null +++ b/UnitTests/testRes/TestTr.qm @@ -0,0 +1 @@ +TEST TR diff --git a/UnitTests/tst_deploytest.cpp b/UnitTests/tst_deploytest.cpp index 57daaf2b..7d5dc897 100644 --- a/UnitTests/tst_deploytest.cpp +++ b/UnitTests/tst_deploytest.cpp @@ -176,6 +176,7 @@ private slots: void testRunScripts(); void testGetDefaultTemplate(); void testDeployGeneralFiles(); + void testTr(); void customTest(); }; @@ -1167,6 +1168,26 @@ void deploytest::testDeployGeneralFiles() { }, &comapareTree); } +void deploytest::testTr() { + TestUtils utils; +#ifdef Q_OS_UNIX + QString bin = TestBinDir + "QtWidgetsProject"; + QString qmake = TestQtDir + "bin/qmake"; + +#else + QString bin = TestBinDir + "QtWidgetsProject.exe"; + QString qmake = TestQtDir + "bin/qmake.exe"; + +#endif + auto comapareTree = TestModule.qtLibs(); + + comapareTree += utils.createTree({"./" + DISTRO_DIR + "/translations/TestTr.qm"}); + + runTestParams({"-bin", bin, "clear" , + "-tr", ":/testResurces/testRes/TestTr.qm", + "-qmake", qmake}, &comapareTree); +} + void deploytest::customTest() { // runTestParams({"-confFile", "path", // "qifFromSystem"}); diff --git a/docs/en/Options.md b/docs/en/Options.md index 552bf91d..c63858a7 100644 --- a/docs/en/Options.md +++ b/docs/en/Options.md @@ -87,7 +87,7 @@ cqtdeployer -option1 value1 -option2 list, of, values ​​flag1 flag2 flag3 | Option | Descriptiion | |-----------------------------|-----------------------------------------------------------| -| -targetPackage [package;tar1,package;tar2]| Creates a new package and adds 'tar1 and tar2' to it | +| -targetPackage [package;tar1,package;tar2]| Creates a new package and adds 'tar1 and tar2' to it | | -qmlOut [package;path,path] | Sets path to qml out directory | | -libOut [package;path,path] | Sets path to libraries out directory | | -trOut [package;path,path] | Sets path to translations out directory | @@ -104,6 +104,8 @@ cqtdeployer -option1 value1 -option2 list, of, values ​​flag1 flag2 flag3 | -homePage [package;val,val] | Sets the homepage url for a package | | -prefix [package;val,val] | Sets the prefix for the package relatively a target directory | | -extraData [package;val,val]| Adds the extra files or directories like a target. The selected directory will be copy to the extraDataOut location with save own structure.| +| -tr [package;val,val] | Adds qm files into the translations folder. | + ### Plugins Controll Options diff --git a/docs/ru/Options.md b/docs/ru/Options.md index f115e9c2..95358739 100644 --- a/docs/ru/Options.md +++ b/docs/ru/Options.md @@ -98,6 +98,7 @@ cqtdeployer -option1 value1 -option2 list,of,values flag1 flag2 flag3 | -homePage [package;val,val] | Установит URL-адрес домашней страницы для пакета | | -prefix [package;val,val] | Устанавливает префикс для пакета относительно целевого каталога | | -extraData [package;val,val]| Добавляет дополнительные файлы или каталоги как цель. Выбранный каталог будет скопирован в расположение extraDataOut с сохранением собственной структуры.| +| -tr [package;val,val] | Добавляет qm файлы в папку переводов. | ### Параметры управления плагинами: