diff options
| author | Tobias Hunger <tobias.hunger@qt.io> | 2019-07-24 17:37:58 +0200 |
|---|---|---|
| committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-07-25 09:13:39 +0000 |
| commit | 35bb768f4a007d17056ab052708f4b00a2d3838c (patch) | |
| tree | bec977580e88ebba88d44f23bce9fb93fd88aa34 /src | |
| parent | 12dea8f77214cb05cb1898444d5dd874f073ad82 (diff) | |
| download | qt-creator-35bb768f4a007d17056ab052708f4b00a2d3838c.tar.gz | |
CMake: Make CMakeParser work again
The CMakeParser used to set relative paths in the Tasks it creates.
Since is problematic: Task tries to match that relative file name to
one of the files that exist in the session.
At the time cmake runs only the top-level CMakeLists.txt file is known,
so this logic will map all the relative file paths to that file.
Make sure to write absolute file paths into tasks so that this mapping
is not attempted.
Change-Id: I4ab72df21f18d2eff27ca9a502d605e00df2ad85
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src')
5 files changed, 24 insertions, 4 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index 7711ca42c0..90c4bca506 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -52,9 +52,10 @@ #include <utils/qtcprocess.h> #include <utils/pathchooser.h> +#include <QCheckBox> +#include <QDir> #include <QFormLayout> #include <QGroupBox> -#include <QCheckBox> #include <QLineEdit> #include <QListWidget> @@ -212,7 +213,9 @@ bool CMakeBuildStep::init() pp->setCommandLine(cmakeCommand(rc)); pp->resolveAll(); - setOutputParser(new CMakeParser); + CMakeParser *cmakeParser = new CMakeParser; + cmakeParser->setSourceDirectory(projectDirectory.toString()); + setOutputParser(cmakeParser); appendOutputParser(new GnuMakeParser); IOutputParser *parser = target()->kit()->createOutputParser(); if (parser) diff --git a/src/plugins/cmakeprojectmanager/cmakeparser.cpp b/src/plugins/cmakeprojectmanager/cmakeparser.cpp index be67db464f..515bf89222 100644 --- a/src/plugins/cmakeprojectmanager/cmakeparser.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeparser.cpp @@ -50,6 +50,11 @@ CMakeParser::CMakeParser() QTC_CHECK(m_locationLine.isValid()); } +void CMakeParser::setSourceDirectory(const QString &sourceDir) +{ + m_sourceDirectory = QDir(sourceDir); +} + void CMakeParser::stdError(const QString &line) { QString trimmedLine = rightTrimmed(line); @@ -67,8 +72,15 @@ void CMakeParser::stdError(const QString &line) m_skippedFirstEmptyLine = false; if (m_commonError.indexIn(trimmedLine) != -1) { - m_lastTask = Task(Task::Error, QString(), Utils::FilePath::fromUserInput(m_commonError.cap(1)), - m_commonError.cap(2).toInt(), Constants::TASK_CATEGORY_BUILDSYSTEM); + QString path = m_sourceDirectory ? m_sourceDirectory->absoluteFilePath( + QDir::fromNativeSeparators(m_commonError.cap(1))) + : QDir::fromNativeSeparators(m_commonError.cap(1)); + + m_lastTask = Task(Task::Error, + QString(), + Utils::FilePath::fromUserInput(path), + m_commonError.cap(2).toInt(), + Constants::TASK_CATEGORY_BUILDSYSTEM); m_lines = 1; return; } else if (m_nextSubError.indexIn(trimmedLine) != -1) { diff --git a/src/plugins/cmakeprojectmanager/cmakeparser.h b/src/plugins/cmakeprojectmanager/cmakeparser.h index 85a20d870d..57b41ce559 100644 --- a/src/plugins/cmakeprojectmanager/cmakeparser.h +++ b/src/plugins/cmakeprojectmanager/cmakeparser.h @@ -30,6 +30,7 @@ #include <projectexplorer/ioutputparser.h> #include <projectexplorer/task.h> +#include <QDir> #include <QRegExp> #include <QRegularExpression> @@ -41,6 +42,7 @@ class CMAKE_EXPORT CMakeParser : public ProjectExplorer::IOutputParser public: explicit CMakeParser(); + void setSourceDirectory(const QString &sourceDir); void stdError(const QString &line) override; protected: @@ -51,6 +53,7 @@ private: TripleLineError m_expectTripleLineErrorData = NONE; + Utils::optional<QDir> m_sourceDirectory; ProjectExplorer::Task m_lastTask; QRegExp m_commonError; QRegExp m_nextSubError; diff --git a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp index cd6a3d626a..45b7b119ee 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp @@ -104,6 +104,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList & const QString srcDir = parameters.sourceDirectory.toString(); auto parser = std::make_unique<CMakeParser>(); + parser->setSourceDirectory(srcDir); QDir source = QDir(srcDir); connect(parser.get(), &IOutputParser::addTask, parser.get(), [source](const Task &task) { diff --git a/src/plugins/cmakeprojectmanager/servermodereader.cpp b/src/plugins/cmakeprojectmanager/servermodereader.cpp index d88e652322..5c4b1f7a81 100644 --- a/src/plugins/cmakeprojectmanager/servermodereader.cpp +++ b/src/plugins/cmakeprojectmanager/servermodereader.cpp @@ -103,6 +103,7 @@ void ServerModeReader::setParameters(const BuildDirParameters &p) m_parameters = p; + m_parser.setSourceDirectory(m_parameters.sourceDirectory.toString()); createNewServer(); } |
