Merge pull request #760 from QuasarApp/extraDepends_option

Add the extraDepends option
This commit is contained in:
Andrei Yankovich 2023-06-18 18:54:39 +03:00 committed by GitHub
commit ce62467151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 149 additions and 33 deletions

View File

@ -134,9 +134,10 @@ cqtdeployer -option1 value1 -option2 list, of, values flag1 flag2 flag3
| -disableRunScript [target,target2,target3] | Disables the generation of run script for selected targets| | -disableRunScript [target,target2,target3] | Disables the generation of run script for selected targets|
| -disableShortCut [target,target2,target3] | Disables the generation of shortcut for selected targets | | -disableShortCut [target,target2,target3] | Disables the generation of shortcut for selected targets |
| -runScript [target;val,val] | 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" For get more information about customScript see the documentation [page](CustomScripts.md)| | -runScript [target;val,val] | 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" For get more information about customScript see the documentation [page](CustomScripts.md)|
| -extraDepends [target;val,val] | Adds extra dependencies for target, if package is skiped then for all targets. Example -extraDepends libssl.so or -extraDepends myExecutable;libssl.so |
### Plugins Controll Options ### Plugins Controll Options
| Option | Descriptiion | | Option | Descriptiion |
|-----------------------------|-----------------------------------------------------------| |-----------------------------|-----------------------------------------------------------|
| -extraPlugin [package;val1;val2,SingeleVal]| Sets an additional path to third-party application plug-in | | -extraPlugin [package;val1;val2,SingeleVal]| Sets an additional path to third-party application plug-in |

View File

@ -816,6 +816,8 @@ bool ConfigParser::configureTargets() {
const auto disableShortcuts = QuasarAppUtils::Params::getArg("disableShortCut"). const auto disableShortcuts = QuasarAppUtils::Params::getArg("disableShortCut").
split(DeployCore::getSeparator(0), splitbehavior); split(DeployCore::getSeparator(0), splitbehavior);
const auto extraDepends = QuasarAppUtils::Params::getArg("extraDepends").
split(DeployCore::getSeparator(0), splitbehavior);
if (icons.size()) { if (icons.size()) {
parseTargetPrivate(_config, icons, &TargetInfo::setIcon); parseTargetPrivate(_config, icons, &TargetInfo::setIcon);
@ -835,6 +837,10 @@ bool ConfigParser::configureTargets() {
return false; return false;
} }
if (extraDepends.size()) {
parseTargetPrivate(_config, extraDepends, &TargetInfo::addDepends);
}
return true; return true;
} }
@ -1442,27 +1448,27 @@ bool ConfigParser::initExtraPath() {
return true; return true;
} }
void ConfigParser::initExtraNames() { void ConfigParser::addExtraNamesMasks(const QStringList& listNamesMasks) {
for (const auto &i : listNamesMasks) {
if (i.size() > 1) {
_config.allowedPaths.addtExtraNamesMasks({i});
const auto deployExtraNames = [this](const QStringList& listNamesMasks){ QuasarAppUtils::Params::log(i + " is added as a filename mask",
for (const auto &i : listNamesMasks) { QuasarAppUtils::Debug);
if (i.size() > 1) { } else {
_config.allowedPaths.addtExtraNamesMasks({i}); QuasarAppUtils::Params::log(i + " not added in file mask because"
" the file mask must be large 2 characters",
QuasarAppUtils::Params::log(i + " is added as a filename mask", QuasarAppUtils::Debug);
QuasarAppUtils::Debug);
} else {
QuasarAppUtils::Params::log(i + " not added in file mask because"
" the file mask must be large 2 characters",
QuasarAppUtils::Debug);
}
} }
}; }
}
void ConfigParser::initExtraNames() {
auto listNamesMasks = QuasarAppUtils::Params::getArg("extraLibs"). auto listNamesMasks = QuasarAppUtils::Params::getArg("extraLibs").
split(DeployCore::getSeparator(0)); split(DeployCore::getSeparator(0));
deployExtraNames(listNamesMasks); addExtraNamesMasks(listNamesMasks);
/* /*
* Task https://github.com/QuasarApp/CQtDeployer/issues/422 * Task https://github.com/QuasarApp/CQtDeployer/issues/422
@ -1471,7 +1477,7 @@ void ConfigParser::initExtraNames() {
*/ */
if (_config.isNeededQt()) { if (_config.isNeededQt()) {
auto libs = DeployCore::Qt3rdpartyLibs( _config.getPlatformOfAll()); auto libs = DeployCore::Qt3rdpartyLibs( _config.getPlatformOfAll());
deployExtraNames(libs); addExtraNamesMasks(libs);
} }
} }

