mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-27 10:14:32 +00:00
fix #524 "added tr option for control custom translations "
This commit is contained in:
parent
0dc61af754
commit
3cb7ee820a
@ -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,7 @@ 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\""},
|
||||
|
||||
{"-tr [list,params]", "Adds qm files into the translations folder."},
|
||||
{"-verbose [0-3]", "Shows debug log"},
|
||||
|
||||
}
|
||||
@ -364,7 +364,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>
|
||||
|
@ -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"});
|
||||
|
@ -81,13 +81,14 @@ cqtdeployer -option1 value1 -option2 list, of, values flag1 flag2 flag3
|
||||
| -recursiveDepth [params] | Sets the Depth of recursive search of libs and ignoreEnv (default 0) |
|
||||
| -targetDir [params] | Sets target directory(by default it is the path to the first deployable file)|
|
||||
| -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"|
|
||||
| -tr [list,parems] | Adds qm files into the translations folder. |
|
||||
| -verbose [0-3] | Shows debug log |
|
||||
|
||||
### Controll of packages options
|
||||
|
||||
| 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 |
|
||||
@ -105,6 +106,7 @@ cqtdeployer -option1 value1 -option2 list, of, values flag1 flag2 flag3
|
||||
| -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.|
|
||||
|
||||
|
||||
### Plugins Controll Options
|
||||
|
||||
| Option | Descriptiion |
|
||||
|
@ -75,6 +75,7 @@ cqtdeployer -option1 value1 -option2 list,of,values flag1 flag2 flag3
|
||||
| -recursiveDepth [params] | Устанавливает глубину поиска библиотек и глубину игнорирования окружения для ignoreEnv (по умолчанию 0) |
|
||||
| -targetDir [params] | Устанавливает целевой каталог (по умолчанию это путь к первому развертываемому файлу)|
|
||||
| -runScript [list,parems] | заставляет cqtdeployer заменить сценарий запуска по умолчанию на новый из аргументов параметра. Эта опция копирует все содержимое из входного файла и вставляет весь код в runScript.sh или .bat. Пример использования: cqtdeployer -runScript "myTargetMame;path/to/my/myCustomLaunchScript.sh,myTargetSecondMame;path/to/my/mySecondCustomLaunchScript.sh"|
|
||||
| -tr [list,parems] | Добавляет qm файлы в папку переводов. |
|
||||
| -verbose [0-3] | Показывает дебаг лога |
|
||||
|
||||
### Параметры управлениями пакетами:
|
||||
|
Loading…
x
Reference in New Issue
Block a user