Skip to content

Commit

Permalink
Merge pull request #557 from QuasarApp/v1.5
Browse files Browse the repository at this point in the history
V1.5
  • Loading branch information
EndrII authored Mar 27, 2021
2 parents 77841c5 + 12e211b commit b0c7b78
Show file tree
Hide file tree
Showing 22 changed files with 386 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Deploy/Deploy.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TEMPLATE = lib

DEFINES += DEPLOY_LIBRARY

VERSION = 1.5.0.25
VERSION = 1.5.0.26

DEFINES += APP_VERSION='\\"$$VERSION\\"'

Expand Down
20 changes: 4 additions & 16 deletions Deploy/configparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,18 +775,6 @@ QSet<QString> ConfigParser::getQtPathesFromTargets() {
return res;
}

QtMajorVersion ConfigParser::isNeededQt() const {

auto Qt = QtMajorVersion::NoQt;
for (const auto &i: _config.targets()) {
if (i.isValid()) {
Qt = Qt | i.isDependetOfQt();
}
}

return Qt;
}

void ConfigParser::setTargetDir(const QString &target) {

if (QuasarAppUtils::Params::isEndable("targetDir")) {
Expand Down Expand Up @@ -1083,7 +1071,7 @@ bool ConfigParser::initQmakePrivate(const QString &qmake) {
bool ConfigParser::initQmake() {


if (!isNeededQt()) {
if (!_config.isNeededQt()) {
QuasarAppUtils::Params::log("deploy only C/C++ libraryes because a qmake is not needed"
" for the distribution",
QuasarAppUtils::Info);
Expand Down Expand Up @@ -1191,7 +1179,7 @@ bool ConfigParser::setQmake(const QString &value) {
}
}

_config.qtDir.setQtVersion(isNeededQt());
_config.qtDir.setQtVersion(_config.isNeededQt());

_config.envirement.addEnv(_config.qtDir.getLibs());
_config.envirement.addEnv(_config.qtDir.getBins());
Expand Down Expand Up @@ -1257,7 +1245,7 @@ bool ConfigParser::setQtDir(const QString &value) {
_config.qtDir.setQtPlatform(Platform::Win);
#endif

_config.qtDir.setQtVersion(isNeededQt());
_config.qtDir.setQtVersion(_config.isNeededQt());

_config.envirement.addEnv(_config.qtDir.getLibs());
_config.envirement.addEnv(_config.qtDir.getBins());
Expand Down Expand Up @@ -1326,7 +1314,7 @@ void ConfigParser::initExtraNames() {
* We need to add to extra names libraries without which qt will not work,
*
*/
if (isNeededQt()) {
if (_config.isNeededQt()) {
auto libs = DeployCore::Qt3rdpartyLibs( _config.getPlatformOfAll());
deployExtraNames(libs);
}
Expand Down
1 change: 0 additions & 1 deletion Deploy/configparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ class DEPLOYSHARED_EXPORT ConfigParser

QList<iDistribution *> getDistribution();

QtMajorVersion isNeededQt() const;
};

#endif // CQT_H
26 changes: 26 additions & 0 deletions Deploy/deployconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,32 @@ QString DeployConfig::getRunScript(const QString &targetName) const {
return _runScripts.value(targetName, "");
}

QtMajorVersion DeployConfig::isNeededQt() const {

auto Qt = QtMajorVersion::NoQt;
for (const auto &i: targets()) {
if (i.isValid()) {
Qt = Qt | i.isDependetOfQt();
}
}

return Qt;
}

QtMajorVersion DeployConfig::isNeededQt(const QString &pacakge) const {
const auto targetsKeys = packages().value(pacakge, DistroModule{""}).targets();

auto Qt = QtMajorVersion::NoQt;
for (const auto &i: targetsKeys) {
auto target = targets().value(i);
if (target.isValid()) {
Qt = Qt | target.isDependetOfQt();
}
}

return Qt;
}

const QHash<QString, TargetInfo> &DeployConfig::targets() const {
return _targets;
}
Expand Down
13 changes: 13 additions & 0 deletions Deploy/deployconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ class DEPLOYSHARED_EXPORT DeployConfig {
void registerRunScript(const QString& targetName, const QString& scriptPath);
QString getRunScript(const QString& targetName) const;

/**
* @brief isNeededQt This method return all needed qt major version for all targets.
* @return qt major version
*/
QtMajorVersion isNeededQt() const;

/**
* @brief isNeededQt This method return all needed qt major versions for the @a pacakge.
* @param pacakge This is validation pacakge.
* @return qt major version
*/
QtMajorVersion isNeededQt(const QString& pacakge) const;

private:

/**
Expand Down
2 changes: 1 addition & 1 deletion Deploy/extracter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ bool Extracter::extractQml() {
continue;
}

QML ownQmlScaner(cnf->qtDir.getQmls());
QML ownQmlScaner(cnf->qtDir.getQmls(), cnf->isNeededQt(i.key()));

if (!ownQmlScaner.scan(plugins, info.absoluteFilePath())) {
QuasarAppUtils::Params::log("qml scaner run failed!",
Expand Down
88 changes: 64 additions & 24 deletions Deploy/qml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,47 @@

#include <QDir>
#include <QFile>
#include <quasarapp.h>
#include <deploycore.h>
#include "quasarapp.h"
#include "deploycore.h"
#include "deployconfig.h"

QStringList QML::extractImportsFromFile(const QString &filepath) {
QStringList QML::extractImportLine(const QString& line) const {
QStringList result;
QStringList list = line.split(" ", splitbehavior);

if (list.count() == 3 || (list.count() == 5 && list[3] == "as")) {
if (list[2] == "auto" || (_qtVersion & QtMajorVersion::Qt6)) {
// qt6
result << (list[1].replace(".", "/"));
return result;
}
// qt5
result << (list[2][0] + "#" + list[1].replace(".", "/"));
} else if (list.count() == 2 || (list.count() == 4 && list[2] == "as")) {
// qt6
result << (list[1].replace(".", "/"));
}

return result;
}

QStringList QML::extractImportsFromFile(const QString &filepath) const {
QStringList imports;
QFile F(filepath);
if (!F.open(QIODevice::ReadOnly)) return QStringList();

QString content = F.readAll();
content.remove(QRegExp("\\{(.*)\\}"));
content.remove(QRegExp("/\\*(.*)\\*/"));

for (const QString &line : content.split("\n"))
const auto list = content.split("\n");
for (const QString &line : list)
for (QString &word : line.split(";", splitbehavior))
{
word = word.simplified();
if (word.startsWith("//")) continue;
if (!word.startsWith("import")) continue;

QStringList list = word.split(" ", splitbehavior);

if (list.count() == 3 || (list.count() == 5 && list[3] == "as")) {
if (list[2] == "auto") {
// qt6
imports << (list[1].replace(".", "/"));
continue;
}
// qt5
imports << (list[2][0] + "#" + list[1].replace(".", "/"));
} else if (list.count() == 2 || (list.count() == 4 && list[2] == "as")) {
// qt6
imports << (list[1].replace(".", "/"));
}
imports += extractImportLine(word);
}

return imports;
Expand All @@ -56,11 +63,24 @@ bool QML::extractImportsFromDir(const QString &path, bool recursive) {
}

auto files = dir.entryInfoList(QStringList() << "*.qml" << "*.QML", QDir::Files);
auto qmlmodule = dir.entryInfoList(QStringList() << "qmldir", QDir::Files);

auto dirs = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Dirs);

for (const auto &info: files) {
auto imports = extractImportsFromFile(info.absoluteFilePath());
for (auto import : imports) {
for (const auto &import : qAsConst(imports)) {
if (!_imports.contains(import)) {
_imports.insert(import);
extractImportsFromDir(getPathFromImport(import), recursive);
}
}
}

for (const auto& module: qAsConst(qmlmodule)) {
QStringList imports = extractImportsFromQmlModule(module.absoluteFilePath());

for (const auto &import : qAsConst(imports)) {
if (!_imports.contains(import)) {
_imports.insert(import);
extractImportsFromDir(getPathFromImport(import), recursive);
Expand Down Expand Up @@ -123,7 +143,7 @@ bool QML::deployPath(const QString &path, QStringList &res) {
QDir dir(path);
auto infoList = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);

for (auto info : infoList) {
for (const auto &info : qAsConst(infoList)) {
if (DeployCore::isDebugFile(info.fileName())) {
QuasarAppUtils::Params::log("sciped debug lib " +
info.absoluteFilePath());
Expand Down Expand Up @@ -156,12 +176,32 @@ bool QML::scanQmlTree(const QString &qmlTree) {
return true;
}

void QML::addImport() {
QStringList QML::extractImportsFromQmlModule(const QString &module) const {
QStringList imports;
QFile F(module);
if (!F.open(QIODevice::ReadOnly)) return QStringList();

QString content = F.readAll();
const auto list = content.split("\n");
for (QString line : list) {
line = line.simplified();
if (line.startsWith("//") || line.startsWith("#")) continue;
if (!line.startsWith("depends")) continue;

QStringList list = line.split(" ", splitbehavior);
imports += extractImportLine(line);
}

return imports;
}

void QML::setQtVersion(const QtMajorVersion &qtVersion) {
_qtVersion = qtVersion;
}

QML::QML(const QString &qmlRoot) {
QML::QML(const QString &qmlRoot, QtMajorVersion qtVersion) {
_qmlRoot = qmlRoot;
setQtVersion(qtVersion);

}

Expand All @@ -175,7 +215,7 @@ bool QML::scan(QStringList &res, const QString& _qmlProjectDir) {
return false;
}

for (const auto &import : _imports) {
for (const auto &import : qAsConst(_imports)) {
res.push_back(getPathFromImport(import));
}

Expand Down
11 changes: 8 additions & 3 deletions Deploy/qml.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,32 @@
#include <QSet>
#include <QStringList>
#include "deploy_global.h"
#include "deploycore.h"

class DEPLOYSHARED_EXPORT QML {
private:

QStringList extractImportsFromFile(const QString &filepath);
QStringList extractImportsFromFile(const QString &filepath) const;

bool extractImportsFromDir(const QString &path, bool recursive = false);

QString getPathFromImport(const QString& import, bool checkVersions = true);

bool deployPath( const QString& path, QStringList& res);
bool scanQmlTree(const QString& qmlTree);
void addImport();
QStringList extractImportsFromQmlModule(const QString& module) const;
QString _qmlRoot = "";
QSet<QString> _imports;
QSet<QString> secondVersions;
QtMajorVersion _qtVersion = QtMajorVersion::Qt5;

QStringList extractImportLine(const QString &line) const;

public:
QML(const QString& qmlRoot);
QML(const QString& qmlRoot, QtMajorVersion isQt6);

bool scan(QStringList &res, const QString &_qmlProjectDir);
void setQtVersion(const QtMajorVersion &qtVersion);

friend class deploytest;
};
Expand Down
2 changes: 1 addition & 1 deletion QIFData/config/configLinux.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<WizardDefaultWidth>640px</WizardDefaultWidth>
<WizardDefaultHeight>400px</WizardDefaultHeight>
<Name>CQtDeployer</Name>
<Version>1.5.0.25</Version>
<Version>1.5.0.26</Version>
<Title>CQtDeployer</Title>
<Publisher>QuasarApp</Publisher>
<StartMenuDir>CQtDeployer</StartMenuDir>
Expand Down
2 changes: 1 addition & 1 deletion QIFData/config/configWin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<WizardDefaultWidth>640px</WizardDefaultWidth>
<WizardDefaultHeight>400px</WizardDefaultHeight>
<Name>CQtDeployer</Name>
<Version>1.5.0.25</Version>
<Version>1.5.0.26</Version>
<Title>CQtDeployer</Title>
<Publisher>QuasarApp</Publisher>
<StartMenuDir>CQtDeployer</StartMenuDir>
Expand Down
2 changes: 1 addition & 1 deletion QIFData/packages/cqtdeployer.1_5/meta/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Package>
<DisplayName>CQtDeployer 1.5 Alpha</DisplayName>
<Description>CQtDeployer 1.5 Alpha. Do not use this version because it is unstable and may lead to unwanted bugs or consequences. Use this version exclusively for testing new functionality.</Description>
<Version>1.5.0.25</Version>
<Version>1.5.0.26</Version>
<Default>true</Default>
<ForcedInstallation>false</ForcedInstallation>
<Script>installscript.js</Script>
Expand Down
2 changes: 2 additions & 0 deletions UnitTests/UnitTests.pro
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ SOURCES += tst_deploytest.cpp \
modulesqt513.cpp \
modulesqt514.cpp \
modulesqt515.cpp \
modulesqt5152.cpp \
qmlcreator.cpp \
testutils.cpp

Expand All @@ -51,6 +52,7 @@ HEADERS += \
modulesqt513.h \
modulesqt514.h \
modulesqt515.h \
modulesqt5152.h \
qmlcreator.h \
testutils.h

6 changes: 5 additions & 1 deletion UnitTests/modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
#include <configparser.h>
#include <QSet>

#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2)
#include "modulesqt5152.h"
class Modules : public ModulesQt5152

#elif QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#include "modulesqt515.h"
class Modules : public ModulesQt515

Expand Down
10 changes: 8 additions & 2 deletions UnitTests/modulesqt513.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,10 @@ QSet<QString> ModulesQt513::qmlVirtualKeyBoadrLibs(const QString &distDir) const
"./" + distDir + "/qml/QtQuick/VirtualKeyboard/Styles/qmldir",
"./" + distDir + "/qml/QtQuick/VirtualKeyboard/libqtquickvirtualkeyboardplugin.so",
"./" + distDir + "/qml/QtQuick/VirtualKeyboard/plugins.qmltypes",
"./" + distDir + "/qml/QtQuick/VirtualKeyboard/qmldir"
"./" + distDir + "/qml/QtQuick/VirtualKeyboard/qmldir",
"./" + distDir + "/qml/Qt/labs/folderlistmodel/libqmlfolderlistmodelplugin.so",
"./" + distDir + "/qml/Qt/labs/folderlistmodel/plugins.qmltypes",
"./" + distDir + "/qml/Qt/labs/folderlistmodel/qmldir"
});
#else
Tree += utils.createTree({
Expand Down Expand Up @@ -1350,7 +1353,10 @@ QSet<QString> ModulesQt513::qmlVirtualKeyBoadrLibs(const QString &distDir) const
"./" + distDir + "/qml/QtQuick/VirtualKeyboard/Styles/qtquickvirtualkeyboardstylesplugin.dll",
"./" + distDir + "/qml/QtQuick/VirtualKeyboard/plugins.qmltypes",
"./" + distDir + "/qml/QtQuick/VirtualKeyboard/qmldir",
"./" + distDir + "/qml/QtQuick/VirtualKeyboard/qtquickvirtualkeyboardplugin.dll"
"./" + distDir + "/qml/QtQuick/VirtualKeyboard/qtquickvirtualkeyboardplugin.dll",
"./" + distDir + "/qml/Qt/labs/folderlistmodel/qmlfolderlistmodelplugin.dll",
"./" + distDir + "/qml/Qt/labs/folderlistmodel/plugins.qmltypes",
"./" + distDir + "/qml/Qt/labs/folderlistmodel/qmldir"
});
#endif
return Tree;
Expand Down
Loading

0 comments on commit b0c7b78

Please sign in to comment.