2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 Alexis Jeandet.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2020-05-01 18:20:56 +02:00
|
|
|
|
|
|
|
|
#include "ninjaparser.h"
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
#include <utils/fileutils.h>
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
namespace MesonProjectManager {
|
|
|
|
|
namespace Internal {
|
2020-10-29 10:20:14 +01:00
|
|
|
|
2020-05-01 18:20:56 +02:00
|
|
|
NinjaParser::NinjaParser() {}
|
|
|
|
|
|
|
|
|
|
Utils::optional<int> NinjaParser::extractProgress(const QString &line)
|
|
|
|
|
{
|
|
|
|
|
auto progress = m_progressRegex.match(line);
|
|
|
|
|
if (progress.hasMatch()) {
|
|
|
|
|
auto total = progress.captured(2).toInt();
|
|
|
|
|
auto pos = progress.captured(1).toInt();
|
|
|
|
|
return pos * 100 / total;
|
|
|
|
|
}
|
|
|
|
|
return Utils::nullopt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NinjaParser::setSourceDirectory(const Utils::FilePath &sourceDir)
|
|
|
|
|
{
|
2021-02-14 00:19:39 +01:00
|
|
|
emit newSearchDirFound(sourceDir);
|
2020-05-01 18:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Utils::OutputLineParser::Result NinjaParser::handleLine(const QString &line,
|
|
|
|
|
Utils::OutputFormat type)
|
|
|
|
|
{
|
|
|
|
|
if (type == Utils::OutputFormat::StdOutFormat) {
|
|
|
|
|
auto progress = extractProgress(line);
|
|
|
|
|
if (progress) {
|
|
|
|
|
emit reportProgress(*progress);
|
|
|
|
|
//return ProjectExplorer::OutputTaskParser::Status::InProgress;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ProjectExplorer::OutputTaskParser::Status::NotHandled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NinjaParser::hasFatalErrors() const
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace MesonProjectManager
|