mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-27 10:14:32 +00:00
added winApiDeploy
This commit is contained in:
parent
9429b1acc8
commit
793c7848eb
@ -230,7 +230,8 @@ bool ConfigParser::loadFromFile(const QString& confFile) {
|
||||
|
||||
bool ConfigParser::parseQtDeployMode() {
|
||||
|
||||
if (QuasarAppUtils::Params::isEndable("deploySystem-with-libc")) {
|
||||
if (QuasarAppUtils::Params::isEndable("deploySystem-with-libc") ||
|
||||
QuasarAppUtils::Params::isEndable("deploySystem-with-winapi")) {
|
||||
QuasarAppUtils::Params::setEnable("deploySystem", true );
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <QList>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include "pathutils.h"
|
||||
|
||||
DependenciesScanner::DependenciesScanner() {}
|
||||
|
||||
@ -127,20 +128,34 @@ void DependenciesScanner::recursiveDep(LibInfo &lib, QSet<LibInfo> &res) {
|
||||
recursiveDep(*dep, listDep);
|
||||
|
||||
dep->allDep = listDep;
|
||||
lib.setWinApi(lib.getWinApi() | dep->getWinApi());
|
||||
_scanedLibs.insert(dep->fullPath(), *dep);
|
||||
|
||||
res.unite(listDep);
|
||||
} else {
|
||||
lib.setWinApi(lib.getWinApi() | scanedLib.getWinApi());
|
||||
res.unite(scanedLib.allDep);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DependenciesScanner::addToWinAPI(const QString &lib) {
|
||||
#ifdef Q_OS_WIN
|
||||
if (QuasarAppUtils::Params::isEndable("deploySystem-with-winapi")) {
|
||||
WinAPI api = _peScaner.getAPIModule(lib);
|
||||
if (api != WinAPI::NoWinAPI) {
|
||||
_winAPI.insert(api, lib);
|
||||
}
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(lib)
|
||||
#endif
|
||||
}
|
||||
|
||||
void DependenciesScanner::setEnvironment(const QStringList &env) {
|
||||
QDir dir;
|
||||
|
||||
QSet<QString> winAPI;
|
||||
for (auto i : env) {
|
||||
|
||||
dir.setPath(i);
|
||||
@ -153,16 +168,12 @@ void DependenciesScanner::setEnvironment(const QStringList &env) {
|
||||
QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden);
|
||||
|
||||
for (auto i : list) {
|
||||
if (i.fileName().contains(APU_MS_WIN , Qt::CaseInsensitive)) {
|
||||
winAPI.insert(i.fileName().toUpper());
|
||||
}
|
||||
|
||||
addToWinAPI(i.absoluteFilePath());
|
||||
_EnvLibs.insertMulti(i.fileName().toUpper(), i.absoluteFilePath());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_peScaner.setWinApiPlugins(winAPI);
|
||||
|
||||
}
|
||||
|
||||
@ -177,6 +188,18 @@ QSet<LibInfo> DependenciesScanner::scan(const QString &path) {
|
||||
|
||||
recursiveDep(info, result);
|
||||
|
||||
for (auto i = _winAPI.begin(); i != _winAPI.end(); ++i) {
|
||||
if ((info.getWinApi() & i.key()) != WinAPI::NoWinAPI) {
|
||||
|
||||
for (auto apiLib :_winAPI.values(i.key())) {
|
||||
LibInfo info;
|
||||
if (fillLibInfo(info, apiLib)) {
|
||||
result.insert(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,18 @@ private:
|
||||
PE _peScaner;
|
||||
ELF _elfScaner;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
QMultiHash<WinAPI, QString> _winAPI;
|
||||
#endif
|
||||
|
||||
PrivateScaner getScaner(const QString& lib) const;
|
||||
|
||||
QMultiMap<LibPriority, LibInfo> getLibsFromEnvirement(const QString& libName) const;
|
||||
|
||||
void recursiveDep(LibInfo& lib, QSet<LibInfo> &res);
|
||||
|
||||
void addToWinAPI(const QString& lib);
|
||||
|
||||
public:
|
||||
explicit DependenciesScanner();
|
||||
|
||||
|
@ -162,7 +162,7 @@ QString DeployCore::help() {
|
||||
{ "" },
|
||||
{ "Options:" },
|
||||
{ " help / h : Shows help." },
|
||||
{ " noOverwrite : Prevents replacing existing files." },
|
||||
{ " noOverwrite : Prevents replacing existing files." },
|
||||
{ " -bin [list, params] : Deployable file or folder." },
|
||||
{ " | For example -bin /my/project/bin/,/my/project/bin.exe" },
|
||||
{ " -confFile [params] | The path to the json file with all deployment configurations."},
|
||||
@ -173,8 +173,9 @@ QString DeployCore::help() {
|
||||
{ " | WARNING: this flag supports 'so', 'dll' and 'exe' files only." },
|
||||
{ " | Use '-bin' flag if you want to deploy linux binary files" },
|
||||
{ " -qmlDir [params] : Qml data dir. For example -qmlDir ~/my/project/qml" },
|
||||
{ " deploySystem : Deploys all libs" },
|
||||
{ " deploySystem-with-libc : Skip Deploys system core libs libs" },
|
||||
{ " deploySystem : Deploys all libs (Skip Deploys system core libs)" },
|
||||
{ " deploySystem-with-libc : Deploys all libs with Libc (Linux only, not snap)" },
|
||||
{ " deploySystem-with-winapi : Deploys all libs with win-api (Windows only)" },
|
||||
{ " -qmake [params] : Qmake path." },
|
||||
{ " | For example -qmake ~/Qt/5.14.0/gcc_64/bin/qmake" },
|
||||
{ " -ignore [list,params] : The list of libs to ignore." },
|
||||
@ -229,6 +230,7 @@ QStringList DeployCore::helpKeys() {
|
||||
"qmlDir",
|
||||
"deploySystem",
|
||||
"deploySystem-with-libc",
|
||||
"deploySystem-with-winapi",
|
||||
"qmake",
|
||||
"ignore",
|
||||
"ignoreEnv",
|
||||
@ -414,3 +416,7 @@ bool DeployCore::isExtraLib(const QString &lib) {
|
||||
QFileInfo info(lib);
|
||||
return _config->extraPaths.contains(info.absoluteFilePath());
|
||||
}
|
||||
|
||||
uint qHash(WinAPI i) {
|
||||
return static_cast<uint>(i);
|
||||
}
|
||||
|
@ -50,6 +50,19 @@ enum LibPriority : int {
|
||||
NotFile = 0xF,
|
||||
};
|
||||
|
||||
enum class WinAPI : quint8 {
|
||||
NoWinAPI = 0x00,
|
||||
Other = 0x01,
|
||||
Core = 0x02,
|
||||
Devices = 0x04,
|
||||
Eventing = 0x08,
|
||||
Crt = 0x10,
|
||||
Security = 0x20,
|
||||
Base = 0x40
|
||||
};
|
||||
|
||||
uint qHash (WinAPI i);
|
||||
|
||||
enum class RunMode: int {
|
||||
Info,
|
||||
Deploy,
|
||||
|
@ -94,6 +94,14 @@ void LibInfo::setQtPath(const QString &value)
|
||||
qtPath = value;
|
||||
}
|
||||
|
||||
WinAPI LibInfo::getWinApi() const {
|
||||
return _winApi;
|
||||
}
|
||||
|
||||
void LibInfo::setWinApi(WinAPI winApi) {
|
||||
_winApi = winApi;
|
||||
}
|
||||
|
||||
QString LibInfo::fullPath() const {
|
||||
return path + "/" + name;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ private:
|
||||
QSet<QString> dependncies;
|
||||
QString qtPath;
|
||||
LibPriority priority = NotFile;
|
||||
WinAPI _winApi = WinAPI::NoWinAPI;
|
||||
|
||||
public:
|
||||
|
||||
@ -53,6 +54,8 @@ public:
|
||||
void setPriority(const LibPriority &value);
|
||||
QString getQtPath() const;
|
||||
void setQtPath(const QString &value);
|
||||
WinAPI getWinApi() const;
|
||||
void setWinApi(WinAPI winApi);
|
||||
};
|
||||
|
||||
uint qHash(const LibInfo& info);
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <QSet>
|
||||
#include <QVector>
|
||||
#include <parser-library/parse.h>
|
||||
#include <quasarapp.h>
|
||||
|
||||
#include <bits/stl_set.h>
|
||||
|
||||
@ -65,21 +66,46 @@ bool PE::getDep(peparse::parsed_pe_internal * internal, LibInfo &res) const {
|
||||
}
|
||||
}
|
||||
|
||||
if (res.getName().contains(APU_MS_WIN, Qt::CaseInsensitive)) {
|
||||
res.addDependncies(_apimswin);
|
||||
return res.getDependncies().size() || !imports.size();
|
||||
}
|
||||
|
||||
WinAPI PE::getAPIModule(const QString &libName) const {
|
||||
if (libName.contains(API_MS_WIN, Qt::CaseInsensitive)) {
|
||||
if (libName.contains(API_MS_WIN_CORE, Qt::CaseInsensitive)) {
|
||||
return WinAPI::Core;
|
||||
}
|
||||
|
||||
if (libName.contains(API_MS_WIN_EVENTING, Qt::CaseInsensitive)) {
|
||||
return WinAPI::Eventing;
|
||||
}
|
||||
|
||||
if (libName.contains(API_MS_WIN_DEVICES, Qt::CaseInsensitive)) {
|
||||
return WinAPI::Devices;
|
||||
}
|
||||
|
||||
if (libName.contains(API_MS_WIN_CRT, Qt::CaseInsensitive)) {
|
||||
return WinAPI::Crt;
|
||||
}
|
||||
|
||||
if (libName.contains(API_MS_WIN_SECURITY, Qt::CaseInsensitive)) {
|
||||
return WinAPI::Security;
|
||||
}
|
||||
|
||||
if (libName.contains(API_MS_WIN_BASE, Qt::CaseInsensitive)) {
|
||||
return WinAPI::Base;
|
||||
}
|
||||
|
||||
return WinAPI::Other;
|
||||
|
||||
}
|
||||
|
||||
return res.getDependncies().size() || !imports.size();
|
||||
return WinAPI::NoWinAPI;
|
||||
}
|
||||
|
||||
PE::PE(): IGetLibInfo () {
|
||||
|
||||
}
|
||||
|
||||
void PE::setWinApiPlugins(const QSet<QString> &keys) {
|
||||
_apimswin = keys;
|
||||
}
|
||||
|
||||
bool PE::getLibInfo(const QString &lib, LibInfo &info) const {
|
||||
auto parsedPeLib = peparse::ParsePEFromFile(lib.toLatin1());
|
||||
|
||||
@ -104,6 +130,8 @@ bool PE::getLibInfo(const QString &lib, LibInfo &info) const {
|
||||
|
||||
peparse::DestructParsedPE(parsedPeLib);
|
||||
|
||||
info.setWinApi(getAPIModule(info.getName()));
|
||||
|
||||
return info.isValid();
|
||||
}
|
||||
|
||||
|
17
Deploy/pe.h
17
Deploy/pe.h
@ -13,7 +13,13 @@
|
||||
#include <QVector>
|
||||
#include "igetlibinfo.h"
|
||||
|
||||
#define APU_MS_WIN "api-ms-win"
|
||||
#define API_MS_WIN "api-ms-win-"
|
||||
#define API_MS_WIN_CORE "-core-"
|
||||
#define API_MS_WIN_EVENTING "-Eventing-"
|
||||
#define API_MS_WIN_DEVICES "-devices-"
|
||||
#define API_MS_WIN_CRT "-crt-"
|
||||
#define API_MS_WIN_SECURITY "-security-"
|
||||
#define API_MS_WIN_BASE "-base-"
|
||||
|
||||
namespace peparse {
|
||||
struct parsed_pe_internal;
|
||||
@ -24,8 +30,6 @@ private:
|
||||
|
||||
bool getDep(peparse::parsed_pe_internal *, LibInfo &res) const;
|
||||
|
||||
QSet<QString> _apimswin;
|
||||
|
||||
public:
|
||||
|
||||
enum class RunType: unsigned short {
|
||||
@ -35,12 +39,7 @@ public:
|
||||
_ROM = 0x107,
|
||||
};
|
||||
PE();
|
||||
|
||||
/**
|
||||
* @brief setWinApiPlugins
|
||||
* @param keys set values of api-ms-win libs
|
||||
*/
|
||||
void setWinApiPlugins(const QSet<QString>& keys);
|
||||
WinAPI getAPIModule(const QString &libName) const;
|
||||
|
||||
bool getLibInfo(const QString& lib, LibInfo& info) const override;
|
||||
|
||||
|
@ -44,9 +44,9 @@ private:
|
||||
QStringList getFilesFromDir(const QString& dir);
|
||||
|
||||
|
||||
void runTestParams(const QStringList &list, QSet<QString> *tree = nullptr, bool noWarnings = false);
|
||||
void runTestParams(const QStringList &list, QSet<QString> *tree = nullptr, bool noWarnings = false, bool onlySize = false);
|
||||
|
||||
void checkResults(const QSet<QString> &tree, bool noWarnings);
|
||||
void checkResults(const QSet<QString> &tree, bool noWarnings, bool onlySize = false);
|
||||
public:
|
||||
deploytest();
|
||||
/**
|
||||
@ -744,7 +744,7 @@ void deploytest::testSetTargetDir() {
|
||||
|
||||
}
|
||||
|
||||
void deploytest::runTestParams(const QStringList &list, QSet<QString>* tree, bool noWarnings) {
|
||||
void deploytest::runTestParams(const QStringList &list, QSet<QString>* tree, bool noWarnings, bool onlySize) {
|
||||
|
||||
QuasarAppUtils::Params::parseParams(list);
|
||||
|
||||
@ -752,7 +752,7 @@ void deploytest::runTestParams(const QStringList &list, QSet<QString>* tree, boo
|
||||
QVERIFY(deploy.run() == 0);
|
||||
|
||||
if (tree) {
|
||||
checkResults(*tree, noWarnings);
|
||||
checkResults(*tree, noWarnings, onlySize);
|
||||
}
|
||||
|
||||
#ifdef WITH_SNAP
|
||||
@ -790,7 +790,7 @@ void deploytest::runTestParams(const QStringList &list, QSet<QString>* tree, boo
|
||||
#endif
|
||||
}
|
||||
|
||||
void deploytest::checkResults(const QSet<QString> &tree, bool noWarnings) {
|
||||
void deploytest::checkResults(const QSet<QString> &tree, bool noWarnings , bool onlySize) {
|
||||
TestUtils utils;
|
||||
|
||||
QVERIFY(DeployCore::_config);
|
||||
@ -800,6 +800,11 @@ void deploytest::checkResults(const QSet<QString> &tree, bool noWarnings) {
|
||||
|
||||
auto comapre = utils.compareTree(resultTree, tree);
|
||||
|
||||
if (onlySize) {
|
||||
QVERIFY(resultTree.size() > tree.size());
|
||||
return;
|
||||
}
|
||||
|
||||
if (comapre.size() != 0) {
|
||||
|
||||
bool bug = false;
|
||||
@ -1624,6 +1629,12 @@ void deploytest::testSystemLib() {
|
||||
"deploySystem"
|
||||
}, &comapareTree, true);
|
||||
|
||||
runTestParams({"-bin", bin, "clear" ,
|
||||
"-qmake", qmake,
|
||||
"deploySystem-with-winapi"
|
||||
}, &comapareTree, true, true);
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user