Commit 31e2ddd0 authored by Daniel Teske's avatar Daniel Teske
Browse files

Kit: Add createOutputParser method



Which asks each KitInformation for their parser, thus currently creating
a toolchain + qt chain if that is applicable. Remove all code that does
that by hand from various buildsteps/buildconfigurations.

Change-Id: I79a07ffd1dbe9a43bdbc838bc0098071aa412009
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent a36be214
...@@ -112,14 +112,6 @@ void AutotoolsBuildConfiguration::setBuildDirectory(const QString &buildDirector ...@@ -112,14 +112,6 @@ void AutotoolsBuildConfiguration::setBuildDirectory(const QString &buildDirector
emit buildDirectoryChanged(); emit buildDirectoryChanged();
} }
IOutputParser *AutotoolsBuildConfiguration::createOutputParser() const
{
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit());
if (tc)
return tc->outputParser();
return 0;
}
////////////////////////////////////// //////////////////////////////////////
// AutotoolsBuildConfiguration class // AutotoolsBuildConfiguration class
////////////////////////////////////// //////////////////////////////////////
......
...@@ -53,7 +53,6 @@ public: ...@@ -53,7 +53,6 @@ public:
QString buildDirectory() const; QString buildDirectory() const;
void setBuildDirectory(const QString &buildDirectory); void setBuildDirectory(const QString &buildDirectory);
QVariantMap toMap() const; QVariantMap toMap() const;
ProjectExplorer::IOutputParser *createOutputParser() const;
BuildType buildType() const; BuildType buildType() const;
protected: protected:
......
...@@ -192,11 +192,9 @@ bool MakeStep::init() ...@@ -192,11 +192,9 @@ bool MakeStep::init()
pp->setArguments(arguments); pp->setArguments(arguments);
setOutputParser(new GnuMakeParser()); setOutputParser(new GnuMakeParser());
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); IOutputParser *parser = target()->kit()->createOutputParser();
if (version) if (parser)
appendOutputParser(new QtSupport::QtParser); appendOutputParser(parser);
if (tc)
appendOutputParser(tc->outputParser());
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory()); outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
return AbstractProcessStep::init(); return AbstractProcessStep::init();
......
...@@ -125,20 +125,6 @@ void CMakeBuildConfiguration::setBuildDirectory(const QString &buildDirectory) ...@@ -125,20 +125,6 @@ void CMakeBuildConfiguration::setBuildDirectory(const QString &buildDirectory)
emit environmentChanged(); emit environmentChanged();
} }
ProjectExplorer::IOutputParser *CMakeBuildConfiguration::createOutputParser() const
{
ProjectExplorer::IOutputParser *parserchain = new ProjectExplorer::GnuMakeParser;
int versionId = QtSupport::QtKitInformation::qtVersionId(target()->kit());
if (versionId >= 0)
parserchain->appendOutputParser(new QtSupport::QtParser);
ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit());
if (tc)
parserchain->appendOutputParser(tc->outputParser());
return parserchain;
}
/*! /*!
\class CMakeBuildConfigurationFactory \class CMakeBuildConfigurationFactory
*/ */
......
...@@ -58,8 +58,6 @@ public: ...@@ -58,8 +58,6 @@ public:
QVariantMap toMap() const; QVariantMap toMap() const;
ProjectExplorer::IOutputParser *createOutputParser() const;
BuildType buildType() const; BuildType buildType() const;
bool useNinja() const; bool useNinja() const;
......
...@@ -201,12 +201,9 @@ bool MakeStep::init() ...@@ -201,12 +201,9 @@ bool MakeStep::init()
pp->setArguments(arguments); pp->setArguments(arguments);
setOutputParser(new ProjectExplorer::GnuMakeParser()); setOutputParser(new ProjectExplorer::GnuMakeParser());
IOutputParser *parser = target()->kit()->createOutputParser();
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); if (parser)
if (version) appendOutputParser(parser);
appendOutputParser(new QtSupport::QtParser);
if (tc)
appendOutputParser(tc->outputParser());
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory()); outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
return AbstractProcessStep::init(); return AbstractProcessStep::init();
......
...@@ -110,12 +110,6 @@ BuildConfigWidget *GenericBuildConfiguration::createConfigWidget() ...@@ -110,12 +110,6 @@ BuildConfigWidget *GenericBuildConfiguration::createConfigWidget()
return new GenericBuildSettingsWidget; return new GenericBuildSettingsWidget;
} }
IOutputParser *GenericBuildConfiguration::createOutputParser() const
{
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
return tc ? tc->outputParser() : 0;
}
/*! /*!
\class GenericBuildConfigurationFactory \class GenericBuildConfigurationFactory
......
...@@ -56,7 +56,6 @@ public: ...@@ -56,7 +56,6 @@ public:
void setBuildDirectory(const QString &buildDirectory); void setBuildDirectory(const QString &buildDirectory);
QVariantMap toMap() const; QVariantMap toMap() const;
ProjectExplorer::IOutputParser *createOutputParser() const;
BuildType buildType() const; BuildType buildType() const;
protected: protected:
......
...@@ -129,11 +129,9 @@ bool GenericMakeStep::init() ...@@ -129,11 +129,9 @@ bool GenericMakeStep::init()
setIgnoreReturnValue(m_clean); setIgnoreReturnValue(m_clean);
setOutputParser(new GnuMakeParser()); setOutputParser(new GnuMakeParser());
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); IOutputParser *parser = target()->kit()->createOutputParser();
if (version) if (parser)
appendOutputParser(new QtSupport::QtParser); appendOutputParser(parser);
if (tc)
appendOutputParser(tc->outputParser());
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory()); outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
return AbstractProcessStep::init(); return AbstractProcessStep::init();
......
...@@ -76,13 +76,6 @@ public: ...@@ -76,13 +76,6 @@ public:
virtual QVariantMap toMap() const; virtual QVariantMap toMap() const;
// Creates a suitable outputparser for custom build steps
// (based on the tool chain)
// this is not great API
// it's mainly so that custom build systems are better integrated
// with the generic project manager
virtual IOutputParser *createOutputParser() const = 0;
Target *target() const; Target *target() const;
virtual bool isEnabled() const; virtual bool isEnabled() const;
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "kitmanager.h" #include "kitmanager.h"
#include "project.h" #include "project.h"
#include "toolchainmanager.h" #include "toolchainmanager.h"
#include "ioutputparser.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
...@@ -363,6 +364,23 @@ void Kit::addToEnvironment(Utils::Environment &env) const ...@@ -363,6 +364,23 @@ void Kit::addToEnvironment(Utils::Environment &env) const
ki->addToEnvironment(this, env); ki->addToEnvironment(this, env);
} }
IOutputParser *Kit::createOutputParser() const
{
IOutputParser *last = 0;
IOutputParser *first = 0;
QList<KitInformation *> infoList = KitManager::instance()->kitInformation();
foreach (KitInformation *ki, infoList) {
IOutputParser *next = ki->createOutputParser(this);
if (!first)
first = next;
if (last && next)
last->appendOutputParser(next);
if (next)
last = next;
}
return first;
}
QString Kit::toHtml() QString Kit::toHtml()
{ {
QString rc; QString rc;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
namespace Utils { class Environment; } namespace Utils { class Environment; }
namespace ProjectExplorer { namespace ProjectExplorer {
class IOutputParser;
namespace Internal { namespace Internal {
class KitManagerPrivate; class KitManagerPrivate;
...@@ -88,6 +89,7 @@ public: ...@@ -88,6 +89,7 @@ public:
bool isEqual(const Kit *other) const; bool isEqual(const Kit *other) const;
void addToEnvironment(Utils::Environment &env) const; void addToEnvironment(Utils::Environment &env) const;
IOutputParser *createOutputParser() const;
QString toHtml(); QString toHtml();
Kit *clone(bool keepName = false) const; Kit *clone(bool keepName = false) const;
......
...@@ -207,6 +207,14 @@ void ToolChainKitInformation::addToEnvironment(const Kit *k, Utils::Environment ...@@ -207,6 +207,14 @@ void ToolChainKitInformation::addToEnvironment(const Kit *k, Utils::Environment
tc->addToEnvironment(env); tc->addToEnvironment(env);
} }
IOutputParser *ToolChainKitInformation::createOutputParser(const Kit *k) const
{
ToolChain *tc = toolChain(k);
if (tc)
return tc->outputParser();
return 0;
}
ToolChain *ToolChainKitInformation::toolChain(const Kit *k) ToolChain *ToolChainKitInformation::toolChain(const Kit *k)
{ {
if (!k) if (!k)
......
...@@ -112,6 +112,7 @@ public: ...@@ -112,6 +112,7 @@ public:
ItemList toUserOutput(Kit *k) const; ItemList toUserOutput(Kit *k) const;
void addToEnvironment(const Kit *k, Utils::Environment &env) const; void addToEnvironment(const Kit *k, Utils::Environment &env) const;
IOutputParser *createOutputParser(const Kit *k) const;
static ToolChain *toolChain(const Kit *k); static ToolChain *toolChain(const Kit *k);
static void setToolChain(Kit *k, ToolChain *tc); static void setToolChain(Kit *k, ToolChain *tc);
......
...@@ -454,6 +454,12 @@ void KitInformation::addToEnvironment(const Kit *k, Utils::Environment &env) con ...@@ -454,6 +454,12 @@ void KitInformation::addToEnvironment(const Kit *k, Utils::Environment &env) con
Q_UNUSED(env); Q_UNUSED(env);
} }
IOutputParser *KitInformation::createOutputParser(const Kit *k) const
{
Q_UNUSED(k);
return 0;
}
QString KitInformation::displayNamePostfix(const Kit *k) const QString KitInformation::displayNamePostfix(const Kit *k) const
{ {
Q_UNUSED(k); Q_UNUSED(k);
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
namespace Utils { class Environment; } namespace Utils { class Environment; }
namespace ProjectExplorer { namespace ProjectExplorer {
class IOutputParser;
class Kit; class Kit;
class KitConfigWidget; class KitConfigWidget;
...@@ -82,6 +83,7 @@ public: ...@@ -82,6 +83,7 @@ public:
virtual KitConfigWidget *createConfigWidget(Kit *) const = 0; virtual KitConfigWidget *createConfigWidget(Kit *) const = 0;
virtual void addToEnvironment(const Kit *k, Utils::Environment &env) const; virtual void addToEnvironment(const Kit *k, Utils::Environment &env) const;
virtual IOutputParser *createOutputParser(const Kit *k) const;
virtual QString displayNamePostfix(const Kit *k) const; virtual QString displayNamePostfix(const Kit *k) const;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "buildconfiguration.h" #include "buildconfiguration.h"
#include "projectexplorerconstants.h" #include "projectexplorerconstants.h"
#include "target.h" #include "target.h"
#include "kit.h"
#include <coreplugin/idocument.h> #include <coreplugin/idocument.h>
#include <utils/qtcprocess.h> #include <utils/qtcprocess.h>
...@@ -95,7 +96,9 @@ bool ProcessStep::init() ...@@ -95,7 +96,9 @@ bool ProcessStep::init()
pp->setWorkingDirectory(workingDirectory()); pp->setWorkingDirectory(workingDirectory());
pp->setCommand(m_command); pp->setCommand(m_command);
pp->setArguments(m_arguments); pp->setArguments(m_arguments);
setOutputParser(bc->createOutputParser()); IOutputParser *parser = target()->kit()->createOutputParser();
if (parser)
setOutputParser(parser);
return AbstractProcessStep::init(); return AbstractProcessStep::init();
} }
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <projectexplorer/target.h> #include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <projectexplorer/buildsteplist.h> #include <projectexplorer/buildsteplist.h>
#include <projectexplorer/gnumakeparser.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/kitinformation.h> #include <projectexplorer/kitinformation.h>
...@@ -248,20 +249,11 @@ bool MakeStep::init() ...@@ -248,20 +249,11 @@ bool MakeStep::init()
pp->setEnvironment(env); pp->setEnvironment(env);
pp->setArguments(args); pp->setArguments(args);
IOutputParser *parser = 0; setOutputParser(new ProjectExplorer::GnuMakeParser());
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); IOutputParser *parser = target()->kit()->createOutputParser();
if (version)
parser = version->createOutputParser();
if (parser) if (parser)
parser->appendOutputParser(new QtSupport::QtParser); appendOutputParser(parser);
else outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
parser = new QtSupport::QtParser;
if (tc)
parser->appendOutputParser(tc->outputParser());
parser->setWorkingDirectory(workingDirectory);
setOutputParser(parser);
m_scriptTarget = (static_cast<Qt4Project *>(bc->target()->project())->rootQt4ProjectNode()->projectType() == ScriptTemplate); m_scriptTarget = (static_cast<Qt4Project *>(bc->target()->project())->rootQt4ProjectNode()->projectType() == ScriptTemplate);
......
...@@ -538,12 +538,6 @@ FileName Qt4BuildConfiguration::extractSpecFromArguments(QString *args, ...@@ -538,12 +538,6 @@ FileName Qt4BuildConfiguration::extractSpecFromArguments(QString *args,
return parsedSpec; return parsedSpec;
} }
IOutputParser *Qt4BuildConfiguration::createOutputParser() const
{
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
return tc ? tc->outputParser() : 0;
}
bool Qt4BuildConfiguration::isEnabled() const bool Qt4BuildConfiguration::isEnabled() const
{ {
return m_isEnabled; return m_isEnabled;
......
...@@ -98,8 +98,6 @@ public: ...@@ -98,8 +98,6 @@ public:
QVariantMap toMap() const; QVariantMap toMap() const;
ProjectExplorer::IOutputParser *createOutputParser() const;
virtual bool isEnabled() const; virtual bool isEnabled() const;
virtual QString disabledReason() const; virtual QString disabledReason() const;
/// \internal For Qt4Project, since that manages the parsing information /// \internal For Qt4Project, since that manages the parsing information
......
...@@ -1162,11 +1162,6 @@ BaseQtVersion::reportIssues(const QString &proFile, const QString &buildDir) con ...@@ -1162,11 +1162,6 @@ BaseQtVersion::reportIssues(const QString &proFile, const QString &buildDir) con
return results; return results;
} }
ProjectExplorer::IOutputParser *BaseQtVersion::createOutputParser() const
{
return new ProjectExplorer::GnuMakeParser;
}
QtConfigWidget *BaseQtVersion::createConfigurationWidget() const QtConfigWidget *BaseQtVersion::createConfigurationWidget() const
{ {
return 0; return 0;
......
...@@ -185,8 +185,6 @@ public: ...@@ -185,8 +185,6 @@ public:
/// warnings and finally info items. /// warnings and finally info items.
QList<ProjectExplorer::Task> reportIssues(const QString &proFile, const QString &buildDir) const; QList<ProjectExplorer::Task> reportIssues(const QString &proFile, const QString &buildDir) const;
virtual ProjectExplorer::IOutputParser *createOutputParser() const;
static bool queryQMakeVariables(const Utils::FileName &binary, QHash<QString, QString> *versionInfo); static bool queryQMakeVariables(const Utils::FileName &binary, QHash<QString, QString> *versionInfo);
static bool queryQMakeVariables(const Utils::FileName &binary, QHash<QString, QString> *versionInfo, bool *qmakeIsExecutable); static bool queryQMakeVariables(const Utils::FileName &binary, QHash<QString, QString> *versionInfo, bool *qmakeIsExecutable);
static Utils::FileName mkspecDirectoryFromVersionInfo(const QHash<QString, QString> &versionInfo); static Utils::FileName mkspecDirectoryFromVersionInfo(const QHash<QString, QString> &versionInfo);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "qtkitconfigwidget.h" #include "qtkitconfigwidget.h"
#include "qtsupportconstants.h" #include "qtsupportconstants.h"
#include "qtversionmanager.h" #include "qtversionmanager.h"
#include "qtparser.h"
#include <utils/environment.h> #include <utils/environment.h>
...@@ -126,6 +127,13 @@ void QtKitInformation::addToEnvironment(const ProjectExplorer::Kit *k, Utils::En ...@@ -126,6 +127,13 @@ void QtKitInformation::addToEnvironment(const ProjectExplorer::Kit *k, Utils::En
version->addToEnvironment(k, env); version->addToEnvironment(k, env);
} }
ProjectExplorer::IOutputParser *QtKitInformation::createOutputParser(const ProjectExplorer::Kit *k) const
{
if (qtVersion(k))
return new QtParser;
return 0;
}
int QtKitInformation::qtVersionId(const ProjectExplorer::Kit *k) int QtKitInformation::qtVersionId(const ProjectExplorer::Kit *k)
{ {
if (!k) if (!k)
......
...@@ -61,6 +61,7 @@ public: ...@@ -61,6 +61,7 @@ public:
ItemList toUserOutput(ProjectExplorer::Kit *k) const; ItemList toUserOutput(ProjectExplorer::Kit *k) const;
void addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const; void addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const;
ProjectExplorer::IOutputParser *createOutputParser(const ProjectExplorer::Kit *k) const;
static int qtVersionId(const ProjectExplorer::Kit *k); static int qtVersionId(const ProjectExplorer::Kit *k);
static void setQtVersionId(ProjectExplorer::Kit *k, const int id); static void setQtVersionId(ProjectExplorer::Kit *k, const int id);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment