2019-08-25 12:06:01 +03:00
|
|
|
#include "distrostruct.h"
|
2019-08-26 17:05:18 +03:00
|
|
|
#include <quasarapp.h>
|
2019-08-25 12:06:01 +03:00
|
|
|
|
2019-08-25 12:35:31 +03:00
|
|
|
#include <QRegExp>
|
|
|
|
|
2019-08-25 12:06:01 +03:00
|
|
|
//#
|
|
|
|
//# Copyright (C) 2018-2019 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.
|
|
|
|
//#
|
|
|
|
|
2019-08-25 12:35:31 +03:00
|
|
|
QString DistroStruct::getLibOutDir(const QString &basePath) const {
|
|
|
|
return getRelativePath(basePath) + libOutDir;
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DistroStruct::setLibOutDir(const QString &value) {
|
2019-08-26 17:05:18 +03:00
|
|
|
libOutDir = fixPath(value);
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
2019-08-25 12:35:31 +03:00
|
|
|
QString DistroStruct::getBinOutDir(const QString &basePath) const {
|
|
|
|
return getRelativePath(basePath) + binOutDir;
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DistroStruct::setBinOutDir(const QString &value) {
|
2019-08-26 17:05:18 +03:00
|
|
|
binOutDir = fixPath(value);
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
2019-08-25 12:35:31 +03:00
|
|
|
QString DistroStruct::getQmlOutDir(const QString &basePath) const {
|
|
|
|
return getRelativePath(basePath) + qmlOutDir;
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DistroStruct::setQmlOutDir(const QString &value) {
|
2019-08-26 17:05:18 +03:00
|
|
|
qmlOutDir = fixPath(value);
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
2019-08-25 12:35:31 +03:00
|
|
|
QString DistroStruct::getTrOutDir(const QString &basePath) const {
|
|
|
|
return getRelativePath(basePath) + trOutDir;
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DistroStruct::setTrOutDir(const QString &value) {
|
2019-08-26 17:05:18 +03:00
|
|
|
trOutDir = fixPath(value);
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
2019-08-26 21:16:47 +03:00
|
|
|
QString DistroStruct::getResOutDir(const QString &basePath) const {
|
|
|
|
return getRelativePath(basePath) + resOutDir;
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
2019-08-26 21:16:47 +03:00
|
|
|
void DistroStruct::setResOutDir(const QString &value) {
|
|
|
|
resOutDir = fixPath(value);
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
2019-08-25 12:35:31 +03:00
|
|
|
QString DistroStruct::getPluginsOutDir(const QString &basePath) const {
|
|
|
|
return getRelativePath(basePath) + pluginsOutDir;
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DistroStruct::setPluginsOutDir(const QString &value) {
|
2019-08-26 17:05:18 +03:00
|
|
|
pluginsOutDir = fixPath(value);
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|
|
|
|
|
2019-08-26 10:44:12 +03:00
|
|
|
QString DistroStruct::getRootDir(const QString &basePath) const {
|
|
|
|
return getRelativePath(basePath);
|
|
|
|
}
|
|
|
|
|
2019-08-25 12:35:31 +03:00
|
|
|
QString DistroStruct::getRelativePath(QString path) const {
|
|
|
|
|
2019-08-26 08:46:53 +03:00
|
|
|
path.replace('\\', '/');
|
|
|
|
|
|
|
|
int index = -1;
|
|
|
|
do {
|
|
|
|
path.replace("//", "/");
|
|
|
|
} while ((index = path.indexOf("//")) >= 0);
|
|
|
|
|
|
|
|
if (path.left(1) != '/') {
|
|
|
|
path.insert(0, '/');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (path.right(1) != '/') {
|
|
|
|
path.insert(path.size(), '/');
|
|
|
|
}
|
|
|
|
|
|
|
|
int count = path.count('/') - 1;
|
|
|
|
|
2019-08-25 12:35:31 +03:00
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
path += "../";
|
|
|
|
}
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2019-08-26 17:05:18 +03:00
|
|
|
QString DistroStruct::fixPath(const QString &path) const{
|
|
|
|
|
|
|
|
if (path.right(1) != '/')
|
|
|
|
return path + '/';
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2019-08-25 12:06:01 +03:00
|
|
|
DistroStruct::DistroStruct() {
|
|
|
|
|
2019-08-26 17:05:18 +03:00
|
|
|
#ifdef Q_OS_LINUX
|
|
|
|
|
2019-08-26 21:49:01 +03:00
|
|
|
setBinOutDir(QuasarAppUtils::Params::getStrArg("binOut", "/bin"));
|
2019-08-26 21:16:47 +03:00
|
|
|
setLibOutDir(QuasarAppUtils::Params::getStrArg("libOut", "/lib"));
|
2019-08-26 17:05:18 +03:00
|
|
|
|
|
|
|
#else
|
2019-08-26 21:49:01 +03:00
|
|
|
setBinOutDir(QuasarAppUtils::Params::getStrArg("binOut", "/"));
|
2019-08-26 21:16:47 +03:00
|
|
|
setLibOutDir(QuasarAppUtils::Params::getStrArg("libOut", "/"));
|
2019-08-26 17:05:18 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2019-08-26 21:16:47 +03:00
|
|
|
setQmlOutDir(QuasarAppUtils::Params::getStrArg("qmlOut", "/qml"));
|
|
|
|
setTrOutDir(QuasarAppUtils::Params::getStrArg("trOut", "/translations"));
|
|
|
|
setPluginsOutDir(QuasarAppUtils::Params::getStrArg("pluginOut", "/plugins"));
|
|
|
|
setResOutDir("/resources");
|
2019-08-26 17:05:18 +03:00
|
|
|
|
2019-08-25 12:06:01 +03:00
|
|
|
}
|