forked from qt-creator/qt-creator
CMakePM: Rename CMakeParser to CMakeOutputParser
CMakeOutputParser reflects better what the class does, it parses the CMake output to look out for warnings and errors. Change-Id: I601705b2c08ac859c0947d2a50584813353305cf Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -20,7 +20,7 @@ add_qtc_plugin(CMakeProjectManager
|
|||||||
cmakeinstallstep.cpp cmakeinstallstep.h
|
cmakeinstallstep.cpp cmakeinstallstep.h
|
||||||
cmakekitaspect.cpp cmakekitaspect.h
|
cmakekitaspect.cpp cmakekitaspect.h
|
||||||
cmakelocatorfilter.cpp cmakelocatorfilter.h
|
cmakelocatorfilter.cpp cmakelocatorfilter.h
|
||||||
cmakeparser.cpp cmakeparser.h
|
cmakeoutputparser.cpp cmakeoutputparser.h
|
||||||
cmakeprocess.cpp cmakeprocess.h
|
cmakeprocess.cpp cmakeprocess.h
|
||||||
cmakeproject.cpp cmakeproject.h
|
cmakeproject.cpp cmakeproject.h
|
||||||
cmakeproject.qrc
|
cmakeproject.qrc
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
#include "cmakebuildconfiguration.h"
|
#include "cmakebuildconfiguration.h"
|
||||||
#include "cmakebuildsystem.h"
|
#include "cmakebuildsystem.h"
|
||||||
#include "cmakekitaspect.h"
|
#include "cmakekitaspect.h"
|
||||||
#include "cmakeparser.h"
|
#include "cmakeoutputparser.h"
|
||||||
#include "cmakeproject.h"
|
#include "cmakeproject.h"
|
||||||
#include "cmakeprojectconstants.h"
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
@@ -330,14 +330,14 @@ bool CMakeBuildStep::init()
|
|||||||
|
|
||||||
void CMakeBuildStep::setupOutputFormatter(Utils::OutputFormatter *formatter)
|
void CMakeBuildStep::setupOutputFormatter(Utils::OutputFormatter *formatter)
|
||||||
{
|
{
|
||||||
CMakeParser *cmakeParser = new CMakeParser;
|
CMakeOutputParser *cmakeOutputParser = new CMakeOutputParser;
|
||||||
CmakeProgressParser * const progressParser = new CmakeProgressParser;
|
CmakeProgressParser * const progressParser = new CmakeProgressParser;
|
||||||
connect(progressParser, &CmakeProgressParser::progress, this, [this](int percent) {
|
connect(progressParser, &CmakeProgressParser::progress, this, [this](int percent) {
|
||||||
emit progress(percent, {});
|
emit progress(percent, {});
|
||||||
});
|
});
|
||||||
formatter->addLineParser(progressParser);
|
formatter->addLineParser(progressParser);
|
||||||
cmakeParser->setSourceDirectory(project()->projectDirectory());
|
cmakeOutputParser->setSourceDirectory(project()->projectDirectory());
|
||||||
formatter->addLineParsers({cmakeParser, new GnuMakeParser});
|
formatter->addLineParsers({cmakeOutputParser, new GnuMakeParser});
|
||||||
Toolchain *tc = ToolchainKitAspect::cxxToolchain(kit());
|
Toolchain *tc = ToolchainKitAspect::cxxToolchain(kit());
|
||||||
OutputTaskParser *xcodeBuildParser = nullptr;
|
OutputTaskParser *xcodeBuildParser = nullptr;
|
||||||
if (tc && tc->targetAbi().os() == Abi::DarwinOS) {
|
if (tc && tc->targetAbi().os() == Abi::DarwinOS) {
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
#include "cmakeabstractprocessstep.h"
|
#include "cmakeabstractprocessstep.h"
|
||||||
#include "cmakebuildsystem.h"
|
#include "cmakebuildsystem.h"
|
||||||
#include "cmakekitaspect.h"
|
#include "cmakekitaspect.h"
|
||||||
#include "cmakeparser.h"
|
#include "cmakeoutputparser.h"
|
||||||
#include "cmakeprojectconstants.h"
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
#include "cmaketool.h"
|
#include "cmaketool.h"
|
||||||
@@ -52,9 +52,9 @@ private:
|
|||||||
|
|
||||||
void CMakeInstallStep::setupOutputFormatter(OutputFormatter *formatter)
|
void CMakeInstallStep::setupOutputFormatter(OutputFormatter *formatter)
|
||||||
{
|
{
|
||||||
CMakeParser *cmakeParser = new CMakeParser;
|
CMakeOutputParser *cmakeOutputParser = new CMakeOutputParser;
|
||||||
cmakeParser->setSourceDirectory(project()->projectDirectory());
|
cmakeOutputParser->setSourceDirectory(project()->projectDirectory());
|
||||||
formatter->addLineParsers({cmakeParser});
|
formatter->addLineParsers({cmakeOutputParser});
|
||||||
formatter->addSearchDir(processParameters()->effectiveWorkingDirectory());
|
formatter->addSearchDir(processParameters()->effectiveWorkingDirectory());
|
||||||
CMakeAbstractProcessStep::setupOutputFormatter(formatter);
|
CMakeAbstractProcessStep::setupOutputFormatter(formatter);
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (C) 2016 Axonian LLC.
|
// Copyright (C) 2016 Axonian LLC.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "cmakeparser.h"
|
#include "cmakeoutputparser.h"
|
||||||
|
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ const char COMMON_WARNING_PATTERN[] = "^CMake Warning (\\(dev\\) )?at (.*?):([0-
|
|||||||
const char LOCATION_LINE_PATTERN[] = ":(\\d+?):(?:(\\d+?))?$";
|
const char LOCATION_LINE_PATTERN[] = ":(\\d+?):(?:(\\d+?))?$";
|
||||||
const char SOURCE_LINE_AND_FUNCTION_PATTERN[] = " (.*?):([0-9]*?)( \\((.*?)\\))";
|
const char SOURCE_LINE_AND_FUNCTION_PATTERN[] = " (.*?):([0-9]*?)( \\((.*?)\\))";
|
||||||
|
|
||||||
CMakeParser::CMakeParser()
|
CMakeOutputParser::CMakeOutputParser()
|
||||||
{
|
{
|
||||||
m_commonError.setPattern(QLatin1String(COMMON_ERROR_PATTERN));
|
m_commonError.setPattern(QLatin1String(COMMON_ERROR_PATTERN));
|
||||||
QTC_CHECK(m_commonError.isValid());
|
QTC_CHECK(m_commonError.isValid());
|
||||||
@@ -39,7 +39,7 @@ CMakeParser::CMakeParser()
|
|||||||
QTC_CHECK(m_sourceLineAndFunction.isValid());
|
QTC_CHECK(m_sourceLineAndFunction.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeParser::setSourceDirectory(const FilePath &sourceDir)
|
void CMakeOutputParser::setSourceDirectory(const FilePath &sourceDir)
|
||||||
{
|
{
|
||||||
if (m_sourceDirectory)
|
if (m_sourceDirectory)
|
||||||
emit searchDirExpired(m_sourceDirectory.value());
|
emit searchDirExpired(m_sourceDirectory.value());
|
||||||
@@ -47,14 +47,14 @@ void CMakeParser::setSourceDirectory(const FilePath &sourceDir)
|
|||||||
emit newSearchDirFound(sourceDir);
|
emit newSearchDirFound(sourceDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath CMakeParser::resolvePath(const QString &path) const
|
FilePath CMakeOutputParser::resolvePath(const QString &path) const
|
||||||
{
|
{
|
||||||
if (m_sourceDirectory)
|
if (m_sourceDirectory)
|
||||||
return m_sourceDirectory->resolvePath(path);
|
return m_sourceDirectory->resolvePath(path);
|
||||||
return FilePath::fromUserInput(path);
|
return FilePath::fromUserInput(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputLineParser::Result CMakeParser::handleLine(const QString &line, OutputFormat type)
|
OutputLineParser::Result CMakeOutputParser::handleLine(const QString &line, OutputFormat type)
|
||||||
{
|
{
|
||||||
if (line.startsWith("ninja: build stopped")) {
|
if (line.startsWith("ninja: build stopped")) {
|
||||||
m_lastTask = BuildSystemTask(Task::Error, line);
|
m_lastTask = BuildSystemTask(Task::Error, line);
|
||||||
@@ -202,7 +202,7 @@ OutputLineParser::Result CMakeParser::handleLine(const QString &line, OutputForm
|
|||||||
return Status::NotHandled;
|
return Status::NotHandled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeParser::flush()
|
void CMakeOutputParser::flush()
|
||||||
{
|
{
|
||||||
if (m_lastTask.isNull())
|
if (m_lastTask.isNull())
|
||||||
return;
|
return;
|
||||||
@@ -260,16 +260,16 @@ void CMakeParser::flush()
|
|||||||
|
|
||||||
namespace CMakeProjectManager::Internal {
|
namespace CMakeProjectManager::Internal {
|
||||||
|
|
||||||
class CMakeParserTest final : public QObject
|
class CMakeOutputParserTest final : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void testCMakeParser_data();
|
void testCMakeOutputParser_data();
|
||||||
void testCMakeParser();
|
void testCMakeOutputParser();
|
||||||
};
|
};
|
||||||
|
|
||||||
void CMakeParserTest::testCMakeParser_data()
|
void CMakeOutputParserTest::testCMakeOutputParser_data()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("input");
|
QTest::addColumn<QString>("input");
|
||||||
QTest::addColumn<OutputParserTester::Channel>("inputChannel");
|
QTest::addColumn<OutputParserTester::Channel>("inputChannel");
|
||||||
@@ -475,10 +475,10 @@ void CMakeParserTest::testCMakeParser_data()
|
|||||||
<< QString();
|
<< QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeParserTest::testCMakeParser()
|
void CMakeOutputParserTest::testCMakeOutputParser()
|
||||||
{
|
{
|
||||||
OutputParserTester testbench;
|
OutputParserTester testbench;
|
||||||
testbench.addLineParser(new CMakeParser);
|
testbench.addLineParser(new CMakeOutputParser);
|
||||||
QFETCH(QString, input);
|
QFETCH(QString, input);
|
||||||
QFETCH(OutputParserTester::Channel, inputChannel);
|
QFETCH(OutputParserTester::Channel, inputChannel);
|
||||||
QFETCH(Tasks, tasks);
|
QFETCH(Tasks, tasks);
|
||||||
@@ -491,13 +491,13 @@ void CMakeParserTest::testCMakeParser()
|
|||||||
outputLines);
|
outputLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject *createCMakeParserTest()
|
QObject *createCMakeOutputParserTest()
|
||||||
{
|
{
|
||||||
return new CMakeParserTest;
|
return new CMakeOutputParserTest;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // CMakeProjectManager::Internal
|
} // CMakeProjectManager::Internal
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "cmakeparser.moc"
|
#include "cmakeoutputparser.moc"
|
@@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
|
|
||||||
class CMAKE_EXPORT CMakeParser : public ProjectExplorer::OutputTaskParser
|
class CMAKE_EXPORT CMakeOutputParser : public ProjectExplorer::OutputTaskParser
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CMakeParser();
|
explicit CMakeOutputParser();
|
||||||
void setSourceDirectory(const Utils::FilePath &sourceDir);
|
void setSourceDirectory(const Utils::FilePath &sourceDir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -54,7 +54,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
namespace Internal { QObject *createCMakeParserTest(); }
|
namespace Internal { QObject *createCMakeOutputParserTest(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // CMakeProjectManager
|
} // CMakeProjectManager
|
@@ -4,7 +4,7 @@
|
|||||||
#include "cmakeprocess.h"
|
#include "cmakeprocess.h"
|
||||||
|
|
||||||
#include "builddirparameters.h"
|
#include "builddirparameters.h"
|
||||||
#include "cmakeparser.h"
|
#include "cmakeoutputparser.h"
|
||||||
#include "cmakeprojectconstants.h"
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakeprojectmanagertr.h"
|
#include "cmakeprojectmanagertr.h"
|
||||||
#include "cmakespecificsettings.h"
|
#include "cmakespecificsettings.h"
|
||||||
@@ -113,7 +113,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
|||||||
idePackageManagerDir.copyRecursively(localPackageManagerDir);
|
idePackageManagerDir.copyRecursively(localPackageManagerDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto parser = new CMakeParser;
|
const auto parser = new CMakeOutputParser;
|
||||||
parser->setSourceDirectory(parameters.sourceDirectory);
|
parser->setSourceDirectory(parameters.sourceDirectory);
|
||||||
m_parser.addLineParser(parser);
|
m_parser.addLineParser(parser);
|
||||||
m_parser.addLineParsers(parameters.outputParsers());
|
m_parser.addLineParsers(parameters.outputParsers());
|
||||||
|
@@ -41,8 +41,8 @@ QtcPlugin {
|
|||||||
"cmakekitaspect.cpp",
|
"cmakekitaspect.cpp",
|
||||||
"cmakelocatorfilter.cpp",
|
"cmakelocatorfilter.cpp",
|
||||||
"cmakelocatorfilter.h",
|
"cmakelocatorfilter.h",
|
||||||
"cmakeparser.cpp",
|
"cmakeoutputparser.cpp",
|
||||||
"cmakeparser.h",
|
"cmakeoutputparser.h",
|
||||||
"cmakeprocess.cpp",
|
"cmakeprocess.cpp",
|
||||||
"cmakeprocess.h",
|
"cmakeprocess.h",
|
||||||
"cmakeproject.cpp",
|
"cmakeproject.cpp",
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
#include "cmakeinstallstep.h"
|
#include "cmakeinstallstep.h"
|
||||||
#include "cmakelocatorfilter.h"
|
#include "cmakelocatorfilter.h"
|
||||||
#include "cmakekitaspect.h"
|
#include "cmakekitaspect.h"
|
||||||
#include "cmakeparser.h"
|
#include "cmakeoutputparser.h"
|
||||||
#include "cmakeproject.h"
|
#include "cmakeproject.h"
|
||||||
#include "cmakeprojectconstants.h"
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakeprojectimporter.h"
|
#include "cmakeprojectimporter.h"
|
||||||
@@ -70,7 +70,7 @@ class CMakeProjectPlugin final : public ExtensionSystem::IPlugin
|
|||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
addTestCreator(createCMakeConfigTest);
|
addTestCreator(createCMakeConfigTest);
|
||||||
addTestCreator(createCMakeParserTest);
|
addTestCreator(createCMakeOutputParserTest);
|
||||||
addTestCreator(createCMakeProjectImporterTest);
|
addTestCreator(createCMakeProjectImporterTest);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user