mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-05-06 22:49:35 +00:00
added modes
This commit is contained in:
parent
099784b57a
commit
a90b9a10ca
@ -28,30 +28,12 @@ int main(int argc, const char *argv[]) {
|
|||||||
};
|
};
|
||||||
QuasarAppUtils::Params::setEnable("noWriteInFileLog", true);
|
QuasarAppUtils::Params::setEnable("noWriteInFileLog", true);
|
||||||
|
|
||||||
|
|
||||||
if ((QuasarAppUtils::Params::isEndable("v") ||
|
|
||||||
QuasarAppUtils::Params::isEndable("version"))) {
|
|
||||||
DeployUtils::printVersion();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (QuasarAppUtils::Params::isEndable("h") ||
|
|
||||||
QuasarAppUtils::Params::isEndable("help")) {
|
|
||||||
DeployUtils::help();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Deploy deploy;
|
Deploy deploy;
|
||||||
|
|
||||||
if (!DeployUtils::parseQt(&deploy)) {
|
if (!DeployUtils::parseQt(&deploy)) {
|
||||||
qCritical() << "error parse imput data";
|
qCritical() << "error parse imput data";
|
||||||
DeployUtils::help();
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
deploy.deploy();
|
|
||||||
|
|
||||||
qInfo() << "deploy done!";
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,11 @@ PrivateScaner DependenciesScanner::getScaner(const QString &lib) const {
|
|||||||
return PrivateScaner::UNKNOWN;
|
return PrivateScaner::UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMultiMap<libPriority, LibInfo> DependenciesScanner::getLibsFromEnvirement(
|
QMultiMap<LibPriority, LibInfo> DependenciesScanner::getLibsFromEnvirement(
|
||||||
const QString &libName) {
|
const QString &libName) {
|
||||||
|
|
||||||
auto values = _EnvLibs.values(libName.toUpper());
|
auto values = _EnvLibs.values(libName.toUpper());
|
||||||
QMultiMap<libPriority, LibInfo> res;
|
QMultiMap<LibPriority, LibInfo> res;
|
||||||
|
|
||||||
for (auto & lib : values) {
|
for (auto & lib : values) {
|
||||||
LibInfo info;
|
LibInfo info;
|
||||||
|
@ -35,7 +35,7 @@ private:
|
|||||||
|
|
||||||
PrivateScaner getScaner(const QString& lib) const;
|
PrivateScaner getScaner(const QString& lib) const;
|
||||||
|
|
||||||
QMultiMap<libPriority, LibInfo> getLibsFromEnvirement(const QString& libName);
|
QMultiMap<LibPriority, LibInfo> getLibsFromEnvirement(const QString& libName);
|
||||||
bool fillLibInfo(LibInfo& info ,const QString& file);
|
bool fillLibInfo(LibInfo& info ,const QString& file);
|
||||||
|
|
||||||
void recursiveDep(LibInfo& lib, QSet<LibInfo> &res);
|
void recursiveDep(LibInfo& lib, QSet<LibInfo> &res);
|
||||||
|
@ -781,13 +781,13 @@ void Deploy::extractLib(const QString &file, bool isExtractPlugins) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.getPriority() != libPriority::SystemLib && !neadedLibs.contains(line.fullPath())) {
|
if (line.getPriority() != LibPriority::SystemLib && !neadedLibs.contains(line.fullPath())) {
|
||||||
neadedLibs << line.fullPath();
|
neadedLibs << line.fullPath();
|
||||||
if (isExtractPlugins) {
|
if (isExtractPlugins) {
|
||||||
extractPlugins(line.fullPath());
|
extractPlugins(line.fullPath());
|
||||||
}
|
}
|
||||||
} else if (QuasarAppUtils::Params::isEndable("deploySystem") &&
|
} else if (QuasarAppUtils::Params::isEndable("deploySystem") &&
|
||||||
line.getPriority() == libPriority::SystemLib &&
|
line.getPriority() == LibPriority::SystemLib &&
|
||||||
!systemLibs.contains(line.fullPath())) {
|
!systemLibs.contains(line.fullPath())) {
|
||||||
systemLibs << line.fullPath();
|
systemLibs << line.fullPath();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ QtModuleEntry DeployUtils::qtModuleEntries[] = {
|
|||||||
{ QtWebViewModule, "webview", "Qt5WebView", nullptr }
|
{ QtWebViewModule, "webview", "Qt5WebView", nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
libPriority DeployUtils::getLibPriority(const QString &lib) {
|
LibPriority DeployUtils::getLibPriority(const QString &lib) {
|
||||||
|
|
||||||
if (!QFileInfo(lib).isFile()) {
|
if (!QFileInfo(lib).isFile()) {
|
||||||
return NotFile;
|
return NotFile;
|
||||||
@ -96,6 +96,23 @@ void DeployUtils::verboseLog(const QString &str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define C(X) QuasarAppUtils::Params::isEndable(X)
|
||||||
|
RunMode DeployUtils::getMode() {
|
||||||
|
if (C("help") || C("h") || C("v") || C("version")) {
|
||||||
|
return RunMode::Info;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (C("bin") || C("binDir")) {
|
||||||
|
return RunMode::Deploy;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (C("clear") || C("force-clear")) {
|
||||||
|
return RunMode::Clear;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RunMode::Info;
|
||||||
|
}
|
||||||
|
|
||||||
void DeployUtils::help() {
|
void DeployUtils::help() {
|
||||||
|
|
||||||
QStringList help = {
|
QStringList help = {
|
||||||
@ -145,23 +162,53 @@ void DeployUtils::help() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeployUtils::parseQt(Deploy *deploy) {
|
bool DeployUtils::parseQtClearMode(Deploy *deploy) {
|
||||||
|
|
||||||
if (!(QuasarAppUtils::Params::isEndable("bin") ||
|
|
||||||
QuasarAppUtils::Params::isEndable("binDir"))) {
|
|
||||||
qWarning() << "you need to use -bin or -binDir flags";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto bin = QuasarAppUtils::Params::getStrArg("bin").split(',');
|
auto bin = QuasarAppUtils::Params::getStrArg("bin").split(',');
|
||||||
bin.removeAll("");
|
|
||||||
|
|
||||||
if (!deploy->setTargets(bin)) {
|
if (!deploy->setTargets(bin)) {
|
||||||
|
|
||||||
auto binDir = QuasarAppUtils::Params::getStrArg("binDir");
|
auto binDir = QuasarAppUtils::Params::getStrArg("binDir");
|
||||||
|
if (!(deploy->setTargetsRecursive(binDir) || deploy->setTargets({"./"}))) {
|
||||||
|
qCritical() << "setTargetDir fail!";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!deploy->setTargetsRecursive(binDir)) {
|
if (QuasarAppUtils::Params::isEndable("clear") ||
|
||||||
qCritical() << "error init targeet dir";
|
QuasarAppUtils::Params::isEndable("force-clear")) {
|
||||||
|
qInfo() << "clear old data";
|
||||||
|
deploy->clear(QuasarAppUtils::Params::isEndable("force-clear"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeployUtils::parseQtInfoMode() {
|
||||||
|
|
||||||
|
if ((QuasarAppUtils::Params::isEndable("v") ||
|
||||||
|
QuasarAppUtils::Params::isEndable("version"))) {
|
||||||
|
DeployUtils::printVersion();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QuasarAppUtils::Params::isEndable("h") ||
|
||||||
|
QuasarAppUtils::Params::isEndable("help")) {
|
||||||
|
DeployUtils::help();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeployUtils::parseQtDeployMode(Deploy *deploy) {
|
||||||
|
auto bin = QuasarAppUtils::Params::getStrArg("bin").split(',');
|
||||||
|
|
||||||
|
if (!deploy->setTargets(bin)) {
|
||||||
|
|
||||||
|
auto binDir = QuasarAppUtils::Params::getStrArg("binDir");
|
||||||
|
if (!(deploy->setTargetsRecursive(binDir) || deploy->setTargets({"./"}))) {
|
||||||
|
qCritical() << "setTargetDir fail!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,9 +291,51 @@ bool DeployUtils::parseQt(Deploy *deploy) {
|
|||||||
|
|
||||||
deploy->setQtDir(dir.absolutePath());
|
deploy->setQtDir(dir.absolutePath());
|
||||||
|
|
||||||
|
deploy->deploy();
|
||||||
|
qInfo() << "deploy done!";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DeployUtils::parseQt(Deploy *deploy) {
|
||||||
|
switch (getMode()) {
|
||||||
|
case RunMode::Info: {
|
||||||
|
qInfo() << "selected info mode" ;
|
||||||
|
|
||||||
|
if (!parseQtInfoMode()) {
|
||||||
|
qCritical() << "info mode fail!";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case RunMode::Clear: {
|
||||||
|
qInfo() << "selected clear mode" ;
|
||||||
|
|
||||||
|
if (!parseQtClearMode(deploy)) {
|
||||||
|
qCritical() << "clear mode fail!";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
case RunMode::Deploy: {
|
||||||
|
qInfo() << "selected deploy mode" ;
|
||||||
|
|
||||||
|
if (!parseQtDeployMode(deploy)) {
|
||||||
|
qCritical() << "deploy mode fail!";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList DeployUtils::extractTranslation(const QStringList &libs) {
|
QStringList DeployUtils::extractTranslation(const QStringList &libs) {
|
||||||
QSet<QString> res;
|
QSet<QString> res;
|
||||||
const size_t qtModulesCount = sizeof(qtModuleEntries) / sizeof(QtModuleEntry);
|
const size_t qtModulesCount = sizeof(qtModuleEntries) / sizeof(QtModuleEntry);
|
||||||
|
@ -38,13 +38,19 @@ enum Platform {
|
|||||||
Unix64
|
Unix64
|
||||||
};
|
};
|
||||||
|
|
||||||
enum libPriority : int {
|
enum LibPriority : int {
|
||||||
QtLib = 0x0,
|
QtLib = 0x0,
|
||||||
ExtraLib,
|
ExtraLib,
|
||||||
SystemLib,
|
SystemLib,
|
||||||
NotFile = 0xF,
|
NotFile = 0xF,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class RunMode: int {
|
||||||
|
Info,
|
||||||
|
Deploy,
|
||||||
|
Clear
|
||||||
|
};
|
||||||
|
|
||||||
class Deploy;
|
class Deploy;
|
||||||
|
|
||||||
class DEPLOYSHARED_EXPORT DeployUtils
|
class DEPLOYSHARED_EXPORT DeployUtils
|
||||||
@ -54,6 +60,9 @@ private:
|
|||||||
static QString getMSVCName(MSVCVersion msvc);
|
static QString getMSVCName(MSVCVersion msvc);
|
||||||
static QString getMSVCVersion(MSVCVersion msvc);
|
static QString getMSVCVersion(MSVCVersion msvc);
|
||||||
|
|
||||||
|
static bool parseQtDeployMode(Deploy *deploy);
|
||||||
|
static bool parseQtInfoMode();
|
||||||
|
static bool parseQtClearMode(Deploy *deploy);
|
||||||
public:
|
public:
|
||||||
enum QtModule : quint64
|
enum QtModule : quint64
|
||||||
{
|
{
|
||||||
@ -122,8 +131,9 @@ public:
|
|||||||
|
|
||||||
static bool isQtLib(const QString &lib);
|
static bool isQtLib(const QString &lib);
|
||||||
static bool isExtraLib(const QString &lib);
|
static bool isExtraLib(const QString &lib);
|
||||||
static libPriority getLibPriority(const QString &lib);
|
static LibPriority getLibPriority(const QString &lib);
|
||||||
static void verboseLog(const QString &str);
|
static void verboseLog(const QString &str);
|
||||||
|
static RunMode getMode();
|
||||||
static void help();
|
static void help();
|
||||||
static bool parseQt(Deploy *deploy);
|
static bool parseQt(Deploy *deploy);
|
||||||
static QStringList extractTranslation(const QStringList& libs);
|
static QStringList extractTranslation(const QStringList& libs);
|
||||||
|
@ -64,11 +64,11 @@ void LibInfo::setDependncies(const QSet<QString> &value) {
|
|||||||
dependncies = value;
|
dependncies = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
libPriority LibInfo::getPriority() const {
|
LibPriority LibInfo::getPriority() const {
|
||||||
return priority;
|
return priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibInfo::setPriority(const libPriority &value) {
|
void LibInfo::setPriority(const LibPriority &value) {
|
||||||
priority = value;
|
priority = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ private:
|
|||||||
QString name;
|
QString name;
|
||||||
QString path;
|
QString path;
|
||||||
QSet<QString> dependncies;
|
QSet<QString> dependncies;
|
||||||
libPriority priority = NotFile;
|
LibPriority priority = NotFile;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -40,8 +40,8 @@ public:
|
|||||||
void addDependncies(const QString &value);
|
void addDependncies(const QString &value);
|
||||||
void removeDependncies(const QString &value);
|
void removeDependncies(const QString &value);
|
||||||
|
|
||||||
libPriority getPriority() const;
|
LibPriority getPriority() const;
|
||||||
void setPriority(const libPriority &value);
|
void setPriority(const LibPriority &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
uint qHash(const LibInfo& info);
|
uint qHash(const LibInfo& info);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user