CQtDeployer/Deploy/ignorerule.cpp

58 lines
1.5 KiB
C++
Raw Normal View History

2019-09-23 16:46:57 +03:00
/*
2019-12-08 13:57:20 +03:00
* Copyright (C) 2018-2020 QuasarApp.
2019-09-23 16:46:57 +03:00
* 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-09-22 17:31:18 +03:00
#include "ignorerule.h"
#include <quasarapp.h>
bool IgnoreRule::checkOnlytext(const QString &lib) {
for (auto ignore : _data) {
if (lib.contains(ignore.label)) {
return true;
}
}
return false;
}
IgnoreRule::IgnoreRule() {
}
void IgnoreRule::addRule(const IgnoreData &rule) {
_data.push_back(rule);
}
2019-09-23 10:06:22 +03:00
bool IgnoreRule::check(const LibInfo &info, const QString& ignoreLabel) const {
if (info.fullPath().contains(ignoreLabel, Qt::CaseInsensitive)) {
2020-04-04 15:43:46 +03:00
QuasarAppUtils::Params::log(info.fullPath() + " ignored by filter" + ignoreLabel);
2019-09-22 21:55:04 +03:00
return true;
2019-09-22 17:31:18 +03:00
}
2019-09-22 21:55:04 +03:00
return false;
2019-09-22 17:31:18 +03:00
}
2019-10-15 13:35:50 +03:00
const IgnoreData* IgnoreRule::isIgnore(const LibInfo &info) const {
2019-09-22 17:31:18 +03:00
2020-01-12 16:43:03 +03:00
for (const auto &ignore : _data) {
2019-09-22 17:31:18 +03:00
2019-09-23 14:26:45 +03:00
bool checkPlatform = ((ignore.platform & info.getPlatform()) == info.getPlatform()) || ignore.platform == UnknownPlatform;
2019-09-26 13:18:10 +03:00
bool checkPriority = (ignore.prority <= info.getPriority()) || ignore.prority == NotFile;
2019-09-23 14:26:45 +03:00
bool checkEnvirement = !ignore.enfirement.size() || ignore.enfirement.inThisEnvirement(info.fullPath());
2019-09-22 21:55:04 +03:00
2019-09-24 16:30:52 +03:00
if (checkPlatform && checkPriority && checkEnvirement && check(info, ignore.label)) {
2019-10-15 13:35:50 +03:00
return &ignore;
2019-09-22 21:55:04 +03:00
}
2019-09-24 16:30:52 +03:00
2019-09-22 21:55:04 +03:00
}
2019-09-22 17:31:18 +03:00
2019-10-15 13:35:50 +03:00
return nullptr;
2019-09-23 10:06:22 +03:00
}
IgnoreData::IgnoreData(const QString &label) {
this->label = label;
2019-09-22 17:31:18 +03:00
}