Skip to content

Commit

Permalink
Merge pull request #760 from QuasarApp/extraDepends_option
Browse files Browse the repository at this point in the history
Add the extraDepends option
  • Loading branch information
EndrII authored Jun 18, 2023
2 parents de25aa3 + ad8f2a4 commit ce62467
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 33 deletions.
3 changes: 2 additions & 1 deletion md/en/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
38 changes: 22 additions & 16 deletions src/Deploy/src/configparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -835,6 +837,10 @@ bool ConfigParser::configureTargets() {
return false;
}

if (extraDepends.size()) {
parseTargetPrivate(_config, extraDepends, &TargetInfo::addDepends);
}

return true;
}

Expand Down Expand Up @@ -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
Expand All @@ -1471,7 +1477,7 @@ void ConfigParser::initExtraNames() {
*/
if (_config.isNeededQt()) {
auto libs = DeployCore::Qt3rdpartyLibs( _config.getPlatformOfAll());
deployExtraNames(libs);
addExtraNamesMasks(libs);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Deploy/src/configparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -120,6 +119,7 @@ class DEPLOYSHARED_EXPORT ConfigParser
*/
bool addTarget(const TargetData &target);
void initCustomPlatform();
void addExtraNamesMasks(const QStringList &listNamesMasks);
};

#endif // CQT_H
9 changes: 6 additions & 3 deletions src/Deploy/src/dependenciesscanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,15 @@ LibInfo DependenciesScanner::scan(const QString &path) {
return info;
}

QSet<QString> stack;
recursiveDep(info, info._allDep , stack);

scan(info);
return info;
}

void DependenciesScanner::scan(LibInfo &lib) {
QSet<QString> stack;
recursiveDep(lib, lib._allDep , stack);
}

DependenciesScanner::~DependenciesScanner() {

}
14 changes: 13 additions & 1 deletion src/Deploy/src/dependenciesscanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
10 changes: 8 additions & 2 deletions src/Deploy/src/deploycore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
15 changes: 11 additions & 4 deletions src/Deploy/src/extracter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -406,9 +406,16 @@ void Extracter::extractLib(const QString &file,
QuasarAppUtils::Params::log("extract lib :" + file,
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())) {
continue;
Expand Down
4 changes: 4 additions & 0 deletions src/Deploy/src/libinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QString> &value) {
_dependncies += value;
}
Expand Down
1 change: 1 addition & 0 deletions src/Deploy/src/libinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class DEPLOYSHARED_EXPORT LibInfo {
QSet<QString> getDependncies() const;
void setDependncies(const QSet<QString> &value);
void addDependncies(const QString &value);
void addDepends(const QString &value);
void addDependncies(const QSet<QString> &value);
void removeDependncies(const QString &value);

Expand Down
4 changes: 0 additions & 4 deletions src/Deploy/src/targetinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//#

#include "targetinfo.h"
#include "deploycore.h"
#include "deployconfig.h"

TargetInfo::TargetInfo() {

Expand Down Expand Up @@ -101,5 +99,3 @@ void TargetInfo::setFEnableRunScript(bool newFEnableRunScript) {
void TargetInfo::disableRunScript() {
setFEnableRunScript(false);
}


3 changes: 3 additions & 0 deletions tests/tstMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "qttest.h"

#ifdef Q_OS_LINUX
#include "extradependstest.h"

#include "allowemptypackagestest.h"
#include "binprefixtest.h"
#include "checkqttest.h"
Expand Down Expand Up @@ -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)
Expand Down
48 changes: 48 additions & 0 deletions tests/units/linux/extradependstest.cpp
Original file line number Diff line number Diff line change
@@ -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);

}
24 changes: 24 additions & 0 deletions tests/units/linux/extradependstest.h
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion tests/units/testbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ce62467

Please sign in to comment.