CQtDeployer/CDQ/main.cpp

105 lines
2.6 KiB
C++
Raw Normal View History

2018-08-17 20:47:49 +03:00
#include <QCoreApplication>
#include "quasarapp.h"
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include "deploy.h"
#include <QList>
void help() {
qInfo() << "";
qInfo() << "Usage: CDQ <app-binary> [options]";
qInfo() << "";
qInfo() << "Options:";
qInfo() << " help / h : show help.";
qInfo() << " always-overwrite : Copy files even if the target file exists.";
2018-08-17 23:54:29 +03:00
qInfo() << " -bin [params] : deployment binry.";
qInfo() << " -qmlDir [params] : qml datadir. for example -qmlDir ~/Qt/5.11.1/gcc_64/qml";
qInfo() << " noStrip : no strip deployed lib";
qInfo() << " deploy-not-qt : deploy all libs";
2018-08-17 23:54:29 +03:00
qInfo() << " -qmake [params] : qmake path. for example";
qInfo() << " | for example -qmake ~/Qt/5.11.1/gcc_64/bin/qmake";
qInfo() << " ignoreCudaLib : it filter ignore cuda lib of nvidea";
qInfo() << " -ignore [list,params] : ignore filter for libs";
qInfo() << " | for example -ignore libicudata.so.56,libicudata2.so.56";
2018-08-18 19:02:07 +03:00
qInfo() << " clear : delete all old deploy data";
2018-08-17 20:47:49 +03:00
}
bool parseQt(Deploy& deploy) {
auto qmake = QuasarAppUtils::getStrArg("qmake");
QString basePath = "";
QFileInfo info(qmake);
if (!info.isFile() || (info.baseName() != "qmake")) {
return false;
}
2018-08-17 23:54:29 +03:00
basePath = info.absolutePath();
2018-08-17 20:47:49 +03:00
deploy.setQmake(qmake);
auto bin = QuasarAppUtils::getStrArg("bin");
info.setFile(bin);
if (!info.isFile()) {
return false;
}
2018-08-18 19:02:07 +03:00
if (QuasarAppUtils::isEndable("clear")) {
qInfo() << "clear old data";
deploy.clear();
}
2018-08-17 20:47:49 +03:00
if (!deploy.setTarget(bin)) {
qCritical() << "error init targeet dir";
return false;
}
auto qmlDir = QuasarAppUtils::getStrArg("qmlDir");
QDir dir(basePath);
2018-08-18 22:36:28 +03:00
if (QFileInfo::exists(qmlDir)) {
deploy.setDeployQml(true);
2018-08-17 20:47:49 +03:00
} else {
2018-08-18 22:36:28 +03:00
qCritical () << "wrong qml dir!";
2018-08-17 20:47:49 +03:00
}
if (!dir.cdUp()) {
return false;
}
2018-08-17 23:54:29 +03:00
deploy.setQtDir(dir.absolutePath());
2018-08-17 20:47:49 +03:00
return true;
}
int main(int argc, char *argv[])
{
if (!QuasarAppUtils::parseParams(argc, argv)) {
qWarning() << "wrong parametrs";
help();
exit(0);
};
if (QuasarAppUtils::isEndable("h") ||
QuasarAppUtils::isEndable("help")) {
help();
exit(0);
}
Deploy deploy;
if (!parseQt(deploy)) {
qCritical() << "qt parse error";
help();
exit(1);
}
deploy.deploy();
2018-08-17 23:54:29 +03:00
qInfo() << "deploy done!";
return 0;
2018-08-17 20:47:49 +03:00
}