deploy qml

This commit is contained in:
Andrei Yankovich 2018-08-18 22:36:28 +03:00
parent bea4f46124
commit cfe013368d
3 changed files with 52 additions and 21 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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()) {