forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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)
|
||||
|
@@ -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) {
|
||||
|
@@ -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;
|
||||
|
@@ -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) {
|
||||
|
@@ -103,6 +103,7 @@ void ServerModeReader::setParameters(const BuildDirParameters &p)
|
||||
|
||||
m_parameters = p;
|
||||
|
||||
m_parser.setSourceDirectory(m_parameters.sourceDirectory.toString());
|
||||
createNewServer();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user