mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-26 17:54:32 +00:00
Merge pull request #529 from QuasarApp/task_524
Added support of the control custom translation files.
This commit is contained in:
commit
14c71a172a
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -72,6 +72,13 @@ public:
|
||||
*/
|
||||
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
|
||||
|
@ -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"
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -156,6 +156,18 @@ void DistroModule::setKey(const QString &key) {
|
||||
_key = key;
|
||||
}
|
||||
|
||||
QSet<QString> DistroModule::tr() const {
|
||||
return _tr;
|
||||
}
|
||||
|
||||
void DistroModule::setTr(const QSet<QString> &tr) {
|
||||
_tr = tr;
|
||||
}
|
||||
|
||||
void DistroModule::addTr(const QString &tr) {
|
||||
_tr += tr;
|
||||
}
|
||||
|
||||
QSet<QString> DistroModule::extraData() const {
|
||||
return _extraData;
|
||||
}
|
||||
|
@ -73,6 +73,10 @@ public:
|
||||
void setExtraData(const QSet<QString> &extraFiles);
|
||||
void addExtraData(const QString &extraFile);
|
||||
|
||||
QSet<QString> tr() const;
|
||||
void setTr(const QSet<QString> &tr);
|
||||
void addTr(const QString &tr);
|
||||
|
||||
protected:
|
||||
void setKey(const QString &key);
|
||||
|
||||
@ -94,8 +98,14 @@ private:
|
||||
QSet<QString> _enabled;
|
||||
QSet<QString> _disabled;
|
||||
QSet<QString> _extraPlugins;
|
||||
|
||||
// extra data
|
||||
QSet<QString> _extraData;
|
||||
|
||||
// extra translations
|
||||
QSet<QString> _tr;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // DISTROMODULE_H
|
||||
|
@ -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);
|
||||
|
@ -72,7 +72,7 @@ private:
|
||||
void extractPlugins();
|
||||
|
||||
void copyFiles();
|
||||
void copyTr();
|
||||
bool copyTr();
|
||||
|
||||
/**
|
||||
* @brief copyLibs This method copy input libraryes into libOut dir.
|
||||
|
@ -18,5 +18,6 @@
|
||||
<file>testRes/TestQMLWidgets.sh</file>
|
||||
<file>testRes/testMultiPackageConfig.json</file>
|
||||
<file>testRes/customRunScript.sh</file>
|
||||
<file>testRes/TestTr.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
1
UnitTests/testRes/TestTr.qm
Executable file
1
UnitTests/testRes/TestTr.qm
Executable file
@ -0,0 +1 @@
|
||||
TEST TR
|
@ -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"});
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 файлы в папку переводов. |
|
||||
|
||||
### Параметры управления плагинами:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user