2018-08-19 11:00:13 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 QuasarApp.
|
|
|
|
* Distributed under the lgplv3 software license, see the accompanying
|
|
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
|
|
* of this license document, but changing it is not allowed.
|
|
|
|
*/
|
|
|
|
|
2018-08-17 20:47:49 +03:00
|
|
|
#include "deploy.h"
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
|
|
|
#include <quasarapp.h>
|
|
|
|
#include <QProcess>
|
2018-08-23 21:28:47 +03:00
|
|
|
#include <QDirIterator>
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonArray>
|
2018-08-17 20:47:49 +03:00
|
|
|
|
|
|
|
|
|
|
|
bool Deploy::getDeployQml() const {
|
|
|
|
return deployQml;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Deploy::setDeployQml(bool value) {
|
|
|
|
deployQml = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Deploy::getQmlScaner() const {
|
|
|
|
return qmlScaner;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Deploy::setQmlScaner(const QString &value) {
|
|
|
|
qmlScaner = value;
|
|
|
|
deployQml = QFileInfo(qmlScaner).isFile();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Deploy::getQmake() const {
|
|
|
|
return qmake;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Deploy::setQmake(const QString &value) {
|
|
|
|
qmake = value;
|
2018-08-23 21:28:47 +03:00
|
|
|
|
|
|
|
QFileInfo info(qmake);
|
|
|
|
QDir dir = info.absoluteDir();
|
|
|
|
|
|
|
|
if (!dir.cdUp() || !dir.cd("qml")) {
|
|
|
|
qWarning() << "get qml fail!";
|
|
|
|
}
|
|
|
|
|
|
|
|
qmlDir = dir.absolutePath();
|
2018-08-17 20:47:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Deploy::getTarget() const {
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
2018-08-24 16:18:37 +03:00
|
|
|
bool Deploy::initDirs() {
|
2018-08-17 20:47:49 +03:00
|
|
|
|
2018-08-17 23:54:29 +03:00
|
|
|
if (!QFileInfo::exists(targetDir + QDir::separator() + "lib") &&
|
|
|
|
!QDir(targetDir).mkdir("lib")) {
|
2018-08-17 20:47:49 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QuasarAppUtils::isEndable("qmlDir") &&
|
2018-08-17 23:54:29 +03:00
|
|
|
!QFileInfo::exists(targetDir + QDir::separator() + "qml") &&
|
2018-08-17 20:47:49 +03:00
|
|
|
!QDir(targetDir).mkdir("qml")){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-08-24 16:18:37 +03:00
|
|
|
bool Deploy::setTarget(const QString &value) {
|
|
|
|
target = value;
|
|
|
|
|
|
|
|
if (target.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
targetDir = QFileInfo(target).absolutePath();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-08-19 11:00:13 +03:00
|
|
|
bool Deploy::createRunScript() {
|
|
|
|
|
|
|
|
QString content =
|
|
|
|
"#!/bin/sh\n"
|
|
|
|
"BASEDIR=$(dirname $0)\n"
|
2018-08-22 19:06:15 +03:00
|
|
|
"export LD_LIBRARY_PATH=$BASEDIR/lib:$BASEDIR:$LD_LIBRARY_PATH\n"
|
|
|
|
"export QML_IMPORT_PATH=$BASEDIR/qml:QML_IMPORT_PATH\n"
|
|
|
|
"export QML2_IMPORT_PATH=$BASEDIR/qml:QML2_IMPORT_PATH\n"
|
|
|
|
"export QT_PLUGIN_PATH=$BASEDIR/plugins:QT_PLUGIN_PATH\n"
|
|
|
|
"export QT_QPA_PLATFORM_PLUGIN_PATH=$BASEDIR/plugins/platforms:QT_QPA_PLATFORM_PLUGIN_PATH\n"
|
|
|
|
"$BASEDIR/%1";
|
2018-08-19 11:00:13 +03:00
|
|
|
|
|
|
|
content = content.arg(QFileInfo(target).fileName());
|
|
|
|
|
2018-08-22 19:11:57 +03:00
|
|
|
QString fname = targetDir + QDir::separator();
|
|
|
|
if (QuasarAppUtils::isEndable("runScript")) {
|
|
|
|
fname += QuasarAppUtils::getStrArg("runScript");
|
|
|
|
} else {
|
|
|
|
fname += "AppRun.sh";
|
|
|
|
}
|
2018-08-19 11:00:13 +03:00
|
|
|
|
|
|
|
QFile F(fname);
|
|
|
|
if (!F.open(QIODevice::WriteOnly)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
F.write(content.toUtf8());
|
|
|
|
F.flush();
|
|
|
|
F.close();
|
|
|
|
|
|
|
|
return F.setPermissions(QFileDevice::ExeUser |
|
|
|
|
QFileDevice::WriteUser |
|
|
|
|
QFileDevice::ReadUser);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-08-17 20:47:49 +03:00
|
|
|
void Deploy::deploy() {
|
|
|
|
qInfo() << "target deploy started!!";
|
2018-08-18 18:37:33 +03:00
|
|
|
|
|
|
|
if (QuasarAppUtils::isEndable("ignoreCudaLib")) {
|
|
|
|
ignoreList << "libicudata" << "libicui" << "libicuuc";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (QuasarAppUtils::isEndable("ignore")) {
|
|
|
|
auto list = QuasarAppUtils::getStrArg("ignore").split(',');
|
|
|
|
ignoreList.append(list);
|
|
|
|
}
|
|
|
|
|
2018-08-17 20:47:49 +03:00
|
|
|
extract(target);
|
2018-08-19 17:06:29 +03:00
|
|
|
copyPlugins(neededPlugins);
|
|
|
|
|
|
|
|
if (deployQml && !extractQml()) {
|
|
|
|
qCritical() << "qml not extacted!";
|
|
|
|
}
|
|
|
|
|
2018-08-17 20:47:49 +03:00
|
|
|
copyFiles(QtLibs, targetDir + QDir::separator() + "lib");
|
|
|
|
|
|
|
|
if (QuasarAppUtils::isEndable("deploy-not-qt")) {
|
|
|
|
copyFiles(noQTLibs, targetDir + QDir::separator() + "lib");
|
|
|
|
}
|
|
|
|
|
2018-08-17 23:54:29 +03:00
|
|
|
if (!QuasarAppUtils::isEndable("noStrip")) {
|
|
|
|
strip(targetDir + QDir::separator() + "lib");
|
|
|
|
}
|
|
|
|
|
2018-08-18 18:37:33 +03:00
|
|
|
|
|
|
|
if (!QuasarAppUtils::isEndable("noStrip")) {
|
|
|
|
strip(targetDir + QDir::separator() + "plugins");
|
|
|
|
}
|
|
|
|
|
2018-08-19 11:00:13 +03:00
|
|
|
if (!createRunScript()) {
|
|
|
|
qCritical() << "run script not created!";
|
|
|
|
}
|
|
|
|
|
2018-08-17 20:47:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
QString Deploy::getQtDir() const {
|
|
|
|
return qtDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Deploy::setQtDir(const QString &value) {
|
|
|
|
qtDir = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Deploy::isQtLib(const QString &lib) const {
|
|
|
|
QFileInfo info(lib);
|
2018-08-17 23:54:29 +03:00
|
|
|
return info.absolutePath().contains(qtDir);
|
2018-08-17 20:47:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Deploy::copyFiles(const QStringList &files , const QString& target) {
|
|
|
|
for (auto file : files) {
|
2018-08-19 11:00:13 +03:00
|
|
|
if (QFileInfo(file).absolutePath() != targetDir && !copyFile(file, target)) {
|
2018-08-17 20:47:49 +03:00
|
|
|
qWarning() << file + " not copied";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Deploy::copyFile(const QString &file, const QString& target) {
|
|
|
|
|
|
|
|
auto info = QFileInfo(file);
|
|
|
|
|
2018-08-18 18:37:33 +03:00
|
|
|
auto name = info.fileName();
|
2018-08-17 23:54:29 +03:00
|
|
|
info.setFile(target + QDir::separator() + name);
|
2018-08-17 20:47:49 +03:00
|
|
|
|
|
|
|
if (QuasarAppUtils::isEndable("always-overwrite") &&
|
2018-08-17 23:54:29 +03:00
|
|
|
info.exists() && !QFile::remove(target + QDir::separator() + name)){
|
2018-08-17 20:47:49 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
qInfo() << "copy :" << target + QDir::separator() + name;
|
|
|
|
|
|
|
|
return QFile::copy(file, target + QDir::separator() + name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-08-19 17:06:29 +03:00
|
|
|
void Deploy::extract(const QString &file, bool isExtractPlugins) {
|
2018-08-17 20:47:49 +03:00
|
|
|
|
|
|
|
qInfo() << "extract lib :" << file;
|
|
|
|
|
|
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
2018-08-19 17:06:29 +03:00
|
|
|
env.insert("LD_LIBRARY_PATH", qtDir + "/lib:" + targetDir);
|
2018-08-17 20:47:49 +03:00
|
|
|
env.insert("QML_IMPORT_PATH", qtDir + "/qml");
|
|
|
|
env.insert("QML2_IMPORT_PATH", qtDir + "/qml");
|
|
|
|
env.insert("QT_PLUGIN_PATH", qtDir + "/plugins");
|
|
|
|
env.insert("QT_QPA_PLATFORM_PLUGIN_PATH", qtDir + "/plugins/platforms");
|
|
|
|
|
|
|
|
QProcess P;
|
|
|
|
P.setProcessEnvironment(env);
|
|
|
|
P.start("ldd " + file, QProcess::ReadOnly);
|
|
|
|
|
|
|
|
if (!P.waitForStarted()) return;
|
|
|
|
if (!P.waitForFinished()) return;
|
|
|
|
|
|
|
|
auto data = QString(P.readAll());
|
|
|
|
QStringList libs;
|
|
|
|
|
|
|
|
for (QString &line : data.split("\n", QString::SkipEmptyParts)) {
|
|
|
|
line = line.simplified();
|
|
|
|
auto innerlist = line.split(" ");
|
|
|
|
|
|
|
|
if (innerlist.count() < 3) continue;
|
|
|
|
line = innerlist[2];
|
|
|
|
|
|
|
|
if (!line.startsWith("/")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-08-18 18:37:33 +03:00
|
|
|
bool isIgnore = false;
|
|
|
|
for (auto ignore: ignoreList) {
|
|
|
|
if (line.contains(ignore)) {
|
|
|
|
qInfo() << line << " ignored by filter" << ignore;
|
|
|
|
isIgnore = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isIgnore) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-08-17 20:47:49 +03:00
|
|
|
if (isQtLib(line) && !QtLibs.contains(line)) {
|
|
|
|
QtLibs << line;
|
2018-08-19 17:06:29 +03:00
|
|
|
extract(line, isExtractPlugins);
|
|
|
|
if (isExtractPlugins) {
|
|
|
|
extractPlugins(line);
|
|
|
|
}
|
2018-08-17 23:54:29 +03:00
|
|
|
continue;
|
2018-08-17 20:47:49 +03:00
|
|
|
}
|
|
|
|
|
2018-08-17 23:54:29 +03:00
|
|
|
if (QuasarAppUtils::isEndable("deploy-not-qt") &&
|
|
|
|
!noQTLibs.contains(line)) {
|
2018-08-17 20:47:49 +03:00
|
|
|
noQTLibs << line;
|
2018-08-19 17:06:29 +03:00
|
|
|
extract(line, isExtractPlugins);
|
2018-08-17 20:47:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-18 18:37:33 +03:00
|
|
|
void Deploy::extractPlugins(const QString &lib) {
|
|
|
|
|
|
|
|
qInfo() << "extrac plugin for " << lib;
|
|
|
|
|
2018-08-19 17:06:29 +03:00
|
|
|
if (lib.contains("libQt5Gui") && !neededPlugins.contains("imageformats")) {
|
2018-08-18 18:37:33 +03:00
|
|
|
neededPlugins << "imageformats"
|
2018-08-19 17:06:29 +03:00
|
|
|
<< "iconengines"
|
|
|
|
<< "xcbglintegrations"
|
|
|
|
<< "platforms";
|
2018-08-18 18:37:33 +03:00
|
|
|
} else if (lib.contains("libQt5Sql") && !neededPlugins.contains("sqldrivers")) {
|
|
|
|
neededPlugins << "sqldrivers";
|
|
|
|
} else if (lib.contains("libQt5Gamepad") && !neededPlugins.contains("gamepads")) {
|
|
|
|
neededPlugins << "gamepads";
|
|
|
|
} else if (lib.contains("libQt5PrintSupport") && !neededPlugins.contains("printsupport")) {
|
|
|
|
neededPlugins << "printsupport";
|
|
|
|
} else if (lib.contains("libQt5Sensors") && !neededPlugins.contains("sensors")) {
|
|
|
|
neededPlugins << "sensors"
|
|
|
|
<< "sensorgestures";
|
|
|
|
} else if (lib.contains("libQt5Positioning") && !neededPlugins.contains("geoservices")) {
|
|
|
|
neededPlugins << "geoservices"
|
|
|
|
<< "position"
|
|
|
|
<< "geometryloaders";
|
|
|
|
} else if (lib.contains("libQt5Multimedia") && !neededPlugins.contains("audio")) {
|
|
|
|
neededPlugins << "audio"
|
|
|
|
<< "mediaservice"
|
|
|
|
<< "playlistformats";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Deploy::copyPlugin(const QString &plugin) {
|
|
|
|
QDir dir(qtDir);
|
|
|
|
if (!dir.cd("plugins")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dir.cd(plugin)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDir dirTo(targetDir);
|
|
|
|
|
|
|
|
if (!dirTo.cd("plugins")) {
|
|
|
|
if (!dirTo.mkdir("plugins")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dirTo.cd("plugins")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dirTo.cd(plugin)) {
|
|
|
|
if (!dirTo.mkdir(plugin)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dirTo.cd(plugin)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 17:06:29 +03:00
|
|
|
QStringList listItems;
|
|
|
|
|
|
|
|
if (!copyFolder(dir, dirTo, ".so.debug", &listItems)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto item : listItems) {
|
|
|
|
extract(item, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2018-08-18 18:37:33 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Deploy::copyPlugins(const QStringList &list) {
|
|
|
|
for (auto plugin : list) {
|
|
|
|
if ( !copyPlugin(plugin)) {
|
|
|
|
qWarning () << plugin << " not copied!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 17:06:29 +03:00
|
|
|
bool Deploy::copyFolder( QDir &from, QDir &to, const QString& filter,
|
|
|
|
QStringList* listOfCopiedItems) {
|
2018-08-18 18:37:33 +03:00
|
|
|
|
|
|
|
if (!(from.isReadable() && to.isReadable())){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-18 22:36:28 +03:00
|
|
|
auto list = from.entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries);
|
|
|
|
|
2018-08-18 18:37:33 +03:00
|
|
|
|
|
|
|
for (auto item : list ) {
|
|
|
|
if (QFileInfo(item).isDir()) {
|
|
|
|
|
2018-08-23 18:54:57 +03:00
|
|
|
if (!from.cd(item.fileName())) {
|
|
|
|
qWarning() <<"not open " << from.absolutePath() + QDir::separator() + item.fileName();
|
2018-08-18 18:37:33 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-08-23 18:54:57 +03:00
|
|
|
if (!QFileInfo::exists(to.absolutePath() + QDir::separator() + item.fileName()) &&
|
|
|
|
!to.mkdir(item.fileName())) {
|
|
|
|
qWarning() <<"not create " << to.absolutePath() + QDir::separator() + item.fileName();
|
2018-08-18 18:37:33 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-08-23 18:54:57 +03:00
|
|
|
if (!to.cd(item.fileName())) {
|
|
|
|
qWarning() <<"not open " << to.absolutePath() + QDir::separator() + item.fileName();
|
2018-08-18 18:37:33 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-08-19 17:06:29 +03:00
|
|
|
copyFolder(from, to, filter, listOfCopiedItems);
|
2018-08-18 18:37:33 +03:00
|
|
|
from.cdUp();
|
|
|
|
to.cdUp();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2018-08-18 22:36:28 +03:00
|
|
|
if (!filter.isEmpty() && item.fileName().contains(filter)) {
|
2018-08-18 18:37:33 +03:00
|
|
|
qInfo() << item << " ignored by filter " << filter;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-08-18 22:36:28 +03:00
|
|
|
if (!copyFile(from.absolutePath() + QDir::separator() + item.fileName(), to.absolutePath())) {
|
|
|
|
qWarning() <<"not copied file " << to.absolutePath() + QDir::separator() + item.fileName();
|
2018-08-18 18:37:33 +03:00
|
|
|
}
|
2018-08-19 17:06:29 +03:00
|
|
|
|
|
|
|
if (listOfCopiedItems) {
|
|
|
|
*listOfCopiedItems << to.absolutePath() + QDir::separator() + item.fileName();
|
|
|
|
}
|
|
|
|
|
2018-08-18 18:37:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-08-23 21:28:47 +03:00
|
|
|
QStringList Deploy::findFilesInsideDir(const QString &name,
|
|
|
|
const QString &dirpath) {
|
|
|
|
QStringList files;
|
2018-08-18 22:36:28 +03:00
|
|
|
|
2018-08-23 21:28:47 +03:00
|
|
|
QDir dir(dirpath);
|
|
|
|
dir.setNameFilters(QStringList(name));
|
|
|
|
|
|
|
|
QDirIterator it(dir, QDirIterator::Subdirectories);
|
|
|
|
while (it.hasNext()) files << it.next();
|
|
|
|
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
2018-08-24 16:18:37 +03:00
|
|
|
QString Deploy::filterQmlPath(const QString& path) {
|
|
|
|
if (path.contains(qmlDir)) {
|
|
|
|
auto endIndex = path.indexOf(QDir::separator(), qmlDir.size() + 1);
|
|
|
|
QString module = path.mid(qmlDir.size() + 1, endIndex - qmlDir.size() - 1);
|
|
|
|
return qmlDir + QDir::separator() + module;
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2018-08-23 21:28:47 +03:00
|
|
|
QStringList Deploy::extractImportsFromFiles(const QStringList &filepath){
|
|
|
|
QProcess p;
|
|
|
|
p.setProgram(qmlScaner);
|
|
|
|
p.setArguments(QStringList () << "-qmlFiles" << filepath
|
|
|
|
<< "-importPath" << qmlDir);
|
|
|
|
p.start();
|
|
|
|
|
|
|
|
qInfo() << "run extract qml";
|
|
|
|
|
|
|
|
if (!p.waitForFinished()) {
|
|
|
|
qWarning() << filepath << " not scaning!";
|
|
|
|
return QStringList();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto data = QJsonDocument::fromJson(p.readAll());
|
|
|
|
|
|
|
|
if (!data.isArray()) {
|
|
|
|
qWarning() << "wrong data from qml scaner! of " << filepath;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto array = data.array();
|
|
|
|
|
|
|
|
QStringList result;
|
|
|
|
|
|
|
|
for (auto object : array) {
|
2018-08-24 16:18:37 +03:00
|
|
|
|
|
|
|
auto module = filterQmlPath(object.toObject().value("path").toString());
|
|
|
|
|
|
|
|
if (module.isEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!result.contains(module)) {
|
|
|
|
result << module;
|
|
|
|
}
|
2018-08-18 22:36:28 +03:00
|
|
|
}
|
|
|
|
|
2018-08-23 21:28:47 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList Deploy::extractImportsFromDir(const QString &dirpath) {
|
|
|
|
auto files = findFilesInsideDir("*.qml", dirpath);
|
|
|
|
|
|
|
|
QStringList result;
|
2018-08-24 16:18:37 +03:00
|
|
|
result.append(extractImportsFromFiles(files));
|
2018-08-23 21:28:47 +03:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-08-24 16:18:37 +03:00
|
|
|
bool Deploy::extractQmlAll() {
|
|
|
|
|
|
|
|
if (!QFileInfo::exists(qmlDir)){
|
|
|
|
qWarning() << "qml dir wrong!";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDir dir(qmlDir);
|
2018-08-18 22:36:28 +03:00
|
|
|
|
|
|
|
QDir dirTo(targetDir);
|
|
|
|
|
|
|
|
if (!dirTo.cd("qml")) {
|
|
|
|
if (!dirTo.mkdir("qml")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dirTo.cd("qml")) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-19 17:06:29 +03:00
|
|
|
|
2018-08-24 16:18:37 +03:00
|
|
|
QStringList listItems;
|
|
|
|
|
|
|
|
if (!copyFolder(dir, dirTo, ".so.debug", &listItems)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto item : listItems) {
|
|
|
|
extract(item, false);
|
|
|
|
}
|
2018-08-19 17:06:29 +03:00
|
|
|
|
2018-08-24 16:18:37 +03:00
|
|
|
return true;
|
|
|
|
}
|
2018-08-23 21:28:47 +03:00
|
|
|
|
2018-08-24 16:18:37 +03:00
|
|
|
bool Deploy::extractQmlFromSource(const QString sourceDir) {
|
|
|
|
qInfo() << "run extract qml";
|
|
|
|
QDir dirTo(targetDir);
|
2018-08-19 17:06:29 +03:00
|
|
|
|
2018-08-24 16:18:37 +03:00
|
|
|
if (!dirTo.cd("qml")) {
|
|
|
|
if (!dirTo.mkdir("qml")) {
|
2018-08-23 21:28:47 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-08-24 16:18:37 +03:00
|
|
|
if (!dirTo.cd("qml")) {
|
|
|
|
return false;
|
2018-08-23 21:28:47 +03:00
|
|
|
}
|
|
|
|
}
|
2018-08-19 17:06:29 +03:00
|
|
|
|
2018-08-24 16:18:37 +03:00
|
|
|
QStringList plugins = extractImportsFromDir(sourceDir);
|
|
|
|
|
|
|
|
for (auto plugin : plugins) {
|
|
|
|
|
|
|
|
QDir dir(plugin);
|
|
|
|
QStringList listItems;
|
|
|
|
|
|
|
|
if (!dirTo.cd(dir.dirName())) {
|
|
|
|
if (!dirTo.mkdir(dir.dirName())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dirTo.cd(dir.dirName())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!copyFolder(dir, dirTo, ".so.debug", &listItems)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
dirTo.cdUp();
|
|
|
|
|
|
|
|
for (auto item : listItems) {
|
|
|
|
extract(item, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Deploy::extractQml() {
|
|
|
|
|
|
|
|
if (QuasarAppUtils::isEndable("qmlDir")) {
|
|
|
|
return extractQmlFromSource(QuasarAppUtils::getStrArg("qmlDir"));
|
|
|
|
|
|
|
|
} else if (QuasarAppUtils::isEndable("allQmlDependes")){
|
|
|
|
return extractQmlAll();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2018-08-18 22:36:28 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-08-18 19:02:07 +03:00
|
|
|
void Deploy::clear() {
|
2018-08-24 16:18:37 +03:00
|
|
|
|
2018-08-18 19:02:07 +03:00
|
|
|
QDir dir(targetDir);
|
|
|
|
|
|
|
|
if (dir.cd("lib")) {
|
|
|
|
dir.removeRecursively();
|
|
|
|
dir.cdUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir.cd("plugins")) {
|
|
|
|
dir.removeRecursively();
|
|
|
|
dir.cdUp();
|
|
|
|
|
|
|
|
}
|
2018-08-18 22:36:28 +03:00
|
|
|
|
|
|
|
if (dir.cd("qml")) {
|
|
|
|
dir.removeRecursively();
|
|
|
|
dir.cdUp();
|
|
|
|
|
|
|
|
}
|
2018-08-18 19:02:07 +03:00
|
|
|
}
|
|
|
|
|
2018-08-17 23:54:29 +03:00
|
|
|
void Deploy::strip(const QString& dir) {
|
|
|
|
QProcess P;
|
|
|
|
|
|
|
|
P.setWorkingDirectory(dir);
|
|
|
|
P.setArguments(QStringList() << "*");
|
|
|
|
P.start("strip", QProcess::ReadOnly);
|
|
|
|
|
|
|
|
|
|
|
|
if (!P.waitForStarted()) return;
|
|
|
|
if (!P.waitForFinished()) return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-08-17 20:47:49 +03:00
|
|
|
Deploy::Deploy(){
|
|
|
|
|
|
|
|
}
|