mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-05-06 14:39:35 +00:00
added new method of parse qt plugins
This commit is contained in:
parent
6f70498dc1
commit
d46a243f8b
@ -45,24 +45,28 @@ include('$$PWD/../pe/pe-parser-library/pe-parser-library.pri')
|
|||||||
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
deploy.cpp \
|
deploy.cpp \
|
||||||
deployutils.cpp \
|
deployparams.cpp \
|
||||||
|
deployutils.cpp \
|
||||||
pe.cpp \
|
pe.cpp \
|
||||||
igetlibinfo.cpp \
|
igetlibinfo.cpp \
|
||||||
dependenciesscanner.cpp \
|
dependenciesscanner.cpp \
|
||||||
../qtTools/src/shared/winutils/elfreader.cpp \
|
../qtTools/src/shared/winutils/elfreader.cpp \
|
||||||
elf.cpp \
|
elf.cpp \
|
||||||
|
pluginsparser.cpp \
|
||||||
qml.cpp \
|
qml.cpp \
|
||||||
libinfo.cpp
|
libinfo.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
deploy.h \
|
deploy.h \
|
||||||
deploy_global.h \
|
deploy_global.h \
|
||||||
deployutils.h \
|
deployparams.h \
|
||||||
|
deployutils.h \
|
||||||
pe.h \
|
pe.h \
|
||||||
igetlibinfo.h \
|
igetlibinfo.h \
|
||||||
dependenciesscanner.h \
|
dependenciesscanner.h \
|
||||||
../qtTools/src/shared/winutils/elfreader.h \
|
../qtTools/src/shared/winutils/elfreader.h \
|
||||||
elf.h \
|
elf.h \
|
||||||
|
pluginsparser.h \
|
||||||
qml.h \
|
qml.h \
|
||||||
libinfo.h
|
libinfo.h
|
||||||
|
@ -16,6 +16,12 @@ DependenciesScanner::DependenciesScanner() {}
|
|||||||
|
|
||||||
void DependenciesScanner::clearScaned() {
|
void DependenciesScanner::clearScaned() {
|
||||||
_scanedLibs.clear();
|
_scanedLibs.clear();
|
||||||
|
_qtModules = DeployUtils::QtModule::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeployUtils::QtModule DependenciesScanner::getQtModules() const
|
||||||
|
{
|
||||||
|
return _qtModules;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivateScaner DependenciesScanner::getScaner(const QString &lib) const {
|
PrivateScaner DependenciesScanner::getScaner(const QString &lib) const {
|
||||||
@ -35,7 +41,7 @@ PrivateScaner DependenciesScanner::getScaner(const QString &lib) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QMultiMap<LibPriority, LibInfo> DependenciesScanner::getLibsFromEnvirement(
|
QMultiMap<LibPriority, LibInfo> DependenciesScanner::getLibsFromEnvirement(
|
||||||
const QString &libName) {
|
const QString &libName) const {
|
||||||
|
|
||||||
auto values = _EnvLibs.values(libName.toUpper());
|
auto values = _EnvLibs.values(libName.toUpper());
|
||||||
QMultiMap<LibPriority, LibInfo> res;
|
QMultiMap<LibPriority, LibInfo> res;
|
||||||
@ -58,7 +64,7 @@ QMultiMap<LibPriority, LibInfo> DependenciesScanner::getLibsFromEnvirement(
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DependenciesScanner::fillLibInfo(LibInfo &info, const QString &file) {
|
bool DependenciesScanner::fillLibInfo(LibInfo &info, const QString &file) const {
|
||||||
|
|
||||||
info.clear();
|
info.clear();
|
||||||
auto scaner = getScaner(file);
|
auto scaner = getScaner(file);
|
||||||
@ -74,8 +80,7 @@ bool DependenciesScanner::fillLibInfo(LibInfo &info, const QString &file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DependenciesScanner::recursiveDep(LibInfo &lib, QSet<LibInfo> &res)
|
void DependenciesScanner::recursiveDep(LibInfo &lib, QSet<LibInfo> &res) {
|
||||||
{
|
|
||||||
QuasarAppUtils::Params::verboseLog("get recursive dependencies of " + lib.fullPath(),
|
QuasarAppUtils::Params::verboseLog("get recursive dependencies of " + lib.fullPath(),
|
||||||
QuasarAppUtils::Info);
|
QuasarAppUtils::Info);
|
||||||
|
|
||||||
@ -119,6 +124,7 @@ void DependenciesScanner::recursiveDep(LibInfo &lib, QSet<LibInfo> &res)
|
|||||||
|
|
||||||
dep->allDep = listDep;
|
dep->allDep = listDep;
|
||||||
_scanedLibs.insert(dep->fullPath(), *dep);
|
_scanedLibs.insert(dep->fullPath(), *dep);
|
||||||
|
DeployUtils::addQtModule(_qtModules, dep->fullPath());
|
||||||
|
|
||||||
res.unite(listDep);
|
res.unite(listDep);
|
||||||
} else {
|
} else {
|
||||||
|
@ -26,6 +26,9 @@ class DEPLOYSHARED_EXPORT DependenciesScanner {
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
DeployUtils::QtModule _qtModules;
|
||||||
|
|
||||||
QStringList _env;
|
QStringList _env;
|
||||||
QMultiHash<QString, QString> _EnvLibs;
|
QMultiHash<QString, QString> _EnvLibs;
|
||||||
QHash<QString, LibInfo> _scanedLibs;
|
QHash<QString, LibInfo> _scanedLibs;
|
||||||
@ -35,8 +38,8 @@ private:
|
|||||||
|
|
||||||
PrivateScaner getScaner(const QString& lib) const;
|
PrivateScaner getScaner(const QString& lib) const;
|
||||||
|
|
||||||
QMultiMap<LibPriority, LibInfo> getLibsFromEnvirement(const QString& libName);
|
QMultiMap<LibPriority, LibInfo> getLibsFromEnvirement(const QString& libName) const;
|
||||||
bool fillLibInfo(LibInfo& info ,const QString& file);
|
bool fillLibInfo(LibInfo& info ,const QString& file) const;
|
||||||
|
|
||||||
void recursiveDep(LibInfo& lib, QSet<LibInfo> &res);
|
void recursiveDep(LibInfo& lib, QSet<LibInfo> &res);
|
||||||
|
|
||||||
@ -51,6 +54,7 @@ public:
|
|||||||
|
|
||||||
friend class deploytest;
|
friend class deploytest;
|
||||||
void clearScaned();
|
void clearScaned();
|
||||||
|
DeployUtils::QtModule getQtModules() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WINDEPENDENCIESSCANNER_H
|
#endif // WINDEPENDENCIESSCANNER_H
|
||||||
|
6
Deploy/deployparams.cpp
Normal file
6
Deploy/deployparams.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "deployparams.h"
|
||||||
|
|
||||||
|
DeployParams::DeployParams()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
12
Deploy/deployparams.h
Normal file
12
Deploy/deployparams.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef DEPLOYPARAMS_H
|
||||||
|
#define DEPLOYPARAMS_H
|
||||||
|
|
||||||
|
#include "deploy_global.h"
|
||||||
|
|
||||||
|
class DEPLOYSHARED_EXPORT DeployParams
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DeployParams();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEPLOYPARAMS_H
|
@ -73,6 +73,31 @@ QtModuleEntry DeployUtils::qtModuleEntries[] = {
|
|||||||
{ QtWebViewModule, "webview", "Qt5WebView", nullptr }
|
{ QtWebViewModule, "webview", "Qt5WebView", nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DeployUtils::QtModule DeployUtils::getQtModule(const QString& path) {
|
||||||
|
auto priority = DeployUtils::getLibPriority(path);
|
||||||
|
|
||||||
|
if (priority != QtLib) {
|
||||||
|
return DeployUtils::QtModule::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int modulesCount = sizeof (qtModuleEntries) / sizeof (QtModuleEntry);
|
||||||
|
|
||||||
|
auto lIbName = QFileInfo(path).fileName();
|
||||||
|
|
||||||
|
for (int i = 0; i < modulesCount; ++i) {
|
||||||
|
if (lIbName.contains(qtModuleEntries[i].libraryName)) {
|
||||||
|
return static_cast<DeployUtils::QtModule>(qtModuleEntries[i].module);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DeployUtils::QtModule::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeployUtils::addQtModule(DeployUtils::QtModule &module, const QString &path) {
|
||||||
|
module = static_cast<DeployUtils::QtModule>(
|
||||||
|
static_cast<quint64>(module) | static_cast<quint64>(getQtModule(path)));
|
||||||
|
}
|
||||||
|
|
||||||
LibPriority DeployUtils::getLibPriority(const QString &lib) {
|
LibPriority DeployUtils::getLibPriority(const QString &lib) {
|
||||||
|
|
||||||
if (!QFileInfo(lib).isFile()) {
|
if (!QFileInfo(lib).isFile()) {
|
||||||
|
@ -66,6 +66,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
enum QtModule : quint64
|
enum QtModule : quint64
|
||||||
{
|
{
|
||||||
|
NONE = 0x0000000000000000,
|
||||||
QtBluetoothModule = 0x0000000000000001,
|
QtBluetoothModule = 0x0000000000000001,
|
||||||
QtConcurrentModule = 0x0000000000000002,
|
QtConcurrentModule = 0x0000000000000002,
|
||||||
QtCoreModule = 0x0000000000000004,
|
QtCoreModule = 0x0000000000000004,
|
||||||
@ -132,6 +133,9 @@ public:
|
|||||||
static bool isQtLib(const QString &lib);
|
static bool isQtLib(const QString &lib);
|
||||||
static bool isExtraLib(const QString &lib);
|
static bool isExtraLib(const QString &lib);
|
||||||
static LibPriority getLibPriority(const QString &lib);
|
static LibPriority getLibPriority(const QString &lib);
|
||||||
|
static DeployUtils::QtModule getQtModule(const QString& path);
|
||||||
|
static void addQtModule(DeployUtils::QtModule& module, const QString& path);
|
||||||
|
|
||||||
static void verboseLog(const QString &str);
|
static void verboseLog(const QString &str);
|
||||||
static RunMode getMode();
|
static RunMode getMode();
|
||||||
static void help();
|
static void help();
|
||||||
|
@ -7,7 +7,7 @@ ELF::ELF()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ELF::getLibInfo(const QString &lib, LibInfo &info) {
|
bool ELF::getLibInfo(const QString &lib, LibInfo &info) const {
|
||||||
ElfReader reader(lib);
|
ElfReader reader(lib);
|
||||||
|
|
||||||
auto headers = reader.readHeaders();
|
auto headers = reader.readHeaders();
|
||||||
|
@ -11,7 +11,7 @@ class ELF : public IGetLibInfo
|
|||||||
public:
|
public:
|
||||||
ELF();
|
ELF();
|
||||||
|
|
||||||
bool getLibInfo(const QString &lib, LibInfo &info);
|
bool getLibInfo(const QString &lib, LibInfo &info) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ELF_H
|
#endif // ELF_H
|
||||||
|
@ -8,7 +8,7 @@ class IGetLibInfo
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IGetLibInfo() = default;
|
IGetLibInfo() = default;
|
||||||
virtual bool getLibInfo(const QString& lib, LibInfo& info) = 0;
|
virtual bool getLibInfo(const QString& lib, LibInfo& info) const = 0;
|
||||||
virtual ~IGetLibInfo() = default;
|
virtual ~IGetLibInfo() = default;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@ struct parsed_pe_internal {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PE::getDep(peparse::parsed_pe_internal * internal, LibInfo &res) {
|
bool PE::getDep(peparse::parsed_pe_internal * internal, LibInfo &res) const {
|
||||||
auto imports = internal->imports;
|
auto imports = internal->imports;
|
||||||
|
|
||||||
std::set<std::string> filter;
|
std::set<std::string> filter;
|
||||||
@ -52,7 +52,7 @@ PE::PE(): IGetLibInfo () {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PE::getLibInfo(const QString &lib, LibInfo &info) {
|
bool PE::getLibInfo(const QString &lib, LibInfo &info) const {
|
||||||
auto parsedPeLib = peparse::ParsePEFromFile(lib.toLatin1());
|
auto parsedPeLib = peparse::ParsePEFromFile(lib.toLatin1());
|
||||||
|
|
||||||
if (static_cast<RunType>(parsedPeLib->peHeader.nt.OptionalMagic) == RunType::_32bit) {
|
if (static_cast<RunType>(parsedPeLib->peHeader.nt.OptionalMagic) == RunType::_32bit) {
|
||||||
|
@ -13,7 +13,7 @@ class PE : public IGetLibInfo {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool getDep(peparse::parsed_pe_internal *, LibInfo &res);
|
bool getDep(peparse::parsed_pe_internal *, LibInfo &res) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ public:
|
|||||||
};
|
};
|
||||||
PE();
|
PE();
|
||||||
|
|
||||||
bool getLibInfo(const QString& lib, LibInfo& info) override;
|
bool getLibInfo(const QString& lib, LibInfo& info) const override;
|
||||||
|
|
||||||
~PE() override;
|
~PE() override;
|
||||||
|
|
||||||
|
70
Deploy/pluginsparser.cpp
Normal file
70
Deploy/pluginsparser.cpp
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#include "pluginsparser.h"
|
||||||
|
#include <QDir>
|
||||||
|
#include <dependenciesscanner.h>
|
||||||
|
|
||||||
|
PluginsParser::PluginsParser(DependenciesScanner* scaner)
|
||||||
|
{
|
||||||
|
assert(scaner);
|
||||||
|
|
||||||
|
_libScaner = scaner;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const PluginModuleMapping pluginModuleMappings[] =
|
||||||
|
{
|
||||||
|
{"qml1tooling", DeployUtils::QtModule::QtDeclarativeModule},
|
||||||
|
{"gamepads", DeployUtils::QtModule::QtGamePadModule},
|
||||||
|
{"accessible", DeployUtils::QtModule::QtGuiModule},
|
||||||
|
{"iconengines", DeployUtils::QtModule::QtGuiModule},
|
||||||
|
{"imageformats", DeployUtils::QtModule::QtGuiModule},
|
||||||
|
{"platforms", DeployUtils::QtModule::QtGuiModule},
|
||||||
|
{"platforminputcontexts", DeployUtils::QtModule::QtGuiModule},
|
||||||
|
{"virtualkeyboard", DeployUtils::QtModule::QtGuiModule},
|
||||||
|
{"geoservices", DeployUtils::QtModule::QtLocationModule},
|
||||||
|
{"audio", DeployUtils::QtModule::QtMultimediaModule},
|
||||||
|
{"mediaservice", DeployUtils::QtModule::QtMultimediaModule},
|
||||||
|
{"playlistformats", DeployUtils::QtModule::QtMultimediaModule},
|
||||||
|
{"bearer", DeployUtils::QtModule::QtNetworkModule},
|
||||||
|
{"position", DeployUtils::QtModule::QtPositioningModule},
|
||||||
|
{"printsupport", DeployUtils::QtModule::QtPrintSupportModule},
|
||||||
|
{"scenegraph", DeployUtils::QtModule::QtQuickModule},
|
||||||
|
{"qmltooling", DeployUtils::QtModule::QtQuickModule | DeployUtils::QtModule::QtQmlToolingModule},
|
||||||
|
{"sensors", DeployUtils::QtModule::QtSensorsModule},
|
||||||
|
{"sensorgestures", DeployUtils::QtModule::QtSensorsModule},
|
||||||
|
{"canbus", DeployUtils::QtModule::QtSerialBusModule},
|
||||||
|
{"sqldrivers", DeployUtils::QtModule::QtSqlModule},
|
||||||
|
{"texttospeech", DeployUtils::QtModule::QtTextToSpeechModule},
|
||||||
|
{"qtwebengine", DeployUtils::QtModule::QtWebEngineModule | DeployUtils::QtModule::QtWebEngineCoreModule | DeployUtils::QtModule::QtWebEngineWidgetsModule},
|
||||||
|
{"styles", DeployUtils::QtModule::QtWidgetsModule},
|
||||||
|
{"sceneparsers", DeployUtils::QtModule::Qt3DRendererModule},
|
||||||
|
{"renderplugins", DeployUtils::QtModule::Qt3DRendererModule},
|
||||||
|
{"geometryloaders", DeployUtils::QtModule::Qt3DRendererModule},
|
||||||
|
{"webview", DeployUtils::QtModule::QtWebViewModule}
|
||||||
|
};
|
||||||
|
|
||||||
|
quint64 PluginsParser::qtModuleForPlugin(const QString &subDirName) {
|
||||||
|
const auto end = std::end(pluginModuleMappings);
|
||||||
|
|
||||||
|
const auto result =
|
||||||
|
std::find_if(std::begin(pluginModuleMappings), end,
|
||||||
|
[&subDirName] (const PluginModuleMapping &m) {
|
||||||
|
|
||||||
|
return subDirName == QLatin1String(m.directoryName);
|
||||||
|
});
|
||||||
|
|
||||||
|
return result != end ? result->module : 0; // "designer"
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PluginsParser::scan(const QString& pluginPath,
|
||||||
|
QStringList &resDependencies) {
|
||||||
|
|
||||||
|
auto modules = _libScaner->getQtModules();
|
||||||
|
auto plugins = QDir(pluginPath).entryInfoList(QDir::Dirs);
|
||||||
|
|
||||||
|
for (auto &&plugin: plugins) {
|
||||||
|
if (modules & qtModuleForPlugin(plugin.fileName())) {
|
||||||
|
resDependencies.append(plugin.absoluteFilePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
25
Deploy/pluginsparser.h
Normal file
25
Deploy/pluginsparser.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef QTMODULES_H
|
||||||
|
#define QTMODULES_H
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
class DependenciesScanner;
|
||||||
|
|
||||||
|
struct PluginModuleMapping
|
||||||
|
{
|
||||||
|
const char *directoryName;
|
||||||
|
quint64 module;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PluginsParser
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
DependenciesScanner *_libScaner = nullptr;
|
||||||
|
|
||||||
|
quint64 qtModuleForPlugin(const QString &subDirName);
|
||||||
|
public:
|
||||||
|
PluginsParser(DependenciesScanner *scaner);
|
||||||
|
bool scan(const QString &pluginPath, QStringList& resDependencies);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QTMODULES_H
|
Loading…
x
Reference in New Issue
Block a user