From 68d6bfe33bf1c86da4f068df67dee78b770fab78 Mon Sep 17 00:00:00 2001 From: dt <qtc-committer@nokia.com> Date: Mon, 6 Dec 2010 12:18:38 +0100 Subject: [PATCH] Output parsers: Make target specific code pseudo generic Introduce IOutputParser::setWorkingDirectory and IOutputParser::hasFatalErrors() Reviewed-By: hunger --- src/plugins/cmakeprojectmanager/makestep.cpp | 3 +- .../genericprojectmanager/genericmakestep.cpp | 3 +- src/plugins/projectexplorer/gnumakeparser.cpp | 13 ++++++--- src/plugins/projectexplorer/gnumakeparser.h | 6 ++-- src/plugins/projectexplorer/ioutputparser.cpp | 11 ++++++++ src/plugins/projectexplorer/ioutputparser.h | 5 ++++ src/plugins/qt4projectmanager/makestep.cpp | 28 ++++++------------- src/plugins/qt4projectmanager/makestep.h | 2 +- .../qt-s60/s60createpackagestep.cpp | 3 +- .../qt4projectmanager/qtversionmanager.cpp | 18 ++++++++++++ .../qt4projectmanager/qtversionmanager.h | 4 +++ 11 files changed, 67 insertions(+), 29 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/makestep.cpp b/src/plugins/cmakeprojectmanager/makestep.cpp index ab93540b83c..6f6f9f522a7 100644 --- a/src/plugins/cmakeprojectmanager/makestep.cpp +++ b/src/plugins/cmakeprojectmanager/makestep.cpp @@ -142,9 +142,10 @@ bool MakeStep::init() pp->setCommand(bc->toolChain()->makeCommand()); pp->setArguments(arguments); - setOutputParser(new ProjectExplorer::GnuMakeParser(pp->effectiveWorkingDirectory())); + setOutputParser(new ProjectExplorer::GnuMakeParser()); if (bc->toolChain()) appendOutputParser(bc->toolChain()->outputParser()); + outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory()); return AbstractProcessStep::init(); } diff --git a/src/plugins/genericprojectmanager/genericmakestep.cpp b/src/plugins/genericprojectmanager/genericmakestep.cpp index e974ddcfb9c..e4dd6d964d8 100644 --- a/src/plugins/genericprojectmanager/genericmakestep.cpp +++ b/src/plugins/genericprojectmanager/genericmakestep.cpp @@ -111,9 +111,10 @@ bool GenericMakeStep::init() pp->setCommand(makeCommand()); pp->setArguments(allArguments()); - setOutputParser(new ProjectExplorer::GnuMakeParser(pp->effectiveWorkingDirectory())); + setOutputParser(new ProjectExplorer::GnuMakeParser()); if (bc->genericTarget()->genericProject()->toolChain()) appendOutputParser(bc->genericTarget()->genericProject()->toolChain()->outputParser()); + outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory()); return AbstractProcessStep::init(); } diff --git a/src/plugins/projectexplorer/gnumakeparser.cpp b/src/plugins/projectexplorer/gnumakeparser.cpp index 1cefce09cd0..affb370d480 100644 --- a/src/plugins/projectexplorer/gnumakeparser.cpp +++ b/src/plugins/projectexplorer/gnumakeparser.cpp @@ -42,7 +42,7 @@ namespace { const char * const MAKE_PATTERN("^(([A-Za-z]:)?[/\\\\][^:]*[/\\\\])?(mingw(32|64)-|g)?make(.exe)?(\\[\\d+\\])?:\\s"); } -GnuMakeParser::GnuMakeParser(const QString &dir) : +GnuMakeParser::GnuMakeParser() : m_suppressIssues(false), m_fatalErrorCount(0) { @@ -54,12 +54,17 @@ GnuMakeParser::GnuMakeParser(const QString &dir) : m_makeLine.setMinimal(true); m_makefileError.setPattern(QLatin1String("^(.*):(\\d+):\\s\\*\\*\\*\\s(.*)$")); m_makefileError.setMinimal(true); - addDirectory(dir); } -int GnuMakeParser::fatalErrors() const +void GnuMakeParser::setWorkingDirectory(const QString &workingDirectory) { - return m_fatalErrorCount; + addDirectory(workingDirectory); + IOutputParser::setWorkingDirectory(workingDirectory); +} + +bool GnuMakeParser::hasFatalErrors() const +{ + return (m_fatalErrorCount > 0) || IOutputParser::hasFatalErrors(); } void GnuMakeParser::stdOutput(const QString &line) diff --git a/src/plugins/projectexplorer/gnumakeparser.h b/src/plugins/projectexplorer/gnumakeparser.h index ae24798f09a..7f389dd14ee 100644 --- a/src/plugins/projectexplorer/gnumakeparser.h +++ b/src/plugins/projectexplorer/gnumakeparser.h @@ -42,14 +42,16 @@ class PROJECTEXPLORER_EXPORT GnuMakeParser : public ProjectExplorer::IOutputPars Q_OBJECT public: - explicit GnuMakeParser(const QString &dir = QString()); + explicit GnuMakeParser(); virtual void stdOutput(const QString &line); virtual void stdError(const QString &line); + virtual void setWorkingDirectory(const QString &workingDirectory); + QStringList searchDirectories() const; - int fatalErrors() const; + bool hasFatalErrors() const; public slots: virtual void taskAdded(const ProjectExplorer::Task &task); diff --git a/src/plugins/projectexplorer/ioutputparser.cpp b/src/plugins/projectexplorer/ioutputparser.cpp index 9bc7ef60fb5..214b1a901e8 100644 --- a/src/plugins/projectexplorer/ioutputparser.cpp +++ b/src/plugins/projectexplorer/ioutputparser.cpp @@ -103,4 +103,15 @@ void IOutputParser::taskAdded(const ProjectExplorer::Task &task) emit addTask(task); } +bool IOutputParser::hasFatalErrors() const +{ + return false || (m_parser && m_parser->hasFatalErrors()); +} + +void IOutputParser::setWorkingDirectory(const QString &workingDirectory) +{ + if (m_parser) + m_parser->setWorkingDirectory(workingDirectory); +} + } diff --git a/src/plugins/projectexplorer/ioutputparser.h b/src/plugins/projectexplorer/ioutputparser.h index b733aa5a12f..9f227eb520e 100644 --- a/src/plugins/projectexplorer/ioutputparser.h +++ b/src/plugins/projectexplorer/ioutputparser.h @@ -63,6 +63,11 @@ public: /// Called once for each line if standard error to parse. virtual void stdError(const QString &line); + // This is mainly a symbian specific quirk + virtual bool hasFatalErrors() const; + // For GnuMakeParser + virtual void setWorkingDirectory(const QString &workingDirectory); + signals: /// Should be emitted whenever some additional information should be /// added to the output. diff --git a/src/plugins/qt4projectmanager/makestep.cpp b/src/plugins/qt4projectmanager/makestep.cpp index 1172899f16a..3eb4f8be151 100644 --- a/src/plugins/qt4projectmanager/makestep.cpp +++ b/src/plugins/qt4projectmanager/makestep.cpp @@ -183,24 +183,14 @@ bool MakeStep::init() setEnabled(true); pp->setArguments(args); - m_gnuMakeParser = 0; - - if (bc->qtVersion()->supportsTargetId(Qt4ProjectManager::Constants::S60_DEVICE_TARGET_ID) || - bc->qtVersion()->supportsTargetId(Qt4ProjectManager::Constants::S60_EMULATOR_TARGET_ID)) { - if (bc->qtVersion()->isBuildWithSymbianSbsV2()) { - setOutputParser(new SbsV2Parser); - } else { - setOutputParser(new AbldParser); - m_gnuMakeParser = new ProjectExplorer::GnuMakeParser(workingDirectory); - appendOutputParser(m_gnuMakeParser); - } - } else { - setOutputParser(new ProjectExplorer::GnuMakeParser(workingDirectory)); - } - appendOutputParser(new QtParser); - + m_makeParser = bc->qtVersion()->createOutputParser(); + m_makeParser->appendOutputParser(new QtParser); if (toolchain) - appendOutputParser(toolchain->outputParser()); + m_makeParser->appendOutputParser(toolchain->outputParser()); + + m_makeParser->setWorkingDirectory(workingDirectory); + + setOutputParser(m_makeParser); return AbstractProcessStep::init(); } @@ -218,8 +208,8 @@ void MakeStep::run(QFutureInterface<bool> & fi) bool MakeStep::processSucceeded(int exitCode, QProcess::ExitStatus status) { // Symbian does retun 0, even on failed makes! So we check for fatal make errors here. - if (m_gnuMakeParser) - return m_gnuMakeParser->fatalErrors() == 0; + if (m_makeParser && m_makeParser->hasFatalErrors()) + return false; return AbstractProcessStep::processSucceeded(exitCode, status); } diff --git a/src/plugins/qt4projectmanager/makestep.h b/src/plugins/qt4projectmanager/makestep.h index 0858e55fd9a..ac0b35ede07 100644 --- a/src/plugins/qt4projectmanager/makestep.h +++ b/src/plugins/qt4projectmanager/makestep.h @@ -110,7 +110,7 @@ private: bool m_clean; QString m_userArgs; QString m_makeCmd; - ProjectExplorer::GnuMakeParser * m_gnuMakeParser; + ProjectExplorer::IOutputParser *m_makeParser; }; class MakeStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget diff --git a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp index 20b114d32d7..b5adbd040af 100644 --- a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp +++ b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp @@ -409,11 +409,12 @@ bool S60CreatePackageStep::createOnePackage() m_outputParserChain = new Qt4ProjectManager::AbldParser; m_outputParserChain->appendOutputParser(new ProjectExplorer::GnuMakeParser); } else { - m_outputParserChain = new ProjectExplorer::GnuMakeParser(wd.absolutePath()); + m_outputParserChain = new ProjectExplorer::GnuMakeParser(); } Q_ASSERT(!m_parser); m_parser = new S60CreatePackageParser(wd.absolutePath()); m_outputParserChain->appendOutputParser(m_parser); + m_outputParserChain->setWorkingDirectory(wd.absolutePath()); connect(m_outputParserChain, SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat)), this, SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat))); diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index b1dc399c11d..b31f254a04e 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -36,10 +36,13 @@ #include "qt-maemo/maemomanager.h" #include "qt-s60/s60manager.h" #include "qt-s60/s60projectchecker.h" +#include "qt-s60/abldparser.h" +#include "qt-s60/sbsv2parser.h" #include "qmlobservertool.h" #include "qmldumptool.h" #include <projectexplorer/debugginghelper.h> +#include <projectexplorer/gnumakeparser.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/cesdkhandler.h> @@ -669,6 +672,21 @@ bool QtVersion::supportsShadowBuilds() const return true; } +ProjectExplorer::IOutputParser *QtVersion::createOutputParser() const +{ + if (supportsTargetId(Qt4ProjectManager::Constants::S60_DEVICE_TARGET_ID) || + supportsTargetId(Qt4ProjectManager::Constants::S60_EMULATOR_TARGET_ID)) { + if (isBuildWithSymbianSbsV2()) { + return new SbsV2Parser; + } else { + ProjectExplorer::IOutputParser *parser = new AbldParser; + parser->appendOutputParser(new ProjectExplorer::GnuMakeParser); + return parser; + } + } + return new ProjectExplorer::GnuMakeParser; +} + QList<ProjectExplorer::Task> QtVersion::reportIssues(const QString &proFile, const QString &buildDir) { diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index f810aa0868a..7159ea1a11b 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -31,6 +31,8 @@ #define QTVERSIONMANAGER_H #include "qt4projectmanager_global.h" + +#include <projectexplorer/ioutputparser.h> #include <projectexplorer/taskwindow.h> #include <projectexplorer/toolchain.h> #include <projectexplorer/task.h> @@ -173,6 +175,8 @@ public: /// warnings and finally info items. QList<ProjectExplorer::Task> reportIssues(const QString &proFile, const QString &buildDir); + ProjectExplorer::IOutputParser *createOutputParser() const; + private: QList<QSharedPointer<ProjectExplorer::ToolChain> > toolChains() const; static int getUniqueId(); -- GitLab