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

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
emit buildDirectoryChanged();
}
IOutputParser *AutotoolsBuildConfiguration::createOutputParser() const
{
ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit());
if (tc)
return tc->outputParser();
return 0;
}
//////////////////////////////////////
// AutotoolsBuildConfiguration class
//////////////////////////////////////
......
......@@ -53,7 +53,6 @@ public:
QString buildDirectory() const;
void setBuildDirectory(const QString &buildDirectory);
QVariantMap toMap() const;
ProjectExplorer::IOutputParser *createOutputParser() const;
BuildType buildType() const;
protected:
......
......@@ -192,11 +192,9 @@ bool MakeStep::init()
pp->setArguments(arguments);
setOutputParser(new GnuMakeParser());
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
if (version)
appendOutputParser(new QtSupport::QtParser);
if (tc)
appendOutputParser(tc->outputParser());
IOutputParser *parser = target()->kit()->createOutputParser();
if (parser)
appendOutputParser(parser);
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
return AbstractProcessStep::init();
......
......@@ -125,20 +125,6 @@ void CMakeBuildConfiguration::setBuildDirectory(const QString &buildDirectory)
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
*/
......
......@@ -58,8 +58,6 @@ public:
QVariantMap toMap() const;
ProjectExplorer::IOutputParser *createOutputParser() const;
BuildType buildType() const;
bool useNinja() const;
......
......@@ -201,12 +201,9 @@ bool MakeStep::init()
pp->setArguments(arguments);
setOutputParser(new ProjectExplorer::GnuMakeParser());
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
if (version)
appendOutputParser(new QtSupport::QtParser);
if (tc)
appendOutputParser(tc->outputParser());
IOutputParser *parser = target()->kit()->createOutputParser();
if (parser)
appendOutputParser(parser);
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
return AbstractProcessStep::init();
......
......@@ -110,12 +110,6 @@ BuildConfigWidget *GenericBuildConfiguration::createConfigWidget()
return new GenericBuildSettingsWidget;
}
IOutputParser *GenericBuildConfiguration::createOutputParser() const
{
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
return tc ? tc->outputParser() : 0;
}
/*!
\class GenericBuildConfigurationFactory
......
......@@ -56,7 +56,6 @@ public:
void setBuildDirectory(const QString &buildDirectory);
QVariantMap toMap() const;
ProjectExplorer::IOutputParser *createOutputParser() const;
BuildType buildType() const;
protected:
......
......@@ -129,11 +129,9 @@ bool GenericMakeStep::init()
setIgnoreReturnValue(m_clean);
setOutputParser(new GnuMakeParser());
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
if (version)
appendOutputParser(new QtSupport::QtParser);
if (tc)
appendOutputParser(tc->outputParser());
IOutputParser *parser = target()->kit()->createOutputParser();
if (parser)
appendOutputParser(parser);
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
return AbstractProcessStep::init();
......
......@@ -76,13 +76,6 @@ public:
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;
virtual bool isEnabled() const;
......
......@@ -34,6 +34,7 @@
#include "kitmanager.h"
#include "project.h"
#include "toolchainmanager.h"
#include "ioutputparser.h"
#include <utils/qtcassert.h>
......@@ -363,6 +364,23 @@ void Kit::addToEnvironment(Utils::Environment &env) const
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 rc;
......
......@@ -40,6 +40,7 @@
namespace Utils { class Environment; }
namespace ProjectExplorer {
class IOutputParser;
namespace Internal {
class KitManagerPrivate;
......@@ -88,6 +89,7 @@ public:
bool isEqual(const Kit *other) const;
void addToEnvironment(Utils::Environment &env) const;
IOutputParser *createOutputParser() const;
QString toHtml();
Kit *clone(bool keepName = false) const;
......
......@@ -207,6 +207,14 @@ void ToolChainKitInformation::addToEnvironment(const Kit *k, Utils::Environment
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)
{
if (!k)
......
......@@ -112,6 +112,7 @@ public:
ItemList toUserOutput(Kit *k) const;
void addToEnvironment(const Kit *k, Utils::Environment &env) const;
IOutputParser *createOutputParser(const Kit *k) const;
static ToolChain *toolChain(const Kit *k);
static void setToolChain(Kit *k, ToolChain *tc);
......
......@@ -454,6 +454,12 @@ void KitInformation::addToEnvironment(const Kit *k, Utils::Environment &env) con
Q_UNUSED(env);
}
IOutputParser *KitInformation::createOutputParser(const Kit *k) const
{
Q_UNUSED(k);
return 0;
}
QString KitInformation::displayNamePostfix(const Kit *k) const
{
Q_UNUSED(k);
......
......@@ -43,6 +43,7 @@
namespace Utils { class Environment; }
namespace ProjectExplorer {
class IOutputParser;
class Kit;
class KitConfigWidget;
......@@ -82,6 +83,7 @@ public:
virtual KitConfigWidget *createConfigWidget(Kit *) const = 0;
virtual void addToEnvironment(const Kit *k, Utils::Environment &env) const;
virtual IOutputParser *createOutputParser(const Kit *k) const;
virtual QString displayNamePostfix(const Kit *k) const;
......
......@@ -33,6 +33,7 @@
#include "buildconfiguration.h"
#include "projectexplorerconstants.h"
#include "target.h"
#include "kit.h"
#include <coreplugin/idocument.h>
#include <utils/qtcprocess.h>
......@@ -95,7 +96,9 @@ bool ProcessStep::init()
pp->setWorkingDirectory(workingDirectory());
pp->setCommand(m_command);
pp->setArguments(m_arguments);
setOutputParser(bc->createOutputParser());
IOutputParser *parser = target()->kit()->createOutputParser();
if (parser)
setOutputParser(parser);
return AbstractProcessStep::init();
}
......
......@@ -38,6 +38,7 @@
#include <projectexplorer/target.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/gnumakeparser.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/kitinformation.h>
......@@ -248,20 +249,11 @@ bool MakeStep::init()
pp->setEnvironment(env);
pp->setArguments(args);
IOutputParser *parser = 0;
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit());
if (version)
parser = version->createOutputParser();
setOutputParser(new ProjectExplorer::GnuMakeParser());
IOutputParser *parser = target()->kit()->createOutputParser();
if (parser)
parser->appendOutputParser(new QtSupport::QtParser);
else
parser = new QtSupport::QtParser;
if (tc)
parser->appendOutputParser(tc->outputParser());
parser->setWorkingDirectory(workingDirectory);
setOutputParser(parser);
appendOutputParser(parser);
outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory());
m_scriptTarget = (static_cast<Qt4Project *>(bc->target()->project())->rootQt4ProjectNode()->projectType() == ScriptTemplate);
......
......@@ -538,12 +538,6 @@ FileName Qt4BuildConfiguration::extractSpecFromArguments(QString *args,
return parsedSpec;
}
IOutputParser *Qt4BuildConfiguration::createOutputParser() const
{
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
return tc ? tc->outputParser() : 0;
}
bool Qt4BuildConfiguration::isEnabled() const
{
return m_isEnabled;
......
......@@ -98,8 +98,6 @@ public:
QVariantMap toMap() const;
ProjectExplorer::IOutputParser *createOutputParser() const;
virtual bool isEnabled() const;
virtual QString disabledReason() const;
/// \internal For Qt4Project, since that manages the parsing information
......
......@@ -1162,11 +1162,6 @@ BaseQtVersion::reportIssues(const QString &proFile, const QString &buildDir) con
return results;
}
ProjectExplorer::IOutputParser *BaseQtVersion::createOutputParser() const
{
return new ProjectExplorer::GnuMakeParser;
}
QtConfigWidget *BaseQtVersion::createConfigurationWidget() const
{
return 0;
......
......@@ -185,8 +185,6 @@ public:
/// warnings and finally info items.
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, bool *qmakeIsExecutable);
static Utils::FileName mkspecDirectoryFromVersionInfo(const QHash<QString, QString> &versionInfo);
......
......@@ -32,6 +32,7 @@
#include "qtkitconfigwidget.h"
#include "qtsupportconstants.h"
#include "qtversionmanager.h"
#include "qtparser.h"
#include <utils/environment.h>
......@@ -126,6 +127,13 @@ void QtKitInformation::addToEnvironment(const ProjectExplorer::Kit *k, Utils::En
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)
{
if (!k)
......
......@@ -61,6 +61,7 @@ public:
ItemList toUserOutput(ProjectExplorer::Kit *k) 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 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