diff options
author | hjk <hjk@qt.io> | 2017-06-19 13:27:59 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2017-06-20 08:04:33 +0000 |
commit | f047e1a2a2ac6667d7d19c95e3f6bb96e17f2a5a (patch) | |
tree | 3e5d2c507350212821242829784adacd39244168 /src | |
parent | 1cb8e1d291fdaf46b5d0435249edb72198271ded (diff) | |
download | qt-creator-f047e1a2a2ac6667d7d19c95e3f6bb96e17f2a5a.tar.gz |
ProjectExplorer: Simplify standard run control construction
A lot of the target-and-tool specific run controls nowadays
have something like a single main RunWorker. This patch
removes the need to have user-implemented RunControlFactories
in those cases and adjusts local run, remote linux,
python and nim to take advantage.
There's more potential use downstream.
Change-Id: Ie2d2f839b8be1fad2be3b79e21de3c0e475d88cf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src')
19 files changed, 141 insertions, 401 deletions
diff --git a/src/plugins/nim/nim.pro b/src/plugins/nim/nim.pro index f048d92e93..ae570653a0 100644 --- a/src/plugins/nim/nim.pro +++ b/src/plugins/nim/nim.pro @@ -29,7 +29,6 @@ HEADERS += \ project/nimcompilerbuildstepfactory.h \ project/nimcompilercleanstepfactory.h \ project/nimbuildconfigurationwidget.h \ - project/nimruncontrolfactory.h \ editor/nimeditorfactory.h \ settings/nimcodestylesettingspage.h \ settings/nimcodestylepreferencesfactory.h \ @@ -57,7 +56,6 @@ SOURCES += \ project/nimcompilerbuildstepfactory.cpp \ project/nimcompilercleanstepfactory.cpp \ project/nimbuildconfigurationwidget.cpp \ - project/nimruncontrolfactory.cpp \ editor/nimeditorfactory.cpp \ settings/nimcodestylesettingspage.cpp \ settings/nimcodestylepreferencesfactory.cpp \ diff --git a/src/plugins/nim/nim.qbs b/src/plugins/nim/nim.qbs index 735e0f7338..5b6d140719 100644 --- a/src/plugins/nim/nim.qbs +++ b/src/plugins/nim/nim.qbs @@ -49,7 +49,6 @@ QtcPlugin { "nimrunconfiguration.h", "nimrunconfiguration.cpp", "nimrunconfigurationfactory.h", "nimrunconfigurationfactory.cpp", "nimrunconfigurationwidget.h", "nimrunconfigurationwidget.cpp", - "nimruncontrolfactory.h", "nimruncontrolfactory.cpp", "nimtoolchain.h", "nimtoolchain.cpp", "nimtoolchainfactory.h", "nimtoolchainfactory.cpp", ] diff --git a/src/plugins/nim/nimplugin.cpp b/src/plugins/nim/nimplugin.cpp index 8dc128da03..b07d847219 100644 --- a/src/plugins/nim/nimplugin.cpp +++ b/src/plugins/nim/nimplugin.cpp @@ -32,8 +32,8 @@ #include "project/nimcompilerbuildstepfactory.h" #include "project/nimcompilercleanstepfactory.h" #include "project/nimproject.h" +#include "project/nimrunconfiguration.h" #include "project/nimrunconfigurationfactory.h" -#include "project/nimruncontrolfactory.h" #include "project/nimtoolchainfactory.h" #include "settings/nimcodestylepreferencesfactory.h" #include "settings/nimcodestylesettingspage.h" @@ -42,11 +42,13 @@ #include <coreplugin/fileiconprovider.h> #include <projectexplorer/projectmanager.h> #include <projectexplorer/toolchainmanager.h> +#include <projectexplorer/runconfiguration.h> #include <texteditor/snippets/snippetprovider.h> #include <QtPlugin> using namespace Utils; +using namespace ProjectExplorer; namespace Nim { @@ -69,13 +71,15 @@ bool NimPlugin::initialize(const QStringList &arguments, QString *errorMessage) ProjectExplorer::ToolChainManager::registerLanguage(Constants::C_NIMLANGUAGE_ID, Constants::C_NIMLANGUAGE_NAME); + RunControl::registerWorker<NimRunConfiguration, SimpleTargetRunner> + (ProjectExplorer::Constants::NORMAL_RUN_MODE); + addAutoReleasedObject(new NimSettings); addAutoReleasedObject(new NimEditorFactory); addAutoReleasedObject(new NimBuildConfigurationFactory); addAutoReleasedObject(new NimRunConfigurationFactory); addAutoReleasedObject(new NimCompilerBuildStepFactory); addAutoReleasedObject(new NimCompilerCleanStepFactory); - addAutoReleasedObject(new NimRunControlFactory); addAutoReleasedObject(new NimCodeStyleSettingsPage); addAutoReleasedObject(new NimCodeStylePreferencesFactory); addAutoReleasedObject(new NimToolChainFactory); diff --git a/src/plugins/nim/project/nimruncontrolfactory.cpp b/src/plugins/nim/project/nimruncontrolfactory.cpp deleted file mode 100644 index 55f6eaba1a..0000000000 --- a/src/plugins/nim/project/nimruncontrolfactory.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com> -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "nimruncontrolfactory.h" -#include "nimrunconfiguration.h" - -using namespace ProjectExplorer; - -namespace Nim { - -bool NimRunControlFactory::canRun(ProjectExplorer::RunConfiguration *runConfiguration, Core::Id mode) const -{ - Q_UNUSED(mode) - return dynamic_cast<NimRunConfiguration *>(runConfiguration); -} - -RunControl *NimRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) -{ - Q_UNUSED(errorMessage) - QTC_ASSERT(canRun(runConfiguration, mode), return 0); - auto runControl = new RunControl(runConfiguration, mode); - (void) new SimpleTargetRunner(runControl); - return runControl; -} - -} // Nim - diff --git a/src/plugins/nim/project/nimruncontrolfactory.h b/src/plugins/nim/project/nimruncontrolfactory.h deleted file mode 100644 index cee570322b..0000000000 --- a/src/plugins/nim/project/nimruncontrolfactory.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com> -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <projectexplorer/runconfiguration.h> - -namespace Nim { - -class NimRunControlFactory : public ProjectExplorer::IRunControlFactory -{ -public: - bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, Core::Id mode) const override; - ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) override; -}; - -} diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp deleted file mode 100644 index 433998fc64..0000000000 --- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "localapplicationruncontrol.h" -#include "runnables.h" - -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/target.h> - -#include <utils/utilsicons.h> -#include <utils/qtcassert.h> - -using namespace Utils; - -namespace ProjectExplorer { -namespace Internal { - -static bool isLocal(RunConfiguration *runConfiguration) -{ - Target *target = runConfiguration ? runConfiguration->target() : nullptr; - Kit *kit = target ? target->kit() : nullptr; - return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; -} - -bool LocalApplicationRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const -{ - if (mode != Constants::NORMAL_RUN_MODE) - return false; - const Runnable runnable = runConfiguration->runnable(); - if (!runnable.is<StandardRunnable>()) - return false; - const IDevice::ConstPtr device = runnable.as<StandardRunnable>().device; - if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) - return true; - return isLocal(runConfiguration); -} - -RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) -{ - Q_UNUSED(errorMessage) - auto runControl = new RunControl(runConfiguration, mode); - (void) new SimpleTargetRunner(runControl); - return runControl; -} - -} // namespace Internal -} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.h b/src/plugins/projectexplorer/localapplicationruncontrol.h deleted file mode 100644 index 940a5586ca..0000000000 --- a/src/plugins/projectexplorer/localapplicationruncontrol.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "runconfiguration.h" - -namespace ProjectExplorer { -namespace Internal { - -class LocalApplicationRunControlFactory : public IRunControlFactory -{ - Q_OBJECT -public: - bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const override; - RunControl *create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) override; -}; - -} // namespace Internal -} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 035040a609..6351c228ce 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -52,7 +52,6 @@ #include "copytaskhandler.h" #include "showineditortaskhandler.h" #include "vcsannotatetaskhandler.h" -#include "localapplicationruncontrol.h" #include "allprojectsfilter.h" #include "allprojectsfind.h" #include "buildmanager.h" @@ -644,7 +643,19 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er addAutoReleasedObject(new AllProjectsFind); addAutoReleasedObject(new CurrentProjectFind); - addAutoReleasedObject(new LocalApplicationRunControlFactory); + auto constraint = [](RunConfiguration *runConfiguration) { + const Runnable runnable = runConfiguration->runnable(); + if (!runnable.is<StandardRunnable>()) + return false; + const IDevice::ConstPtr device = runnable.as<StandardRunnable>().device; + if (device && device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) + return true; + Target *target = runConfiguration ? runConfiguration->target() : nullptr; + Kit *kit = target ? target->kit() : nullptr; + return DeviceTypeKitInformation::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE; + }; + RunControl::registerWorker<SimpleTargetRunner>(Constants::NORMAL_RUN_MODE, constraint); + addAutoReleasedObject(new CustomExecutableRunConfigurationFactory); addAutoReleasedObject(new ProjectFileWizardExtension); @@ -1972,12 +1983,30 @@ void ProjectExplorerPluginPrivate::buildStateChanged(Project * pro) } // NBS TODO implement more than one runner -static IRunControlFactory *findRunControlFactory(RunConfiguration *config, Core::Id mode) +using RunControlFactory = std::function<RunControl *(RunConfiguration *, Core::Id, QString *)>; + +static RunControlFactory findRunControlFactory(RunConfiguration *config, Core::Id mode) { - return ExtensionSystem::PluginManager::getObject<IRunControlFactory>( + if (auto producer = RunControl::producer(config, mode)) { + return [producer, config](RunConfiguration *rc, Id runMode, QString *) { + auto runControl = new RunControl(rc, runMode); + (void) producer(runControl); + return runControl; + }; + } + + IRunControlFactory *runControlFactory = ExtensionSystem::PluginManager::getObject<IRunControlFactory>( [&config, &mode](IRunControlFactory *factory) { return factory->canRun(config, mode); }); + + if (runControlFactory) { + return [runControlFactory](RunConfiguration *rc, Id runMode, QString *errorMessage) { + return runControlFactory->create(rc, runMode, errorMessage); + }; + } + + return {}; } void ProjectExplorerPluginPrivate::executeRunConfiguration(RunConfiguration *runConfiguration, Core::Id runMode) @@ -1997,11 +2026,11 @@ void ProjectExplorerPluginPrivate::executeRunConfiguration(RunConfiguration *run } } - if (IRunControlFactory *runControlFactory = findRunControlFactory(runConfiguration, runMode)) { + if (RunControlFactory runControlFactory = findRunControlFactory(runConfiguration, runMode)) { emit m_instance->aboutToExecuteProject(runConfiguration->target()->project(), runMode); QString errorMessage; - RunControl *control = runControlFactory->create(runConfiguration, runMode, &errorMessage); + RunControl *control = runControlFactory(runConfiguration, runMode, &errorMessage); if (!control) { m_instance->showRunErrorMessage(errorMessage); return; diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 88f0f4f003..31987ee6ee 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -99,7 +99,6 @@ HEADERS += projectexplorer.h \ processparameters.h \ abstractprocessstep.h \ taskhub.h \ - localapplicationruncontrol.h \ headerpath.h \ gcctoolchainfactories.h \ appoutputpane.h \ @@ -243,7 +242,6 @@ SOURCES += projectexplorer.cpp \ buildconfigurationmodel.cpp \ taskhub.cpp \ processparameters.cpp \ - localapplicationruncontrol.cpp \ appoutputpane.cpp \ codestylesettingspropertiespage.cpp \ settingsaccessor.cpp \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 999ae6c27e..f61ab5a221 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -94,7 +94,6 @@ Project { "kitoptionspage.cpp", "kitoptionspage.h", "ldparser.cpp", "ldparser.h", "linuxiccparser.cpp", "linuxiccparser.h", - "localapplicationruncontrol.cpp", "localapplicationruncontrol.h", "localenvironmentaspect.cpp", "localenvironmentaspect.h", "miniprojecttargetselector.cpp", "miniprojecttargetselector.h", "msvcparser.cpp", "msvcparser.h", diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 25cea48b0f..d496f35b53 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -479,6 +479,35 @@ IRunControlFactory::IRunControlFactory(QObject *parent) { } +using WorkerFactories = std::vector<RunControl::WorkerFactory>; + +static WorkerFactories &theWorkerFactories() +{ + static WorkerFactories factories; + return factories; +} + +bool IRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id runMode) const +{ + for (const RunControl::WorkerFactory &factory : theWorkerFactories()) { + if (factory.runMode == runMode && factory.constraint(runConfiguration)) + return true; + }; + return false; +} + +RunControl *IRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id runMode, QString *) +{ + for (const RunControl::WorkerFactory &factory : theWorkerFactories()) { + if (factory.runMode == runMode && factory.constraint(runConfiguration)) { + auto runControl = new RunControl(runConfiguration, runMode); + factory.producer(runControl); + return runControl; + } + }; + return nullptr; +} + /*! Returns an IRunConfigurationAspect to carry options for RunControls this factory can create. @@ -628,6 +657,7 @@ public: QPointer<Project> project; // Not owned. Utils::OutputFormatter *outputFormatter = nullptr; std::function<bool(bool*)> promptToStop; + std::vector<RunControl::WorkerFactory> m_factories; // A handle to the actual application process. Utils::ProcessHandle applicationProcessHandle; @@ -724,7 +754,7 @@ RunWorker *RunControl::createWorker(Core::Id id) { auto keys = theWorkerCreators().keys(); Q_UNUSED(keys); - RunWorkerCreator creator = theWorkerCreators().value(id); + Producer creator = theWorkerCreators().value(id); if (creator) return creator(this); creator = device()->workerCreator(id); @@ -733,6 +763,20 @@ RunWorker *RunControl::createWorker(Core::Id id) return nullptr; } +RunControl::Producer RunControl::producer(RunConfiguration *runConfiguration, Core::Id runMode) +{ + for (const auto &factory : theWorkerFactories()) { + if (factory.runMode == runMode && factory.constraint(runConfiguration)) + return factory.producer; + } + return {}; +} + +void RunControl::addWorkerFactory(const RunControl::WorkerFactory &workerFactory) +{ + theWorkerFactories().push_back(workerFactory); +} + void RunControlPrivate::initiateStart() { checkState(RunControlState::Initialized); diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index b95a7b8a28..bdcc494f71 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -337,8 +337,8 @@ class PROJECTEXPLORER_EXPORT IRunControlFactory : public QObject public: explicit IRunControlFactory(QObject *parent = nullptr); - virtual bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const = 0; - virtual RunControl *create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) = 0; + virtual bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const; + virtual RunControl *create(RunConfiguration *runConfiguration, Core::Id runMode, QString *errorMessage); virtual IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc); }; @@ -492,10 +492,33 @@ public: return nullptr; } - using RunWorkerCreator = std::function<RunWorker *(RunControl *)>; - static void registerRunWorkerCreator(Core::Id id, const RunWorkerCreator &creator); RunWorker *createWorker(Core::Id id); + using Producer = std::function<RunWorker *(RunControl *)>; + using Constraint = std::function<bool(RunConfiguration *)>; + + template <class Worker> + static void registerWorker(Core::Id runMode, const Constraint &constraint) + { + auto producer = [](RunControl *rc) { return new Worker(rc); }; + addWorkerFactory({runMode, constraint, producer}); + } + template <class Config, class Worker> + static void registerWorker(Core::Id runMode) + { + auto constraint = [](RunConfiguration *runConfig) { return qobject_cast<Config *>(runConfig); }; + auto producer = [](RunControl *rc) { return new Worker(rc); }; + addWorkerFactory({runMode, constraint, producer}); + } + + struct WorkerFactory { + Core::Id runMode; + Constraint constraint; + Producer producer; + }; + + static Producer producer(RunConfiguration *runConfiguration, Core::Id runMode); + signals: void appendMessageRequested(ProjectExplorer::RunControl *runControl, const QString &msg, Utils::OutputFormat format); @@ -509,6 +532,8 @@ private: friend class RunWorker; friend class Internal::RunWorkerPrivate; + static void addWorkerFactory(const WorkerFactory &workerFactory); + void bringApplicationToForegroundInternal(); Internal::RunControlPrivate *d; }; diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index 8487079b47..bb90706784 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -655,30 +655,6 @@ bool PythonProjectNode::renameFile(const QString &filePath, const QString &newFi return m_project->renameFile(filePath, newFilePath); } -// PythonRunControlFactory - -class PythonRunControlFactory : public IRunControlFactory -{ -public: - bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const override; - RunControl *create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) override; -}; - -bool PythonRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const -{ - auto rc = dynamic_cast<PythonRunConfiguration *>(runConfiguration); - return mode == ProjectExplorer::Constants::NORMAL_RUN_MODE && rc && !rc->interpreter().isEmpty(); -} - -RunControl *PythonRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) -{ - Q_UNUSED(errorMessage) - QTC_ASSERT(canRun(runConfiguration, mode), return 0); - auto runControl = new RunControl(runConfiguration, mode); - (void) new SimpleTargetRunner(runControl); - return runControl; -} - // PythonRunConfigurationWidget void PythonRunConfigurationWidget::setInterpreter(const QString &interpreter) @@ -713,7 +689,12 @@ bool PythonEditorPlugin::initialize(const QStringList &arguments, QString *error addAutoReleasedObject(new PythonEditorFactory); addAutoReleasedObject(new PythonRunConfigurationFactory); - addAutoReleasedObject(new PythonRunControlFactory); + + auto constraint = [](RunConfiguration *runConfiguration) { + auto rc = dynamic_cast<PythonRunConfiguration *>(runConfiguration); + return rc && !rc->interpreter().isEmpty(); + }; + RunControl::registerWorker<SimpleTargetRunner>(ProjectExplorer::Constants::NORMAL_RUN_MODE, constraint); return true; } diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp index 5d9ed55376..7f7e687d56 100644 --- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp +++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp @@ -34,7 +34,6 @@ #include <projectexplorer/buildstep.h> #include <projectexplorer/buildsteplist.h> #include <projectexplorer/deployconfiguration.h> -#include <projectexplorer/localapplicationruncontrol.h> #include <projectexplorer/localenvironmentaspect.h> #include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/target.h> diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro index 570034882e..5167f61ace 100644 --- a/src/plugins/remotelinux/remotelinux.pro +++ b/src/plugins/remotelinux/remotelinux.pro @@ -16,7 +16,6 @@ HEADERS += \ genericlinuxdeviceconfigurationfactory.h \ remotelinuxrunconfigurationwidget.h \ remotelinuxrunconfigurationfactory.h \ - remotelinuxruncontrolfactory.h \ remotelinuxdebugsupport.h \ genericlinuxdeviceconfigurationwizardpages.h \ abstractremotelinuxdeploystep.h \ @@ -63,7 +62,6 @@ SOURCES += \ genericlinuxdeviceconfigurationfactory.cpp \ remotelinuxrunconfigurationwidget.cpp \ remotelinuxrunconfigurationfactory.cpp \ - remotelinuxruncontrolfactory.cpp \ remotelinuxdebugsupport.cpp \ genericlinuxdeviceconfigurationwizardpages.cpp \ abstractremotelinuxdeploystep.cpp \ diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 27fce5dbb8..3855efc24b 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -98,8 +98,6 @@ Project { "remotelinuxrunconfigurationfactory.h", "remotelinuxrunconfigurationwidget.cpp", "remotelinuxrunconfigurationwidget.h", - "remotelinuxruncontrolfactory.cpp", - "remotelinuxruncontrolfactory.h", "remotelinuxsignaloperation.cpp", "remotelinuxsignaloperation.h", "remotelinuxutils.cpp", diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index bde1411edc..15437952d9 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -28,9 +28,12 @@ #include "embeddedlinuxqtversionfactory.h" #include "genericlinuxdeviceconfigurationfactory.h" #include "genericremotelinuxdeploystepfactory.h" +#include "remotelinuxanalyzesupport.h" +#include "remotelinuxcustomrunconfiguration.h" +#include "remotelinuxdebugsupport.h" #include "remotelinuxdeployconfigurationfactory.h" +#include "remotelinuxrunconfiguration.h" #include "remotelinuxrunconfigurationfactory.h" -#include "remotelinuxruncontrolfactory.h" #include <QtPlugin> @@ -48,9 +51,24 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments, Q_UNUSED(arguments) Q_UNUSED(errorMessage) + using namespace ProjectExplorer; + using namespace ProjectExplorer::Constants; + + auto constraint = [](RunConfiguration *runConfig) { + const Core::Id id = runConfig->id(); + return id == RemoteLinuxCustomRunConfiguration::runConfigId() + || id.name().startsWith(RemoteLinuxRunConfiguration::IdPrefix); + }; + + RunControl::registerWorker<SimpleTargetRunner>(NORMAL_RUN_MODE, constraint); + RunControl::registerWorker<LinuxDeviceDebugSupport>(DEBUG_RUN_MODE, constraint); + RunControl::registerWorker<LinuxDeviceDebugSupport>(DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, + constraint); + RunControl::registerWorker<RemoteLinuxQmlProfilerSupport>(QML_PROFILER_RUN_MODE, constraint); + //RunControl::registerWorker<RemoteLinuxPerfSupport>(PERFPROFILER_RUN_MODE, constraint); + addAutoReleasedObject(new GenericLinuxDeviceConfigurationFactory); addAutoReleasedObject(new RemoteLinuxRunConfigurationFactory); - addAutoReleasedObject(new RemoteLinuxRunControlFactory); addAutoReleasedObject(new RemoteLinuxDeployConfigurationFactory); addAutoReleasedObject(new GenericRemoteLinuxDeployStepFactory); diff --git a/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp b/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp deleted file mode 100644 index 1d219a15ac..0000000000 --- a/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "remotelinuxruncontrolfactory.h" - -#include "remotelinuxanalyzesupport.h" -#include "remotelinuxdebugsupport.h" -#include "remotelinuxcustomrunconfiguration.h" -#include "remotelinuxrunconfiguration.h" - -#include <debugger/debuggerruncontrol.h> - -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/runnables.h> -#include <projectexplorer/target.h> - -#include <utils/portlist.h> -#include <utils/qtcassert.h> - -using namespace Debugger; -using namespace ProjectExplorer; - -namespace RemoteLinux { -namespace Internal { - -RemoteLinuxRunControlFactory::RemoteLinuxRunControlFactory(QObject *parent) - : IRunControlFactory(parent) -{ -} - -bool RemoteLinuxRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const -{ - if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE - && mode != ProjectExplorer::Constants::DEBUG_RUN_MODE - && mode != ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN - && mode != ProjectExplorer::Constants::QML_PROFILER_RUN_MODE -// && mode != ProjectExplorer::Constants::PERFPROFILER_RUN_MODE - ) { - return false; - } - - const Core::Id id = runConfiguration->id(); - return runConfiguration->isEnabled() - && (id == RemoteLinuxCustomRunConfiguration::runConfigId() - || id.name().startsWith(RemoteLinuxRunConfiguration::IdPrefix)); -} - -RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Core::Id mode, - QString *) -{ - QTC_ASSERT(canRun(runConfig, mode), return 0); - - if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) { - auto runControl = new RunControl(runConfig, mode); - (void) new SimpleTargetRunner(runControl); - return runControl; - } - - if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE - || mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) { - auto runControl = new RunControl(runConfig, mode); - (void) new LinuxDeviceDebugSupport(runControl); - return runControl; - } - - if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { - auto runControl = new RunControl(runConfig, mode); - (void) new RemoteLinuxQmlProfilerSupport(runControl); - return runControl; - } - - if ( mode == ProjectExplorer::Constants::PERFPROFILER_RUN_MODE) { - auto runControl = new RunControl(runConfig, mode); - (void) new RemoteLinuxPerfSupport(runControl); - return runControl; - } - QTC_CHECK(false); - return 0; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/remotelinuxruncontrolfactory.h b/src/plugins/remotelinux/remotelinuxruncontrolfactory.h deleted file mode 100644 index 6256fa80a8..0000000000 --- a/src/plugins/remotelinux/remotelinuxruncontrolfactory.h +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include <projectexplorer/runconfiguration.h> - -namespace RemoteLinux { -namespace Internal { - -class RemoteLinuxRunControlFactory : public ProjectExplorer::IRunControlFactory -{ - Q_OBJECT -public: - explicit RemoteLinuxRunControlFactory(QObject *parent = 0); - - bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, - Core::Id mode) const override; - ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, - Core::Id mode, QString *errorMessage) override; -}; - -} // namespace Internal -} // namespace RemoteLinux |