mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-05-09 16:09:37 +00:00
added support check qt major version
This commit is contained in:
parent
61047efefb
commit
c03d92e599
@ -617,15 +617,15 @@ QSet<QString> ConfigParser::getQtPathesFromTargets() {
|
||||
return res;
|
||||
}
|
||||
|
||||
bool ConfigParser::isNeededQt() const {
|
||||
QtMajorVersion ConfigParser::isNeededQt() const {
|
||||
|
||||
for (const auto &i: _config.targets()) {
|
||||
if (i.isValid() && i.isDependetOfQt()) {
|
||||
return true;
|
||||
if (i.isValid()) {
|
||||
return i.isDependetOfQt();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return QtMajorVersion::NoQt;
|
||||
}
|
||||
|
||||
void ConfigParser::setTargetDir(const QString &target) {
|
||||
@ -920,7 +920,6 @@ bool ConfigParser::initQmakePrivate(const QString &qmake) {
|
||||
bool ConfigParser::initQmake() {
|
||||
|
||||
|
||||
|
||||
if (!isNeededQt()) {
|
||||
QuasarAppUtils::Params::log("deploy only C/C++ libraryes because a qmake is not needed"
|
||||
" for the distribution",
|
||||
@ -1028,6 +1027,9 @@ bool ConfigParser::setQmake(const QString &value) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_config.qtDir.setQtVersion(isNeededQt());
|
||||
|
||||
_config.envirement.addEnv(_config.qtDir.getLibs());
|
||||
_config.envirement.addEnv(_config.qtDir.getBins());
|
||||
|
||||
@ -1092,6 +1094,8 @@ bool ConfigParser::setQtDir(const QString &value) {
|
||||
_config.qtDir.setQtPlatform(Platform::Win);
|
||||
#endif
|
||||
|
||||
_config.qtDir.setQtVersion(isNeededQt());
|
||||
|
||||
_config.envirement.addEnv(_config.qtDir.getLibs());
|
||||
_config.envirement.addEnv(_config.qtDir.getBins());
|
||||
|
||||
|
@ -82,6 +82,10 @@ private:
|
||||
|
||||
void initEnvirement();
|
||||
|
||||
/**
|
||||
* @brief checkSnapPermisions This method checks the required permissions. Of all the permissions granted, this method returns true, otherwise false.
|
||||
* @return
|
||||
*/
|
||||
bool checkSnapPermisions();
|
||||
|
||||
QStringList getDirsRecursive(const QString &path, int maxDepch = -1, int depch = 0);
|
||||
@ -102,7 +106,7 @@ private:
|
||||
|
||||
iDistribution* getDistribution();
|
||||
|
||||
bool isNeededQt() const;
|
||||
QtMajorVersion isNeededQt() const;
|
||||
};
|
||||
|
||||
#endif // CQT_H
|
||||
|
@ -513,21 +513,34 @@ QString DeployCore::getMSVCVersion(MSVCVersion msvc) {
|
||||
return "";
|
||||
}
|
||||
|
||||
bool DeployCore::isQtLib(const QString &lib) {
|
||||
QtMajorVersion DeployCore::isQtLib(const QString &lib) {
|
||||
QFileInfo info(lib);
|
||||
/*
|
||||
* Task https://github.com/QuasarApp/CQtDeployer/issues/422
|
||||
* All qt libs need to contains the Qt label.
|
||||
*/
|
||||
bool isQt = isLib(info) && info.fileName().contains("Qt", ONLY_WIN_CASE_INSENSIATIVE);
|
||||
QtMajorVersion isQt = QtMajorVersion::NoQt;
|
||||
|
||||
if (_config) {
|
||||
isQt = isQt && _config->qtDir.isQt(info.absoluteFilePath());
|
||||
if (!isLib(info)) {
|
||||
return isQt;
|
||||
}
|
||||
|
||||
QString fileName = info.fileName();
|
||||
if (fileName.contains("Qt4", ONLY_WIN_CASE_INSENSIATIVE)) {
|
||||
isQt = QtMajorVersion::Qt4;
|
||||
} else if (fileName.contains("Qt5", ONLY_WIN_CASE_INSENSIATIVE)) {
|
||||
isQt = QtMajorVersion::Qt5;
|
||||
} else if (fileName.contains("Qt6", ONLY_WIN_CASE_INSENSIATIVE)) {
|
||||
isQt = QtMajorVersion::Qt6;
|
||||
}
|
||||
|
||||
if (_config && !_config->qtDir.isQt(info.absoluteFilePath())) {
|
||||
return QtMajorVersion::NoQt;
|
||||
}
|
||||
|
||||
if (isQt && QuasarAppUtils::Params::isEndable("noQt") &&
|
||||
!QuasarAppUtils::Params::isEndable("qmake")) {
|
||||
return false;
|
||||
return QtMajorVersion::NoQt;
|
||||
}
|
||||
|
||||
return isQt;
|
||||
|
@ -23,6 +23,16 @@ enum MSVCVersion: int {
|
||||
MSVC_19 = 0x80,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The QtMajorVersion enum
|
||||
*/
|
||||
enum QtMajorVersion: int {
|
||||
NoQt = 0x0,
|
||||
Qt4 = 0x01,
|
||||
Qt5 = 0x02,
|
||||
Qt6 = 0x04
|
||||
};
|
||||
|
||||
struct DEPLOYSHARED_EXPORT QtModuleEntry {
|
||||
quint64 module;
|
||||
const char *option;
|
||||
@ -175,7 +185,7 @@ public:
|
||||
static MSVCVersion getMSVC(const QString & _qtBin);
|
||||
static QString getVCredist(const QString & _qtBin);
|
||||
|
||||
static bool isQtLib(const QString &lib);
|
||||
static QtMajorVersion isQtLib(const QString &lib);
|
||||
static bool isExtraLib(const QString &lib);
|
||||
static QChar getSeparator(int lvl);
|
||||
static bool isAlienLib(const QString &lib);
|
||||
|
@ -102,14 +102,14 @@ void LibInfo::setWinApi(WinAPI winApi) {
|
||||
_winApi = winApi;
|
||||
}
|
||||
|
||||
bool LibInfo::isDependetOfQt() const {
|
||||
QtMajorVersion LibInfo::isDependetOfQt() const {
|
||||
for (const auto& i : dependncies) {
|
||||
if (DeployCore::isQtLib(i)) {
|
||||
return true;
|
||||
if (QtMajorVersion result = DeployCore::isQtLib(i)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return QtMajorVersion::NoQt;
|
||||
}
|
||||
|
||||
QString LibInfo::fullPath() const {
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
void setQtPath(const QString &value);
|
||||
WinAPI getWinApi() const;
|
||||
void setWinApi(WinAPI winApi);
|
||||
bool isDependetOfQt() const;
|
||||
QtMajorVersion isDependetOfQt() const;
|
||||
};
|
||||
|
||||
uint qHash(const LibInfo& info);
|
||||
|
@ -9,9 +9,20 @@
|
||||
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <quasarapp.h>
|
||||
#include "quasarapp.h"
|
||||
#include "deploycore.h"
|
||||
#include "deployconfig.h"
|
||||
|
||||
QStringList QML::extractImportsFromFile(const QString &filepath) {
|
||||
|
||||
if (DeployCore::_config && DeployCore::_config->qtDir.getQtVersion() == QtMajorVersion::Qt6) {
|
||||
return extractImportsFromFileQt6(filepath);
|
||||
}
|
||||
|
||||
return extractImportsFromFileQt5(filepath);
|
||||
}
|
||||
|
||||
QStringList QML::extractImportsFromFileQt5(const QString &filepath) {
|
||||
QStringList imports;
|
||||
QFile F(filepath);
|
||||
if (!F.open(QIODevice::ReadOnly)) return QStringList();
|
||||
@ -44,6 +55,11 @@ QStringList QML::extractImportsFromFile(const QString &filepath) {
|
||||
return imports;
|
||||
}
|
||||
|
||||
QStringList QML::extractImportsFromFileQt6(const QString &filepath) {
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
bool QML::extractImportsFromDir(const QString &path, bool recursive) {
|
||||
QDir dir(path);
|
||||
|
||||
@ -74,6 +90,14 @@ bool QML::extractImportsFromDir(const QString &path, bool recursive) {
|
||||
}
|
||||
|
||||
QString QML::getPathFromImport(const QString &import, bool checkVersions) {
|
||||
if (DeployCore::_config && DeployCore::_config->qtDir.getQtVersion() == QtMajorVersion::Qt6) {
|
||||
return getPathFromImportQt6(import, checkVersions);
|
||||
}
|
||||
|
||||
return getPathFromImportQt5(import, checkVersions);
|
||||
}
|
||||
|
||||
QString QML::getPathFromImportQt5(const QString &import, bool checkVersions) {
|
||||
auto importData = import.split("#");
|
||||
|
||||
int index;
|
||||
@ -109,6 +133,12 @@ QString QML::getPathFromImport(const QString &import, bool checkVersions) {
|
||||
return info.absoluteFilePath();
|
||||
}
|
||||
|
||||
|
||||
QString QML::getPathFromImportQt6(const QString &import, bool checkVersions) {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
bool QML::deployPath(const QString &path, QStringList &res) {
|
||||
QDir dir(path);
|
||||
auto infoList = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
|
||||
|
@ -14,9 +14,17 @@
|
||||
|
||||
class DEPLOYSHARED_EXPORT QML {
|
||||
private:
|
||||
|
||||
QStringList extractImportsFromFile(const QString &filepath);
|
||||
QStringList extractImportsFromFileQt5(const QString &filepath);
|
||||
QStringList extractImportsFromFileQt6(const QString &filepath);
|
||||
|
||||
bool extractImportsFromDir(const QString &path, bool recursive = false);
|
||||
|
||||
QString getPathFromImport(const QString& import, bool checkVersions = true);
|
||||
QString getPathFromImportQt5(const QString& import, bool checkVersions = true);
|
||||
QString getPathFromImportQt6(const QString& import, bool checkVersions = true);
|
||||
|
||||
bool deployPath( const QString& path, QStringList& res);
|
||||
bool scanQmlTree(const QString& qmlTree);
|
||||
void addImport();
|
||||
|
@ -1,6 +1,14 @@
|
||||
#include "pathutils.h"
|
||||
#include "qtdir.h"
|
||||
|
||||
QtMajorVersion QtDir::getQtVersion() const {
|
||||
return _qtVersion;
|
||||
}
|
||||
|
||||
void QtDir::setQtVersion(const QtMajorVersion &qtVersion) {
|
||||
_qtVersion = qtVersion;
|
||||
}
|
||||
|
||||
QString QtDir::getLibs() const {
|
||||
return libs;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ class DEPLOYSHARED_EXPORT QtDir {
|
||||
|
||||
Platform qtPlatform = UnknownPlatform;
|
||||
|
||||
|
||||
QtMajorVersion _qtVersion;
|
||||
public:
|
||||
QString getLibs() const;
|
||||
void setLibs(const QString &value);
|
||||
@ -41,6 +41,13 @@ public:
|
||||
* @return true if object is qt.
|
||||
*/
|
||||
bool isQt(QString path) const;
|
||||
|
||||
/**
|
||||
* @brief getQtVersion This method return information of version of qt
|
||||
* @return the masjor version of qt
|
||||
*/
|
||||
QtMajorVersion getQtVersion() const;
|
||||
void setQtVersion(const QtMajorVersion &qtVersion);
|
||||
};
|
||||
|
||||
#endif // QTDIR_H
|
||||
|
@ -793,28 +793,28 @@ void deploytest::testCheckQt() {
|
||||
QVERIFY(deployer->prepare());
|
||||
|
||||
|
||||
auto cases = QList<QPair<QString, bool>>{
|
||||
{TestQtDir + "/", false},
|
||||
{TestQtDir + "", false},
|
||||
{TestQtDir + "/bin/file1", false},
|
||||
{TestQtDir + "/lib/file12.so", false},
|
||||
{TestQtDir + "/resurces/file13.dll", false},
|
||||
{TestQtDir + "/libexec/f", false},
|
||||
{TestQtDir + "/mkspecs", false},
|
||||
{TestQtDir + "/qml", false},
|
||||
{TestQtDir + "/plugins", false},
|
||||
{TestQtDir + "/file", false},
|
||||
auto cases = QList<QPair<QString, QtMajorVersion>>{
|
||||
{TestQtDir + "/", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/bin/file1", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/lib/file12.so", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/resurces/file13.dll", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/libexec/f", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/mkspecs", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/qml", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/plugins", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/file", QtMajorVersion::NoQt},
|
||||
|
||||
{TestQtDir + "\\", false},
|
||||
{TestQtDir + "", false},
|
||||
{TestQtDir + "\\bin\\file1", false},
|
||||
{TestQtDir + "\\lib\\file12", false},
|
||||
{TestQtDir + "\\resurces\\file13", false},
|
||||
{TestQtDir + "\\libexec\\f.so", false},
|
||||
{TestQtDir + "\\mkspecs.dll", false},
|
||||
{TestQtDir + "\\qml", false},
|
||||
{TestQtDir + "\\plugins", false},
|
||||
{TestQtDir + "\\file", false},
|
||||
{TestQtDir + "\\", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\bin\\file1", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\lib\\file12", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\resurces\\file13", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\libexec\\f.so", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\mkspecs.dll", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\qml", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\plugins", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\file", QtMajorVersion::NoQt},
|
||||
|
||||
};
|
||||
|
||||
@ -839,30 +839,44 @@ void deploytest::testCheckQt() {
|
||||
QVERIFY(deployer->prepare());
|
||||
|
||||
|
||||
cases = QList<QPair<QString, bool>>{
|
||||
{TestQtDir + "/", false},
|
||||
{TestQtDir + "", false},
|
||||
{TestQtDir + "/bin/file1", false},
|
||||
{TestQtDir + "/lib/file12", false},
|
||||
{TestQtDir + "/bin/file1Qt.so", true},
|
||||
{TestQtDir + "/lib/file12", false},
|
||||
{TestQtDir + "/resources/Qtfile13.so", true},
|
||||
{TestQtDir + "/libexec/Qtf.dll", true},
|
||||
{TestQtDir + "/mkspecs", false},
|
||||
{TestQtDir + "/qml", false},
|
||||
{TestQtDir + "/plugins", false},
|
||||
{TestQtDir + "/file", false},
|
||||
cases = QList<QPair<QString, QtMajorVersion>>{
|
||||
{TestQtDir + "/", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/bin/file1", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/lib/file12", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/lib/file12", QtMajorVersion::NoQt},
|
||||
|
||||
{TestQtDir + "\\", false},
|
||||
{TestQtDir + "", false},
|
||||
{TestQtDir + "\\bin\\Qtfile1.dll", true},
|
||||
{TestQtDir + "\\lib\\file12", false},
|
||||
{TestQtDir + "\\resources\\fileQt13.dll", true},
|
||||
{TestQtDir + "\\libexec\\fQt", false},
|
||||
{TestQtDir + "\\mkspecs", false},
|
||||
{TestQtDir + "\\qml", false},
|
||||
{TestQtDir + "\\plugins", false},
|
||||
{TestQtDir + "\\file", false},
|
||||
{TestQtDir + "/mkspecs", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/qml", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/plugins", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "/file", QtMajorVersion::NoQt},
|
||||
|
||||
{TestQtDir + "\\", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\lib\\file12", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\libexec\\fQt", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\mkspecs", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\qml", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\plugins", QtMajorVersion::NoQt},
|
||||
{TestQtDir + "\\file", QtMajorVersion::NoQt},
|
||||
|
||||
{TestQtDir + "/bin/file1Qt4.so", QtMajorVersion::Qt4},
|
||||
{TestQtDir + "/resources/Qt4file13.so", QtMajorVersion::Qt4},
|
||||
{TestQtDir + "/libexec/Qt4f.dll", QtMajorVersion::Qt4},
|
||||
{TestQtDir + "\\bin\\Qt4file1.dll", QtMajorVersion::Qt4},
|
||||
{TestQtDir + "\\resources\\fileQt413.dll", QtMajorVersion::Qt4},
|
||||
|
||||
{TestQtDir + "/bin/file1Qt5.so", QtMajorVersion::Qt5},
|
||||
{TestQtDir + "/resources/Qt5file13.so", QtMajorVersion::Qt5},
|
||||
{TestQtDir + "/libexec/Qt5f.dll", QtMajorVersion::Qt5},
|
||||
{TestQtDir + "\\bin\\Qt5file1.dll", QtMajorVersion::Qt5},
|
||||
{TestQtDir + "\\resources\\fileQt513.dll", QtMajorVersion::Qt5},
|
||||
|
||||
{TestQtDir + "/bin/file1Qt6.so", QtMajorVersion::Qt6},
|
||||
{TestQtDir + "/resources/Qt6file13.so", QtMajorVersion::Qt6},
|
||||
{TestQtDir + "/libexec/Qt6f.dll", QtMajorVersion::Qt6},
|
||||
{TestQtDir + "\\bin\\Qt6file1.dll", QtMajorVersion::Qt6},
|
||||
{TestQtDir + "\\resources\\fileQt613.dll", QtMajorVersion::Qt6},
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user