diff --git a/Deploy/Deploy.pro b/Deploy/Deploy.pro index b33d416..92da219 100644 --- a/Deploy/Deploy.pro +++ b/Deploy/Deploy.pro @@ -45,24 +45,28 @@ include('$$PWD/../pe/pe-parser-library/pe-parser-library.pri') SOURCES += \ - deploy.cpp \ - deployutils.cpp \ + deploy.cpp \ + deployparams.cpp \ + deployutils.cpp \ pe.cpp \ igetlibinfo.cpp \ dependenciesscanner.cpp \ ../qtTools/src/shared/winutils/elfreader.cpp \ elf.cpp \ + pluginsparser.cpp \ qml.cpp \ libinfo.cpp HEADERS += \ - deploy.h \ - deploy_global.h \ - deployutils.h \ + deploy.h \ + deploy_global.h \ + deployparams.h \ + deployutils.h \ pe.h \ igetlibinfo.h \ dependenciesscanner.h \ ../qtTools/src/shared/winutils/elfreader.h \ elf.h \ + pluginsparser.h \ qml.h \ libinfo.h diff --git a/Deploy/dependenciesscanner.cpp b/Deploy/dependenciesscanner.cpp index 30551e1..a0e47ec 100644 --- a/Deploy/dependenciesscanner.cpp +++ b/Deploy/dependenciesscanner.cpp @@ -16,6 +16,12 @@ DependenciesScanner::DependenciesScanner() {} void DependenciesScanner::clearScaned() { _scanedLibs.clear(); + _qtModules = DeployUtils::QtModule::NONE; +} + +DeployUtils::QtModule DependenciesScanner::getQtModules() const +{ + return _qtModules; } PrivateScaner DependenciesScanner::getScaner(const QString &lib) const { @@ -35,7 +41,7 @@ PrivateScaner DependenciesScanner::getScaner(const QString &lib) const { } QMultiMap DependenciesScanner::getLibsFromEnvirement( - const QString &libName) { + const QString &libName) const { auto values = _EnvLibs.values(libName.toUpper()); QMultiMap res; @@ -58,7 +64,7 @@ QMultiMap DependenciesScanner::getLibsFromEnvirement( return res; } -bool DependenciesScanner::fillLibInfo(LibInfo &info, const QString &file) { +bool DependenciesScanner::fillLibInfo(LibInfo &info, const QString &file) const { info.clear(); auto scaner = getScaner(file); @@ -74,8 +80,7 @@ bool DependenciesScanner::fillLibInfo(LibInfo &info, const QString &file) { } } -void DependenciesScanner::recursiveDep(LibInfo &lib, QSet &res) -{ +void DependenciesScanner::recursiveDep(LibInfo &lib, QSet &res) { QuasarAppUtils::Params::verboseLog("get recursive dependencies of " + lib.fullPath(), QuasarAppUtils::Info); @@ -119,6 +124,7 @@ void DependenciesScanner::recursiveDep(LibInfo &lib, QSet &res) dep->allDep = listDep; _scanedLibs.insert(dep->fullPath(), *dep); + DeployUtils::addQtModule(_qtModules, dep->fullPath()); res.unite(listDep); } else { diff --git a/Deploy/dependenciesscanner.h b/Deploy/dependenciesscanner.h index ea809fe..0f6f2d6 100644 --- a/Deploy/dependenciesscanner.h +++ b/Deploy/dependenciesscanner.h @@ -26,6 +26,9 @@ class DEPLOYSHARED_EXPORT DependenciesScanner { private: + + DeployUtils::QtModule _qtModules; + QStringList _env; QMultiHash _EnvLibs; QHash _scanedLibs; @@ -35,8 +38,8 @@ private: PrivateScaner getScaner(const QString& lib) const; - QMultiMap getLibsFromEnvirement(const QString& libName); - bool fillLibInfo(LibInfo& info ,const QString& file); + QMultiMap getLibsFromEnvirement(const QString& libName) const; + bool fillLibInfo(LibInfo& info ,const QString& file) const; void recursiveDep(LibInfo& lib, QSet &res); @@ -51,6 +54,7 @@ public: friend class deploytest; void clearScaned(); + DeployUtils::QtModule getQtModules() const; }; #endif // WINDEPENDENCIESSCANNER_H diff --git a/Deploy/deployparams.cpp b/Deploy/deployparams.cpp new file mode 100644 index 0000000..438efb0 --- /dev/null +++ b/Deploy/deployparams.cpp @@ -0,0 +1,6 @@ +#include "deployparams.h" + +DeployParams::DeployParams() +{ + +} diff --git a/Deploy/deployparams.h b/Deploy/deployparams.h new file mode 100644 index 0000000..5d29de1 --- /dev/null +++ b/Deploy/deployparams.h @@ -0,0 +1,12 @@ +#ifndef DEPLOYPARAMS_H +#define DEPLOYPARAMS_H + +#include "deploy_global.h" + +class DEPLOYSHARED_EXPORT DeployParams +{ +public: + DeployParams(); +}; + +#endif // DEPLOYPARAMS_H diff --git a/Deploy/deployutils.cpp b/Deploy/deployutils.cpp index 701bf8c..04a48f6 100644 --- a/Deploy/deployutils.cpp +++ b/Deploy/deployutils.cpp @@ -73,6 +73,31 @@ QtModuleEntry DeployUtils::qtModuleEntries[] = { { 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(qtModuleEntries[i].module); + } + } + + return DeployUtils::QtModule::NONE; +} + +void DeployUtils::addQtModule(DeployUtils::QtModule &module, const QString &path) { + module = static_cast( + static_cast(module) | static_cast(getQtModule(path))); +} + LibPriority DeployUtils::getLibPriority(const QString &lib) { if (!QFileInfo(lib).isFile()) { diff --git a/Deploy/deployutils.h b/Deploy/deployutils.h index 5164220..1833518 100644 --- a/Deploy/deployutils.h +++ b/Deploy/deployutils.h @@ -66,6 +66,7 @@ private: public: enum QtModule : quint64 { + NONE = 0x0000000000000000, QtBluetoothModule = 0x0000000000000001, QtConcurrentModule = 0x0000000000000002, QtCoreModule = 0x0000000000000004, @@ -132,6 +133,9 @@ public: static bool isQtLib(const QString &lib); static bool isExtraLib(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 RunMode getMode(); static void help(); diff --git a/Deploy/elf.cpp b/Deploy/elf.cpp index a4d42c2..9ea3a12 100644 --- a/Deploy/elf.cpp +++ b/Deploy/elf.cpp @@ -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); auto headers = reader.readHeaders(); diff --git a/Deploy/elf.h b/Deploy/elf.h index 998013a..4d89144 100644 --- a/Deploy/elf.h +++ b/Deploy/elf.h @@ -11,7 +11,7 @@ class ELF : public IGetLibInfo public: ELF(); - bool getLibInfo(const QString &lib, LibInfo &info); + bool getLibInfo(const QString &lib, LibInfo &info) const override; }; #endif // ELF_H diff --git a/Deploy/igetlibinfo.h b/Deploy/igetlibinfo.h index 0f46ef4..4c5f302 100644 --- a/Deploy/igetlibinfo.h +++ b/Deploy/igetlibinfo.h @@ -8,7 +8,7 @@ class IGetLibInfo { public: IGetLibInfo() = default; - virtual bool getLibInfo(const QString& lib, LibInfo& info) = 0; + virtual bool getLibInfo(const QString& lib, LibInfo& info) const = 0; virtual ~IGetLibInfo() = default; }; diff --git a/Deploy/pe.cpp b/Deploy/pe.cpp index 14e231e..7e2a043 100644 --- a/Deploy/pe.cpp +++ b/Deploy/pe.cpp @@ -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; std::set 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()); if (static_cast(parsedPeLib->peHeader.nt.OptionalMagic) == RunType::_32bit) { diff --git a/Deploy/pe.h b/Deploy/pe.h index fe97f6f..b47f27a 100644 --- a/Deploy/pe.h +++ b/Deploy/pe.h @@ -13,7 +13,7 @@ class PE : public IGetLibInfo { private: - bool getDep(peparse::parsed_pe_internal *, LibInfo &res); + bool getDep(peparse::parsed_pe_internal *, LibInfo &res) const; public: @@ -25,7 +25,7 @@ public: }; PE(); - bool getLibInfo(const QString& lib, LibInfo& info) override; + bool getLibInfo(const QString& lib, LibInfo& info) const override; ~PE() override; diff --git a/Deploy/pluginsparser.cpp b/Deploy/pluginsparser.cpp new file mode 100644 index 0000000..f199387 --- /dev/null +++ b/Deploy/pluginsparser.cpp @@ -0,0 +1,70 @@ +#include "pluginsparser.h" +#include +#include + +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; +} diff --git a/Deploy/pluginsparser.h b/Deploy/pluginsparser.h new file mode 100644 index 0000000..384b72f --- /dev/null +++ b/Deploy/pluginsparser.h @@ -0,0 +1,25 @@ +#ifndef QTMODULES_H +#define QTMODULES_H + +#include + +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