diff --git a/md/en/Options.md b/md/en/Options.md index 6407e142..76bd0007 100644 --- a/md/en/Options.md +++ b/md/en/Options.md @@ -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| | -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)| +| -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 - + | Option | Descriptiion | |-----------------------------|-----------------------------------------------------------| | -extraPlugin [package;val1;val2,SingeleVal]| Sets an additional path to third-party application plug-in | diff --git a/src/Deploy/src/configparser.cpp b/src/Deploy/src/configparser.cpp index 525bbd20..f66c42e5 100644 --- a/src/Deploy/src/configparser.cpp +++ b/src/Deploy/src/configparser.cpp @@ -816,6 +816,8 @@ bool ConfigParser::configureTargets() { const auto disableShortcuts = QuasarAppUtils::Params::getArg("disableShortCut"). split(DeployCore::getSeparator(0), splitbehavior); + const auto extraDepends = QuasarAppUtils::Params::getArg("extraDepends"). + split(DeployCore::getSeparator(0), splitbehavior); if (icons.size()) { parseTargetPrivate(_config, icons, &TargetInfo::setIcon); @@ -835,6 +837,10 @@ bool ConfigParser::configureTargets() { return false; } + if (extraDepends.size()) { + parseTargetPrivate(_config, extraDepends, &TargetInfo::addDepends); + } + return true; } @@ -1442,27 +1448,27 @@ bool ConfigParser::initExtraPath() { return true; } -void ConfigParser::initExtraNames() { - - const auto deployExtraNames = [this](const QStringList& listNamesMasks){ - for (const auto &i : listNamesMasks) { - if (i.size() > 1) { - _config.allowedPaths.addtExtraNamesMasks({i}); +void ConfigParser::addExtraNamesMasks(const QStringList& listNamesMasks) { + for (const auto &i : listNamesMasks) { + if (i.size() > 1) { + _config.allowedPaths.addtExtraNamesMasks({i}); - QuasarAppUtils::Params::log(i + " is added as a filename mask", - QuasarAppUtils::Debug); - } else { - QuasarAppUtils::Params::log(i + " not added in file mask because" - " the file mask must be large 2 characters", - QuasarAppUtils::Debug); - } + QuasarAppUtils::Params::log(i + " is added as a filename mask", + 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"). split(DeployCore::getSeparator(0)); - deployExtraNames(listNamesMasks); + addExtraNamesMasks(listNamesMasks); /* * Task https://github.com/QuasarApp/CQtDeployer/issues/422 @@ -1471,7 +1477,7 @@ void ConfigParser::initExtraNames() { */ if (_config.isNeededQt()) { auto libs = DeployCore::Qt3rdpartyLibs( _config.getPlatformOfAll()); - deployExtraNames(libs); + addExtraNamesMasks(libs); } } diff --git a/src/Deploy/src/configparser.h b/src/Deploy/src/configparser.h index e9656d48..2c6dd6d5 100644 --- a/src/Deploy/src/configparser.h +++ b/src/Deploy/src/configparser.h @@ -68,7 +68,6 @@ class DEPLOYSHARED_EXPORT ConfigParser bool setTargets(const QStringList &value); bool setTargetsRecursive(const QString &dir); bool setTargetsInDir(const QString &dir, bool recursive = false); - void initIgnoreList(); void initIgnoreEnvList(); @@ -120,6 +119,7 @@ class DEPLOYSHARED_EXPORT ConfigParser */ bool addTarget(const TargetData &target); void initCustomPlatform(); + void addExtraNamesMasks(const QStringList &listNamesMasks); }; #endif // CQT_H diff --git a/src/Deploy/src/dependenciesscanner.cpp b/src/Deploy/src/dependenciesscanner.cpp index 7a1fd24c..c63e211b 100644 --- a/src/Deploy/src/dependenciesscanner.cpp +++ b/src/Deploy/src/dependenciesscanner.cpp @@ -219,12 +219,15 @@ LibInfo DependenciesScanner::scan(const QString &path) { return info; } - QSet stack; - recursiveDep(info, info._allDep , stack); - + scan(info); return info; } +void DependenciesScanner::scan(LibInfo &lib) { + QSet stack; + recursiveDep(lib, lib._allDep , stack); +} + DependenciesScanner::~DependenciesScanner() { } diff --git a/src/Deploy/src/dependenciesscanner.h b/src/Deploy/src/dependenciesscanner.h index b6997b6d..76019b6e 100644 --- a/src/Deploy/src/dependenciesscanner.h +++ b/src/Deploy/src/dependenciesscanner.h @@ -48,8 +48,20 @@ class DEPLOYSHARED_EXPORT DependenciesScanner { 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); - 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(); diff --git a/src/Deploy/src/deploycore.cpp b/src/Deploy/src/deploycore.cpp index 72c19e99..425f0e4f 100644 --- a/src/Deploy/src/deploycore.cpp +++ b/src/Deploy/src/deploycore.cpp @@ -452,14 +452,20 @@ QuasarAppUtils::OptionsDataList DeployCore::avilableOptions() { "Sets path to icon for a targets" }}); help.insert(group, {QuasarAppUtils::OptionData{ - {"-disableRunScript"}, "{package;val,val}", + {"-disableRunScript"}, "{target;val,val}", "Disables a generation of run script for selected targets" }}); help.insert(group, {QuasarAppUtils::OptionData{ - {"-disableShortCut"}, "{package;val,val}", + {"-disableShortCut"}, "{target;val,val}", "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"; help.insert(group, {QuasarAppUtils::OptionData{ diff --git a/src/Deploy/src/extracter.cpp b/src/Deploy/src/extracter.cpp index 1573fb91..89afbb10 100644 --- a/src/Deploy/src/extracter.cpp +++ b/src/Deploy/src/extracter.cpp @@ -100,8 +100,8 @@ void Extracter::extractAllTargets() { for (auto i = cfg->packages().cbegin(); i != cfg->packages().cend(); ++i) { auto &dep = _packageDependencyes[i.key()]; - for (const auto &target : i.value().targets()) { - extract(target, &dep); + for (const auto &targetId : i.value().targets()) { + extract(targetId, &dep); } } } @@ -406,9 +406,16 @@ void Extracter::extractLib(const QString &file, QuasarAppUtils::Params::log("extract lib :" + file, QuasarAppUtils::Debug); - auto data = _scaner->scan(file); + QSet 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())) { continue; diff --git a/src/Deploy/src/libinfo.cpp b/src/Deploy/src/libinfo.cpp index 9a934958..acef117d 100644 --- a/src/Deploy/src/libinfo.cpp +++ b/src/Deploy/src/libinfo.cpp @@ -60,6 +60,10 @@ void LibInfo::addDependncies(const QString &value) { _dependncies.insert(value); } +void LibInfo::addDepends(const QString &value) { + addDependncies(value); +} + void LibInfo::addDependncies(const QSet &value) { _dependncies += value; } diff --git a/src/Deploy/src/libinfo.h b/src/Deploy/src/libinfo.h index da30ada0..87084d75 100644 --- a/src/Deploy/src/libinfo.h +++ b/src/Deploy/src/libinfo.h @@ -37,6 +37,7 @@ class DEPLOYSHARED_EXPORT LibInfo { QSet getDependncies() const; void setDependncies(const QSet &value); void addDependncies(const QString &value); + void addDepends(const QString &value); void addDependncies(const QSet &value); void removeDependncies(const QString &value); diff --git a/src/Deploy/src/targetinfo.cpp b/src/Deploy/src/targetinfo.cpp index d42435b6..261bada1 100644 --- a/src/Deploy/src/targetinfo.cpp +++ b/src/Deploy/src/targetinfo.cpp @@ -6,8 +6,6 @@ //# #include "targetinfo.h" -#include "deploycore.h" -#include "deployconfig.h" TargetInfo::TargetInfo() { @@ -101,5 +99,3 @@ void TargetInfo::setFEnableRunScript(bool newFEnableRunScript) { void TargetInfo::disableRunScript() { setFEnableRunScript(false); } - - diff --git a/tests/tstMain.cpp b/tests/tstMain.cpp index c7ae7663..1f478b23 100644 --- a/tests/tstMain.cpp +++ b/tests/tstMain.cpp @@ -9,6 +9,8 @@ #include "qttest.h" #ifdef Q_OS_LINUX +#include "extradependstest.h" + #include "allowemptypackagestest.h" #include "binprefixtest.h" #include "checkqttest.h" @@ -100,6 +102,7 @@ private slots: // main tests works on linux only #ifdef Q_OS_LINUX + TestCase(extraDependsTest, ExtraDependsTest) TestCase(allowemptypackagestest, AllowEmptyPackagesTest ) TestCase(binprefixtest, BinPrefixTest) TestCase(checkqttest, CheckQtTest) diff --git a/tests/units/linux/extradependstest.cpp b/tests/units/linux/extradependstest.cpp new file mode 100644 index 00000000..aac3f024 --- /dev/null +++ b/tests/units/linux/extradependstest.cpp @@ -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); + +} diff --git a/tests/units/linux/extradependstest.h b/tests/units/linux/extradependstest.h new file mode 100644 index 00000000..15bb166d --- /dev/null +++ b/tests/units/linux/extradependstest.h @@ -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 + +class ExtraDependsTest: public TestBase, protected TestUtils +{ +public: + ExtraDependsTest(); + void test() override; + +}; + +#endif // EXTRADEPENDSTEST_H diff --git a/tests/units/testbase.cpp b/tests/units/testbase.cpp index ede2fa01..bf18a5b2 100644 --- a/tests/units/testbase.cpp +++ b/tests/units/testbase.cpp @@ -187,7 +187,12 @@ void TestBase::costomScript() { } -void TestBase::runTestParams(QStringList list, QSet *tree, bool noWarnings, bool onlySize, exitCodes exitCode, const std::function &cb) { +void TestBase::runTestParams(QStringList list, + QSet *tree, + bool noWarnings, + bool onlySize, + exitCodes exitCode, + const std::function &cb) { QuasarAppUtils::Params::parseParams(list);