CQtDeployer/Deploy/deployconfig.cpp

151 lines
3.7 KiB
C++
Raw Normal View History

/*
* Copyright (C) 2018-2021 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-12-11 18:06:54 +03:00
#include "deployconfig.h"
2020-07-02 16:00:34 +03:00
#include "quasarapp.h"
2019-12-11 18:06:54 +03:00
void DeployConfig::reset() {
*this = DeployConfig{};
}
QHash<QString, TargetInfo*>
DeployConfig::getTargetsListByFilter(const QString &filter) {
QHash<QString, TargetInfo*> result;
2020-01-02 19:27:40 +03:00
for( auto it = _targets.begin(); it != _targets.end(); ++it) {
2019-12-11 18:06:54 +03:00
if (it.key().contains(filter, Qt::CaseInsensitive)) {
result.insert(it.key(), &(*it));
}
}
return result;
}
2019-12-12 22:50:04 +03:00
QString DeployConfig::getTargetDir(const QString &target) const {
2020-01-02 19:27:40 +03:00
if (_targets.contains(target))
2020-02-26 16:51:28 +03:00
return targetDir + "/" + _targets.value(target).getPackage();
2020-02-27 10:50:11 +03:00
return targetDir;
2019-12-11 18:06:54 +03:00
}
QString DeployConfig::getPackageTargetDir(const QString &package) const {
if (!_packages.contains(package)) {
#ifdef QT_DEBUG
abort();
#endif
return "";
}
return targetDir + "/" + package;
}
2019-12-14 17:38:43 +03:00
void DeployConfig::setTargetDir(const QString &target) {
targetDir = target;
2020-04-25 18:16:02 +03:00
if (targetDir.right(1) != "/" ) {
ignoreList.addRule(targetDir + "/");
}
else {
ignoreList.addRule(targetDir);
}
2019-12-14 17:38:43 +03:00
}
2020-01-02 19:27:40 +03:00
DistroModule DeployConfig::getDistro(const QString &target) const {
2020-12-03 20:00:14 +03:00
auto key = _targets.value(target).getPackage();
return _packages.value(key, DistroModule{key});
2019-12-14 17:38:43 +03:00
}
2020-01-27 20:02:25 +03:00
DistroModule DeployConfig::getDistroFromPackage(const QString &package) const {
2020-12-03 20:00:14 +03:00
return _packages.value(package, DistroModule{package});
2019-12-15 18:30:24 +03:00
}
2020-01-02 19:27:40 +03:00
2021-01-19 14:26:11 +03:00
QHash<QString, TargetInfo> &DeployConfig::targetsEdit() {
2020-01-02 19:27:40 +03:00
return _targets;
}
2020-01-27 20:02:25 +03:00
QHash<QString, DistroModule> &DeployConfig::packagesEdit() {
return _packages;
2020-01-02 19:27:40 +03:00
}
Platform DeployConfig::getPlatform(const QString& package) const {
2020-07-02 16:00:34 +03:00
Platform result = Platform::UnknownPlatform;
if (_packages.contains(package)) {
auto disto = getDistroFromPackage(package);
2020-07-04 23:08:41 +03:00
for( auto it = disto.targets().cbegin(); it != disto.targets().cend(); ++it) {
result = result | _targets.value(*it).getPlatform();
}
}
2020-10-14 13:17:26 +03:00
return result;
}
Platform DeployConfig::getPlatformOfAll() const {
Platform result = Platform::UnknownPlatform;
2020-07-04 23:08:41 +03:00
for( auto it = _targets.cbegin(); it != _targets.cend(); ++it) {
2020-07-02 16:00:34 +03:00
result = result | it.value().getPlatform();
}
return result;
}
2020-08-15 19:29:17 +03:00
QString DeployConfig::getDefaultPackage() const {
return defaultPackage;
}
2021-01-08 22:02:50 +03:00
void DeployConfig::setDefaultPackage(const QString &value) {
2020-08-15 19:29:17 +03:00
defaultPackage = value;
}
2021-01-08 22:02:50 +03:00
void DeployConfig::registerRunScript(const QString &targetName,
const QString &scriptPath) {
_runScripts.insert(targetName, scriptPath);
}
QString DeployConfig::getRunScript(const QString &targetName) const {
return _runScripts.value(targetName, "");
}
QtMajorVersion DeployConfig::isNeededQt() const {
auto Qt = QtMajorVersion::NoQt;
for (const auto &i: targets()) {
if (i.isValid()) {
Qt = Qt | i.isDependetOfQt();
}
}
return Qt;
}
QtMajorVersion DeployConfig::isNeededQt(const QString &pacakge) const {
2021-03-27 18:03:36 +03:00
const auto targetsKeys = packages().value(pacakge, DistroModule{""}).targets();
auto Qt = QtMajorVersion::NoQt;
for (const auto &i: targetsKeys) {
auto target = targets().value(i);
if (target.isValid()) {
Qt = Qt | target.isDependetOfQt();
}
}
return Qt;
}
2020-01-02 19:27:40 +03:00
const QHash<QString, TargetInfo> &DeployConfig::targets() const {
return _targets;
}
2020-01-27 20:02:25 +03:00
const QHash<QString, DistroModule> &DeployConfig::packages() const {
return _packages;
2020-01-02 19:27:40 +03:00
}