View File

@ -68,7 +68,6 @@ private:
bool setTargets(const QStringList &value); bool setTargets(const QStringList &value);
bool setTargetsRecursive(const QString &dir); bool setTargetsRecursive(const QString &dir);
bool setTargetsInDir(const QString &dir, bool recursive = false); bool setTargetsInDir(const QString &dir, bool recursive = false);
void initIgnoreList(); void initIgnoreList();
void initIgnoreEnvList(); void initIgnoreEnvList();
@ -120,6 +119,7 @@ private:
*/ */
bool addTarget(const TargetData &target); bool addTarget(const TargetData &target);
void initCustomPlatform(); void initCustomPlatform();
void addExtraNamesMasks(const QStringList &listNamesMasks);
}; };
#endif // CQT_H #endif // CQT_H

View File

@ -219,12 +219,15 @@ LibInfo DependenciesScanner::scan(const QString &path) {
return info; return info;
} }
QSet<QString> stack; scan(info);
recursiveDep(info, info._allDep , stack);
return info; return info;
} }
void DependenciesScanner::scan(LibInfo &lib) {
QSet<QString> stack;
recursiveDep(lib, lib._allDep , stack);
}
DependenciesScanner::~DependenciesScanner() { DependenciesScanner::~DependenciesScanner() {
} }

View File

@ -48,8 +48,20 @@ public:
void setEnvironment(const QStringList &env); void setEnvironment(const QStringList &env);
/**
* @brief scan This method create a "lib info" object from path and extract all depends on from the current environment.
* @param path This is full path to the library
* @return full lib of executable info
*/
LibInfo scan(const QString& path); LibInfo scan(const QString& path);
bool fillLibInfo(LibInfo& info ,const QString& file) const;
/**
* @brief scan This method do same as a scan(const QString& path) but not use already created libInfo data.
* @param lib this is already prepared lib info.
*/
void scan(LibInfo& lib);
bool fillLibInfo(LibInfo& info, const QString& file) const;
~DependenciesScanner(); ~DependenciesScanner();

View File

