From cfe013368d1e56248be991f6ec37980bf5ec33c7 Mon Sep 17 00:00:00 2001 From: EndrII Date: Sat, 18 Aug 2018 22:36:28 +0300 Subject: [PATCH] deploy qml --- CDQ/deploy.cpp | 61 +++++++++++++++++++++++++++++++++++++++----------- CDQ/deploy.h | 1 + CDQ/main.cpp | 11 +++------ 3 files changed, 52 insertions(+), 21 deletions(-) diff --git a/CDQ/deploy.cpp b/CDQ/deploy.cpp index a707510..ad22aad 100644 --- a/CDQ/deploy.cpp +++ b/CDQ/deploy.cpp @@ -83,6 +83,10 @@ void Deploy::deploy() { strip(targetDir + QDir::separator() + "plugins"); } + if (deployQml && !extractQml()) { + qCritical() << "qml not extacted!"; + } + } QString Deploy::getQtDir() const { @@ -266,26 +270,25 @@ bool Deploy::copyFolder( QDir &from, QDir &to, const QString& filter) { return false; } - auto list = from.entryList(); - list.removeAll(".."); - list.removeAll("."); + auto list = from.entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries); + for (auto item : list ) { if (QFileInfo(item).isDir()) { - if (!from.cd(item)) { - qWarning() <<"not open " << from.absolutePath() + QDir::separator() + item; + if (!from.cd(item.baseName())) { + qWarning() <<"not open " << from.absolutePath() + QDir::separator() + item.baseName(); continue; } - if (!QFileInfo::exists(to.absolutePath() + QDir::separator() + item) && - !to.mkdir(item)) { - qWarning() <<"not create " << to.absolutePath() + QDir::separator() + item; + if (!QFileInfo::exists(to.absolutePath() + QDir::separator() + item.baseName()) && + !to.mkdir(item.baseName())) { + qWarning() <<"not create " << to.absolutePath() + QDir::separator() + item.baseName(); continue; } - if (!to.cd(item)) { - qWarning() <<"not open " << to.absolutePath() + QDir::separator() + item; + if (!to.cd(item.baseName())) { + qWarning() <<"not open " << to.absolutePath() + QDir::separator() + item.baseName(); continue; } @@ -295,13 +298,13 @@ bool Deploy::copyFolder( QDir &from, QDir &to, const QString& filter) { } else { - if (!filter.isEmpty() && item.contains(filter)) { + if (!filter.isEmpty() && item.fileName().contains(filter)) { qInfo() << item << " ignored by filter " << filter; continue; } - if (!copyFile(from.absolutePath() + QDir::separator() + item, to.absolutePath())) { - qWarning() <<"not copied file " << to.absolutePath() + QDir::separator() + item; + if (!copyFile(from.absolutePath() + QDir::separator() + item.fileName(), to.absolutePath())) { + qWarning() <<"not copied file " << to.absolutePath() + QDir::separator() + item.fileName(); } } } @@ -309,6 +312,32 @@ bool Deploy::copyFolder( QDir &from, QDir &to, const QString& filter) { return true; } +bool Deploy::extractQml() { + auto qmlDir = QuasarAppUtils::getStrArg("qmlDir"); + + if (!QFileInfo::exists(qmlDir)){ + qWarning() << "qml dir wrong!"; + return false; + } + + QDir dir(qmlDir); + + QDir dirTo(targetDir); + + if (!dirTo.cd("qml")) { + if (!dirTo.mkdir("qml")) { + return false; + } + + if (!dirTo.cd("qml")) { + return false; + } + } + + return copyFolder(dir, dirTo, ".so.debug"); + +} + void Deploy::clear() { QDir dir(targetDir); @@ -322,6 +351,12 @@ void Deploy::clear() { dir.cdUp(); } + + if (dir.cd("qml")) { + dir.removeRecursively(); + dir.cdUp(); + + } } void Deploy::strip(const QString& dir) { diff --git a/CDQ/deploy.h b/CDQ/deploy.h index edc307f..8a9efb7 100644 --- a/CDQ/deploy.h +++ b/CDQ/deploy.h @@ -31,6 +31,7 @@ private: void copyPlugins(const QStringList& list); bool copyFolder(QDir &from, QDir &to, const QString &filter = ""); + bool extractQml(); void strip(const QString &dir); diff --git a/CDQ/main.cpp b/CDQ/main.cpp index 55504f5..6a2e8eb 100644 --- a/CDQ/main.cpp +++ b/CDQ/main.cpp @@ -57,15 +57,10 @@ bool parseQt(Deploy& deploy) { QDir dir(basePath); - if (qmlDir.isEmpty()) { - deploy.setDeployQml(false); + if (QFileInfo::exists(qmlDir)) { + deploy.setDeployQml(true); } else { - auto scaners = dir.entryList(QStringList() << "qmlimportscanner"); - if (!scaners.size()) { - qWarning () << "qmlimportscanner not installed"; - } else { - deploy.setQmlScaner(scaners.first()); - } + qCritical () << "wrong qml dir!"; } if (!dir.cdUp()) {