CMake: Allow parser to run remotely

Change-Id: I3953d459177790fd652ab69c083b0dd0f1d29031
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-09-30 17:21:09 +02:00
parent 7020efffbb
commit 3b84a408df
4 changed files with 24 additions and 18 deletions

View File

@@ -300,7 +300,7 @@ void CMakeBuildStep::setupOutputFormatter(Utils::OutputFormatter *formatter)
emit progress(percent, {});
});
formatter->addLineParser(progressParser);
cmakeParser->setSourceDirectory(project()->projectDirectory().toString());
cmakeParser->setSourceDirectory(project()->projectDirectory());
formatter->addLineParsers({cmakeParser, new GnuMakeParser});
ToolChain *tc = ToolChainKitAspect::cxxToolChain(kit());
OutputTaskParser *xcodeBuildParser = nullptr;

View File

@@ -32,12 +32,19 @@ CMakeParser::CMakeParser()
QTC_CHECK(m_locationLine.isValid());
}
void CMakeParser::setSourceDirectory(const QString &sourceDir)
void CMakeParser::setSourceDirectory(const FilePath &sourceDir)
{
if (m_sourceDirectory)
emit searchDirExpired(FilePath::fromString(m_sourceDirectory.value().path()));
m_sourceDirectory = QDir(sourceDir);
emit newSearchDirFound(FilePath::fromString(sourceDir));
emit searchDirExpired(m_sourceDirectory.value());
m_sourceDirectory = sourceDir;
emit newSearchDirFound(sourceDir);
}
FilePath CMakeParser::resolvePath(const QString &path) const
{
if (m_sourceDirectory)
return m_sourceDirectory->resolvePath(path);
return FilePath::fromUserInput(path);
}
OutputLineParser::Result CMakeParser::handleLine(const QString &line, OutputFormat type)
@@ -69,12 +76,11 @@ OutputLineParser::Result CMakeParser::handleLine(const QString &line, OutputForm
match = m_commonError.match(trimmedLine);
if (match.hasMatch()) {
QString path = m_sourceDirectory ? m_sourceDirectory->absoluteFilePath(
QDir::fromNativeSeparators(match.captured(1)))
: QDir::fromNativeSeparators(match.captured(1));
const FilePath path = resolvePath(match.captured(1));
m_lastTask = BuildSystemTask(Task::Error,
QString(),
absoluteFilePath(FilePath::fromUserInput(path)),
absoluteFilePath(path),
match.captured(2).toInt());
m_lines = 1;
LinkSpecs linkSpecs;
@@ -94,12 +100,10 @@ OutputLineParser::Result CMakeParser::handleLine(const QString &line, OutputForm
}
match = m_commonWarning.match(trimmedLine);
if (match.hasMatch()) {
QString path = m_sourceDirectory ? m_sourceDirectory->absoluteFilePath(
QDir::fromNativeSeparators(match.captured(2)))
: QDir::fromNativeSeparators(match.captured(2));
const FilePath path = resolvePath(match.captured(2));
m_lastTask = BuildSystemTask(Task::Warning,
QString(),
absoluteFilePath(FilePath::fromUserInput(path)),
absoluteFilePath(path),
match.captured(3).toInt());
m_lines = 1;
LinkSpecs linkSpecs;

View File

@@ -8,7 +8,8 @@
#include <projectexplorer/ioutputparser.h>
#include <projectexplorer/task.h>
#include <QDir>
#include <utils/filepath.h>
#include <QRegularExpression>
#include <optional>
@@ -21,17 +22,18 @@ class CMAKE_EXPORT CMakeParser : public ProjectExplorer::OutputTaskParser
public:
explicit CMakeParser();
void setSourceDirectory(const QString &sourceDir);
void setSourceDirectory(const Utils::FilePath &sourceDir);
private:
Result handleLine(const QString &line, Utils::OutputFormat type) override;
void flush() override;
Utils::FilePath resolvePath(const QString &path) const;
enum TripleLineError { NONE, LINE_LOCATION, LINE_DESCRIPTION, LINE_DESCRIPTION2 };
TripleLineError m_expectTripleLineErrorData = NONE;
std::optional<QDir> m_sourceDirectory;
std::optional<Utils::FilePath> m_sourceDirectory;
ProjectExplorer::Task m_lastTask;
QRegularExpression m_commonError;
QRegularExpression m_nextSubError;
@@ -41,4 +43,4 @@ private:
int m_lines = 0;
};
} // namespace CMakeProjectManager
} // CMakeProjectManager

View File

@@ -97,7 +97,7 @@ void CMakeProcess::run(const BuildDirParameters &parameters, const QStringList &
}
const auto parser = new CMakeParser;
parser->setSourceDirectory(parameters.sourceDirectory.path());
parser->setSourceDirectory(parameters.sourceDirectory);
m_parser.addLineParser(parser);
// Always use the sourceDir: If we are triggered because the build directory is getting deleted