@ -452,14 +452,20 @@ QuasarAppUtils::OptionsDataList DeployCore::avilableOptions() {
"Sets path to icon for a targets" "Sets path to icon for a targets"
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-disableRunScript"}, "{package;val,val}", {"-disableRunScript"}, "{target;val,val}",
"Disables a generation of run script for selected targets" "Disables a generation of run script for selected targets"
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{
{"-disableShortCut"}, "{package;val,val}", {"-disableShortCut"}, "{target;val,val}",
"Disables a generation of shortcut for selected targets" "Disables a generation of shortcut for selected targets"
}}); }});
help.insert(group, {QuasarAppUtils::OptionData{
{"-extraDepends"}, "{target;val,val}",
"Adds extra dependencies for target, if target is skipped then for rest of all targets",
"Example -extraDepends libssl.so or -targetPackage packageName;myExecutable -extraDepends packageName;libssl.so"
}});
group = "Part 5 Plugins Control Options"; group = "Part 5 Plugins Control Options";
help.insert(group, {QuasarAppUtils::OptionData{ help.insert(group, {QuasarAppUtils::OptionData{

View File

@ -100,8 +100,8 @@ void Extracter::extractAllTargets() {
for (auto i = cfg->packages().cbegin(); i != cfg->packages().cend(); ++i) { for (auto i = cfg->packages().cbegin(); i != cfg->packages().cend(); ++i) {
auto &dep = _packageDependencyes[i.key()]; auto &dep = _packageDependencyes[i.key()];
for (const auto &target : i.value().targets()) { for (const auto &targetId : i.value().targets()) {
extract(target, &dep); extract(targetId, &dep);
} }
} }
} }
@ -406,9 +406,16 @@ void Extracter::extractLib(const QString &file,
QuasarAppUtils::Params::log("extract lib :" + file, QuasarAppUtils::Params::log("extract lib :" + file,
QuasarAppUtils::Debug); QuasarAppUtils::Debug);
auto data = _scaner->scan(file); QSet<LibInfo> allDependencies;
auto targetObject = DeployCore::_config->targets().value(file);
if (targetObject.isValid()) {
_scaner->scan(targetObject);
allDependencies = targetObject.getAllDep();
} else {
allDependencies = _scaner->scan(file).getAllDep();
}
for (const auto &line : data.getAllDep()) { for (const auto &line : qAsConst(allDependencies)) {
if (mask.size() && !line.getName().contains(mask, DeployCore::getCaseSensitivity())) { if (mask.size() && !line.getName().contains(mask, DeployCore::getCaseSensitivity())) {
continue; continue;

View File

@ -60,6 +60,10 @@ void LibInfo::addDependncies(const QString &value) {
_dependncies.insert(value); _dependncies.insert(value);
} }
void LibInfo::addDepends(const QString &value) {
addDependncies(value);
}
void LibInfo::addDependncies(const QSet<QString> &value) { void LibInfo::addDependncies(const QSet<QString> &value) {
_dependncies += value; _dependncies += value;
} }

View File

@ -37,6 +37,7 @@ public:
QSet<QString> getDependncies() const; QSet<QString> getDependncies() const;
void setDependncies(const QSet<QString> &value); void setDependncies(const QSet<QString> &value);
void addDependncies(const QString &value); void addDependncies(const QString &value);
void addDepends(const QString &value);
void addDependncies(const QSet<QString> &value); void addDependncies(const QSet<QString> &value);
void removeDependncies(const QString &value); void removeDependncies(const QString &value);

View File

@ -6,8 +6,6 @@
//# //#
#include "targetinfo.h" #include "targetinfo.h"
#include "deploycore.h"
#include "deployconfig.h"
TargetInfo::TargetInfo() { TargetInfo::TargetInfo() {
@ -101,5 +99,3 @@ void TargetInfo::setFEnableRunScript(bool newFEnableRunScript) {
void TargetInfo::disableRunScript() { void TargetInfo::disableRunScript() {
setFEnableRunScript(false); setFEnableRunScript(false);
} }

View File

@ -9,6 +9,8 @@
#include "qttest.h" #include "qttest.h"
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
#include "extradependstest.h"
#include "allowemptypackagestest.h" #include "allowemptypackagestest.h"
#include "binprefixtest.h" #include "binprefixtest.h"
#include "checkqttest.h" #include "checkqttest.h"
@ -100,6 +102,7 @@ private slots:
// main tests works on linux only // main tests works on linux only
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
TestCase(extraDependsTest, ExtraDependsTest)
TestCase(allowemptypackagestest, AllowEmptyPackagesTest ) TestCase(allowemptypackagestest, AllowEmptyPackagesTest )
TestCase(binprefixtest, BinPrefixTest) TestCase(binprefixtest, BinPrefixTest)
TestCase(checkqttest, CheckQtTest) TestCase(checkqttest, CheckQtTest)

View File

@ -0,0 +1,48 @@
//#
//# Copyright (C) 2020-2023 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#include "extradependstest.h"
#include "modules.h"
ExtraDependsTest::ExtraDependsTest() {
}
void ExtraDependsTest::test() {
TestUtils utils;
QString bin = TestBinDir + "TestOnlyC";
auto comapareTree = TestModule.onlyC();
// should be without icu libs
runTestParams({"-bin", bin, "clear",
"-libDir", QT_BASE_DIR,
"-recursiveDepth", "4"}, &comapareTree);
comapareTree += utils.createTree(
{
"./" + DISTRO_DIR + "/lib/libicutu.so.56.1",
"./" + DISTRO_DIR + "/lib/libicuuc.so",
"./" + DISTRO_DIR + "/lib/libicui18n.so",
"./" + DISTRO_DIR + "/lib/libicudata.so",
});
// this cases should contains all icu libs.
runTestParams({"-bin", bin, "clear",
"-libDir", QT_BASE_DIR,
"-recursiveDepth", "4",
"-extraDepends", "libicutu.so.56.1"}, &comapareTree);
runTestParams({"-bin", bin, "clear" ,
"-libDir", QT_BASE_DIR,
"-recursiveDepth", "4",
"-extraDepends", "TestOnlyC;libicutu.so.56.1"}, &comapareTree);
}

View File

@ -0,0 +1,24 @@
//#
//# Copyright (C) 2023-2023 QuasarApp.
//# Distributed under the GPLv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
#ifndef EXTRADEPENDSTEST_H
#define EXTRADEPENDSTEST_H
#include "testbase.h"
#include "testutils.h"
#include <QtTest>
class ExtraDependsTest: public TestBase, protected TestUtils
{
public:
ExtraDependsTest();
void test() override;
};
#endif // EXTRADEPENDSTEST_H

View File

@ -187,7 +187,12 @@ void TestBase::costomScript() {
} }
void TestBase::runTestParams(QStringList list, QSet<QString> *tree, bool noWarnings, bool onlySize, exitCodes exitCode, const std::function<void (const DeployConfig *)> &cb) { void TestBase::runTestParams(QStringList list,
QSet<QString> *tree,
bool noWarnings,
bool onlySize,
exitCodes exitCode,
const std::function<void (const DeployConfig *)> &cb) {
QuasarAppUtils::Params::parseParams(list); QuasarAppUtils::Params::parseParams(list);