diff options
Diffstat (limited to 'src/plugins/projectexplorer/runcontrol.cpp')
-rw-r--r-- | src/plugins/projectexplorer/runcontrol.cpp | 107 |
1 files changed, 51 insertions, 56 deletions
diff --git a/src/plugins/projectexplorer/runcontrol.cpp b/src/plugins/projectexplorer/runcontrol.cpp index 1bd5d90f9a..a7d3a075fa 100644 --- a/src/plugins/projectexplorer/runcontrol.cpp +++ b/src/plugins/projectexplorer/runcontrol.cpp @@ -26,16 +26,17 @@ #include "runcontrol.h" #include "devicesupport/desktopdevice.h" -#include "project.h" -#include "target.h" -#include "toolchain.h" #include "abi.h" #include "buildconfiguration.h" +#include "customparser.h" #include "environmentaspect.h" #include "kitinformation.h" +#include "project.h" +#include "projectexplorer.h" #include "runconfigurationaspects.h" #include "session.h" -#include "kitinformation.h" +#include "target.h" +#include "toolchain.h" #include <utils/algorithm.h> #include <utils/checkablemessagebox.h> @@ -73,13 +74,13 @@ namespace ProjectExplorer { static QList<RunWorkerFactory *> g_runWorkerFactories; -static QSet<Core::Id> g_runModes; -static QSet<Core::Id> g_runConfigs; +static QSet<Utils::Id> g_runModes; +static QSet<Utils::Id> g_runConfigs; RunWorkerFactory::RunWorkerFactory(const WorkerCreator &producer, - const QList<Core::Id> &runModes, - const QList<Core::Id> &runConfigs, - const QList<Core::Id> &deviceTypes) + const QList<Utils::Id> &runModes, + const QList<Utils::Id> &runConfigs, + const QList<Utils::Id> &deviceTypes) : m_producer(producer), m_supportedRunModes(runModes), m_supportedRunConfigurations(runConfigs), @@ -88,9 +89,9 @@ RunWorkerFactory::RunWorkerFactory(const WorkerCreator &producer, g_runWorkerFactories.append(this); // Debugging only. - for (Core::Id runMode : runModes) + for (Utils::Id runMode : runModes) g_runModes.insert(runMode); - for (Core::Id runConfig : runConfigs) + for (Utils::Id runConfig : runConfigs) g_runConfigs.insert(runConfig); } @@ -99,8 +100,8 @@ RunWorkerFactory::~RunWorkerFactory() g_runWorkerFactories.removeOne(this); } -bool RunWorkerFactory::canRun(Core::Id runMode, - Core::Id deviceType, +bool RunWorkerFactory::canRun(Utils::Id runMode, + Utils::Id deviceType, const QString &runConfigId) const { if (!m_supportedRunModes.contains(runMode)) @@ -111,7 +112,7 @@ bool RunWorkerFactory::canRun(Core::Id runMode, //if (!m_supportedRunConfigurations.contains(runConfigId) // return false; bool ok = false; - for (const Core::Id &id : m_supportedRunConfigurations) { + for (const Utils::Id &id : m_supportedRunConfigurations) { if (runConfigId.startsWith(id.toString())) { ok = true; break; @@ -130,13 +131,13 @@ bool RunWorkerFactory::canRun(Core::Id runMode, void RunWorkerFactory::dumpAll() { - const QList<Core::Id> devices = + const QList<Utils::Id> devices = Utils::transform(IDeviceFactory::allDeviceFactories(), &IDeviceFactory::deviceType); - for (Core::Id runMode : qAsConst(g_runModes)) { + for (Utils::Id runMode : qAsConst(g_runModes)) { qDebug() << ""; - for (Core::Id device : devices) { - for (Core::Id runConfig : qAsConst(g_runConfigs)) { + for (Utils::Id device : devices) { + for (Utils::Id runConfig : qAsConst(g_runConfigs)) { const auto check = std::bind(&RunWorkerFactory::canRun, std::placeholders::_1, runMode, @@ -275,11 +276,10 @@ static QString stateName(RunControlState s) class RunControlPrivate : public QObject { public: - RunControlPrivate(RunControl *parent, Core::Id mode) + RunControlPrivate(RunControl *parent, Utils::Id mode) : q(parent), runMode(mode) { icon = Icons::RUN_SMALL_TOOLBAR; - outputFormatter = new OutputFormatter(); } ~RunControlPrivate() override @@ -289,7 +289,6 @@ public: q = nullptr; qDeleteAll(m_workers); m_workers.clear(); - delete outputFormatter; } Q_ENUM(RunControlState) @@ -320,13 +319,13 @@ public: QString displayName; Runnable runnable; IDevice::ConstPtr device; - Core::Id runMode; + Utils::Id runMode; Utils::Icon icon; - MacroExpander *macroExpander; + const MacroExpander *macroExpander; QPointer<RunConfiguration> runConfiguration; // Not owned. Avoid use. QString buildKey; - QMap<Core::Id, QVariantMap> settingsData; - Core::Id runConfigId; + QMap<Utils::Id, QVariantMap> settingsData; + Utils::Id runConfigId; BuildTargetInfo buildTargetInfo; BuildConfiguration::BuildType buildType = BuildConfiguration::Unknown; FilePath buildDirectory; @@ -334,7 +333,6 @@ public: Kit *kit = nullptr; // Not owned. QPointer<Target> target; // Not owned. QPointer<Project> project; // Not owned. - QPointer<Utils::OutputFormatter> outputFormatter = nullptr; std::function<bool(bool*)> promptToStop; std::vector<RunWorkerFactory> m_factories; @@ -350,7 +348,7 @@ public: using namespace Internal; -RunControl::RunControl(Core::Id mode) : +RunControl::RunControl(Utils::Id mode) : d(std::make_unique<RunControlPrivate>(this, mode)) { } @@ -385,11 +383,6 @@ void RunControl::setTarget(Target *target) d->buildEnvironment = bc->environment(); } - delete d->outputFormatter; - d->outputFormatter = OutputFormatterFactory::createFormatter(target); - if (!d->outputFormatter) - d->outputFormatter = new OutputFormatter(); - setKit(target->kit()); d->project = target->project(); } @@ -466,7 +459,7 @@ void RunControl::initiateFinish() QTimer::singleShot(0, d.get(), &RunControlPrivate::initiateFinish); } -RunWorker *RunControl::createWorker(Core::Id workerId) +RunWorker *RunControl::createWorker(Utils::Id workerId) { const auto check = std::bind(&RunWorkerFactory::canRun, std::placeholders::_1, @@ -496,7 +489,7 @@ bool RunControl::createMainWorker() return candidates.front()->producer()(this) != nullptr; } -bool RunControl::canRun(Core::Id runMode, Core::Id deviceType, Core::Id runConfigId) +bool RunControl::canRun(Utils::Id runMode, Utils::Id deviceType, Utils::Id runConfigId) { const auto check = std::bind(&RunWorkerFactory::canRun, std::placeholders::_1, @@ -831,12 +824,20 @@ void RunControlPrivate::showError(const QString &msg) q->appendMessage(msg + '\n', ErrorMessageFormat); } -Utils::OutputFormatter *RunControl::outputFormatter() const +QList<Utils::OutputLineParser *> RunControl::createOutputParsers() const { - return d->outputFormatter; + QList<Utils::OutputLineParser *> parsers = OutputFormatterFactory::createFormatters(target()); + if (const auto customParsersAspect + = (runConfiguration() ? runConfiguration()->aspect<CustomParsersAspect>() : nullptr)) { + for (const Utils::Id id : customParsersAspect->parsers()) { + if (CustomParser * const parser = CustomParser::createFromId(id)) + parsers << parser; + } + } + return parsers; } -Core::Id RunControl::runMode() const +Utils::Id RunControl::runMode() const { return d->runMode; } @@ -896,17 +897,17 @@ Kit *RunControl::kit() const return d->kit; } -MacroExpander *RunControl::macroExpander() const +const MacroExpander *RunControl::macroExpander() const { return d->macroExpander; } -ProjectConfigurationAspect *RunControl::aspect(Core::Id id) const +ProjectConfigurationAspect *RunControl::aspect(Utils::Id id) const { return d->runConfiguration ? d->runConfiguration->aspect(id) : nullptr; } -QVariantMap RunControl::settingsData(Core::Id id) const +QVariantMap RunControl::settingsData(Utils::Id id) const { return d->settingsData.value(id); } @@ -1037,7 +1038,7 @@ bool RunControl::showPromptToStopDialog(const QString &title, { // Show a question message box where user can uncheck this // question for this class. - Utils::CheckableMessageBox messageBox(Core::ICore::mainWindow()); + Utils::CheckableMessageBox messageBox(Core::ICore::dialogParent()); messageBox.setWindowTitle(title); messageBox.setText(text); messageBox.setStandardButtons(QDialogButtonBox::Yes|QDialogButtonBox::Cancel); @@ -1214,12 +1215,12 @@ void SimpleTargetRunner::doStart(const Runnable &runnable, const IDevice::ConstP connect(&m_launcher, &ApplicationLauncher::remoteStderr, this, [this](const QString &output) { - appendMessage(output, Utils::StdErrFormatSameLine, false); + appendMessage(output, Utils::StdErrFormat, false); }); connect(&m_launcher, &ApplicationLauncher::remoteStdout, this, [this](const QString &output) { - appendMessage(output, Utils::StdOutFormatSameLine, false); + appendMessage(output, Utils::StdOutFormat, false); }); connect(&m_launcher, &ApplicationLauncher::finished, @@ -1601,11 +1602,7 @@ static QList<OutputFormatterFactory *> g_outputFormatterFactories; OutputFormatterFactory::OutputFormatterFactory() { - // This is a bit cheating: We know that only two formatters exist right now, - // and this here gives the second (python) implicit more priority. - // For a final solution, probably all matching formatters should be used - // in parallel, so there's no need to invent a fancy priority system here. - g_outputFormatterFactories.prepend(this); + g_outputFormatterFactories.append(this); } OutputFormatterFactory::~OutputFormatterFactory() @@ -1613,17 +1610,15 @@ OutputFormatterFactory::~OutputFormatterFactory() g_outputFormatterFactories.removeOne(this); } -OutputFormatter *OutputFormatterFactory::createFormatter(Target *target) +QList<OutputLineParser *> OutputFormatterFactory::createFormatters(Target *target) { - for (auto factory : qAsConst(g_outputFormatterFactories)) { - if (auto formatter = factory->m_creator(target)) - return formatter; - } - return nullptr; + QList<OutputLineParser *> formatters; + for (auto factory : qAsConst(g_outputFormatterFactories)) + formatters << factory->m_creator(target); + return formatters; } -void OutputFormatterFactory::setFormatterCreator - (const std::function<OutputFormatter *(Target *)> &creator) +void OutputFormatterFactory::setFormatterCreator(const FormatterCreator &creator) { m_creator = creator; } |