ProjectExplorer: Re-work setup runworker factories

This combines two of the previous three paths to create run workers,
and refers to RunConfigurations by id, not by type where possible
to decrease coupling between the classes.

Only allow "type of run configuration" and "type of device"
as the only possible kind of restriction and require a uniform
RunWorker constructor signature.

Adapt user code to fit that pattern.

Change-Id: I5a6d49c9a144785fd0235d7586f244b56f67b366
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2019-08-07 18:05:15 +02:00
parent a88970db34
commit f9c221eb54
33 changed files with 289 additions and 308 deletions

View File

@@ -88,23 +88,13 @@ public:
} }
}; };
class QmlPreviewRunWorkerFactory : public RunWorkerFactory class AndroidQmlPreviewWorker : public AndroidQmlToolingSupport
{ {
public: public:
QmlPreviewRunWorkerFactory() AndroidQmlPreviewWorker(RunControl *runControl)
{ : AndroidQmlToolingSupport(runControl,
addSupportedRunMode(QML_PREVIEW_RUN_MODE); runControl->runConfiguration()->runnable().executable.toString())
setProducer([](RunControl *runControl) -> RunWorker * { {}
const Runnable runnable = runControl->runConfiguration()->runnable();
return new AndroidQmlToolingSupport(runControl, runnable.executable.toString());
});
addConstraint([](RunConfiguration *runConfig) {
return runConfig->isEnabled()
&& runConfig->id().name().startsWith("QmlProjectManager.QmlRunConfiguration")
&& DeviceTypeKitAspect::deviceTypeId(runConfig->target()->kit())
== Android::Constants::ANDROID_DEVICE_TYPE;
});
}
}; };
class AndroidPluginPrivate : public QObject class AndroidPluginPrivate : public QObject
@@ -151,14 +141,32 @@ public:
AndroidManifestEditorFactory manifestEditorFactory; AndroidManifestEditorFactory manifestEditorFactory;
AndroidRunConfigurationFactory runConfigFactory; AndroidRunConfigurationFactory runConfigFactory;
SimpleRunWorkerFactory<AndroidRunSupport, AndroidRunConfiguration> runWorkerFactory; RunWorkerFactory runWorkerFactory{
SimpleRunWorkerFactory<AndroidDebugSupport, AndroidRunConfiguration> RunWorkerFactory::make<AndroidRunSupport>(),
debugWorkerFactory{DEBUG_RUN_MODE}; {NORMAL_RUN_MODE},
SimpleRunWorkerFactory<AndroidQmlToolingSupport, AndroidRunConfiguration> {runConfigFactory.id()}
profilerWorkerFactory{QML_PROFILER_RUN_MODE}; };
SimpleRunWorkerFactory<AndroidQmlToolingSupport, AndroidRunConfiguration> RunWorkerFactory debugWorkerFactory{
qmlPreviewWorkerFactory{QML_PREVIEW_RUN_MODE}; RunWorkerFactory::make<AndroidDebugSupport>(),
QmlPreviewRunWorkerFactory qmlPreviewWorkerFactory2; {DEBUG_RUN_MODE},
{runConfigFactory.id()}
};
RunWorkerFactory profilerWorkerFactory{
RunWorkerFactory::make<AndroidQmlToolingSupport>(),
{QML_PROFILER_RUN_MODE},
{runConfigFactory.id()}
};
RunWorkerFactory qmlPreviewWorkerFactory{
RunWorkerFactory::make<AndroidQmlToolingSupport>(),
{QML_PREVIEW_RUN_MODE},
{runConfigFactory.id()}
};
RunWorkerFactory qmlPreviewWorkerFactory2{
RunWorkerFactory::make<AndroidQmlPreviewWorker>(),
{QML_PREVIEW_RUN_MODE},
{"QmlProjectManager.QmlRunConfiguration"},
{Android::Constants::ANDROID_DEVICE_TYPE}
};
AndroidBuildApkStepFactory buildApkStepFactory; AndroidBuildApkStepFactory buildApkStepFactory;
AndroidGdbServerKitAspect gdbServerKitAspect; AndroidGdbServerKitAspect gdbServerKitAspect;

View File

@@ -63,6 +63,12 @@ public:
BareMetalCustomRunConfigurationFactory customRunConfigurationFactory; BareMetalCustomRunConfigurationFactory customRunConfigurationFactory;
GdbServerProvidersSettingsPage gdbServerProviderSettinsPage; GdbServerProvidersSettingsPage gdbServerProviderSettinsPage;
GdbServerProviderManager gdbServerProviderManager; GdbServerProviderManager gdbServerProviderManager;
RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<BareMetalDebugSupport>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE, ProjectExplorer::Constants::DEBUG_RUN_MODE},
{runConfigurationFactory.id(), customRunConfigurationFactory.id()}
};
}; };
// BareMetalPlugin // BareMetalPlugin
@@ -78,19 +84,6 @@ bool BareMetalPlugin::initialize(const QStringList &arguments, QString *errorStr
Q_UNUSED(errorString) Q_UNUSED(errorString)
d = new BareMetalPluginPrivate; d = new BareMetalPluginPrivate;
auto constraint = [](RunConfiguration *runConfig) {
const QByteArray idStr = runConfig->id().name();
const bool res = idStr.startsWith(BareMetalRunConfiguration::IdPrefix)
|| idStr == BareMetalCustomRunConfiguration::Id;
return res;
};
RunControl::registerWorker<BareMetalDebugSupport>
(ProjectExplorer::Constants::NORMAL_RUN_MODE, constraint);
RunControl::registerWorker<BareMetalDebugSupport>
(ProjectExplorer::Constants::DEBUG_RUN_MODE, constraint);
return true; return true;
} }

View File

@@ -180,6 +180,36 @@ public:
QdbDeployStepFactory<RemoteLinux::GenericDirectUploadStep> QdbDeployStepFactory<RemoteLinux::GenericDirectUploadStep>
m_directUploadStepFactory; m_directUploadStepFactory;
const QList<Core::Id> supportedRunConfigs {
m_runConfigFactory.id(),
"QmlProjectManager.QmlRunConfiguration"
};
RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<QdbDeviceRunSupport>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
supportedRunConfigs,
{Qdb::Constants::QdbLinuxOsType}
};
RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<QdbDeviceDebugSupport>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE},
supportedRunConfigs,
{Qdb::Constants::QdbLinuxOsType}
};
RunWorkerFactory qmlProfilerWorkerFactory{
RunWorkerFactory::make<QdbDeviceQmlProfilerSupport>(),
{ProjectExplorer::Constants::QML_PROFILER_RUN_MODE},
supportedRunConfigs,
{Qdb::Constants::QdbLinuxOsType}
};
RunWorkerFactory qmlPreviewWorkerFactory{
RunWorkerFactory::make<QdbDeviceQmlPreviewSupport>(),
{ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE},
supportedRunConfigs,
{Qdb::Constants::QdbLinuxOsType}
};
DeviceDetector m_deviceDetector; DeviceDetector m_deviceDetector;
}; };
@@ -195,28 +225,6 @@ bool QdbPlugin::initialize(const QStringList &arguments, QString *errorString)
d = new QdbPluginPrivate; d = new QdbPluginPrivate;
auto constraint = [](RunConfiguration *runConfiguration) {
const Core::Id devType = DeviceTypeKitAspect::deviceTypeId(
runConfiguration->target()->kit());
if (devType != Qdb::Constants::QdbLinuxOsType)
return false;
const Core::Id id = runConfiguration->id();
return runConfiguration->isEnabled()
&& (id.name().startsWith(Constants::QdbRunConfigurationPrefix)
|| id.name().startsWith("QmlProjectManager.QmlRunConfiguration"));
};
RunControl::registerWorker<QdbDeviceRunSupport>
(ProjectExplorer::Constants::NORMAL_RUN_MODE, constraint);
RunControl::registerWorker<QdbDeviceDebugSupport>
(ProjectExplorer::Constants::DEBUG_RUN_MODE, constraint);
RunControl::registerWorker<QdbDeviceQmlProfilerSupport>
(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, constraint);
RunControl::registerWorker<QdbDeviceQmlPreviewSupport>
(ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE, constraint);
registerFlashAction(this); registerFlashAction(this);
return true; return true;

View File

@@ -610,6 +610,7 @@ private:
QHash<unsigned, QString> m_debugInfoTasks; QHash<unsigned, QString> m_debugInfoTasks;
}; };
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// //
// DebuggerPluginPrivate // DebuggerPluginPrivate
@@ -776,6 +777,18 @@ public:
Perspective m_perspective{Constants::PRESET_PERSPECTIVE_ID, tr("Debugger")}; Perspective m_perspective{Constants::PRESET_PERSPECTIVE_ID, tr("Debugger")};
DebuggerKitAspect debuggerKitAspect; DebuggerKitAspect debuggerKitAspect;
RunWorkerFactory debuggerWorkerFactory{
RunWorkerFactory::make<DebuggerRunTool>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE},
{}, // All local run configs?
{PE::DESKTOP_DEVICE_TYPE}
};
// FIXME: Needed?
// QString mainScript = runConfig->property("mainScript").toString();
// const bool isDebuggableScript = mainScript.endsWith(".py"); // Only Python for now.
// return isDebuggableScript;
}; };
DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin)
@@ -2086,23 +2099,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
} }
} }
auto constraint = [](RunConfiguration *runConfig) {
Runnable runnable = runConfig->runnable();
if (runnable.device && runnable.device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
return true;
if (DeviceTypeKitAspect::deviceTypeId(runConfig->target()->kit())
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE)
return true;
QString mainScript = runConfig->property("mainScript").toString();
const bool isDebuggableScript = mainScript.endsWith(".py"); // Only Python for now.
return isDebuggableScript;
};
RunControl::registerWorker<DebuggerRunTool>
(ProjectExplorer::Constants::DEBUG_RUN_MODE, constraint);
DebuggerMainWindow::ensureMainWindowExists(); DebuggerMainWindow::ensureMainWindowExists();
} }

View File

@@ -95,12 +95,21 @@ public:
IosDsymBuildStepFactory dsymBuildStepFactory; IosDsymBuildStepFactory dsymBuildStepFactory;
IosDeployConfigurationFactory deployConfigurationFactory; IosDeployConfigurationFactory deployConfigurationFactory;
SimpleRunWorkerFactory<Internal::IosRunSupport, IosRunConfiguration> RunWorkerFactory runWorkerFactory{
runWorkerFactory{ProjectExplorer::Constants::NORMAL_RUN_MODE}; RunWorkerFactory::make<IosRunSupport>(),
SimpleRunWorkerFactory<Internal::IosDebugSupport, IosRunConfiguration> {ProjectExplorer::Constants::NORMAL_RUN_MODE},
debugWorkerFactory{ProjectExplorer::Constants::DEBUG_RUN_MODE}; {runConfigurationFactory.id()}
SimpleRunWorkerFactory<Internal::IosQmlProfilerSupport, IosRunConfiguration> };
qmlProfilerWorkerFactory{ProjectExplorer::Constants::QML_PROFILER_RUN_MODE}; RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<IosDebugSupport>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE},
{runConfigurationFactory.id()}
};
RunWorkerFactory qmlProfilerWorkerFactory{
RunWorkerFactory::make<IosQmlProfilerSupport>(),
{ProjectExplorer::Constants::QML_PROFILER_RUN_MODE},
{runConfigurationFactory.id()}
};
}; };
IosPlugin::~IosPlugin() IosPlugin::~IosPlugin()

View File

@@ -67,7 +67,11 @@ public:
NimEditorFactory editorFactory; NimEditorFactory editorFactory;
NimBuildConfigurationFactory buildConfigFactory; NimBuildConfigurationFactory buildConfigFactory;
NimRunConfigurationFactory runConfigFactory; NimRunConfigurationFactory runConfigFactory;
SimpleRunWorkerFactory<SimpleTargetRunner, NimRunConfiguration> runWorkerFactory; RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.id()}
};
NimCompilerBuildStepFactory buildStepFactory; NimCompilerBuildStepFactory buildStepFactory;
NimCompilerCleanStepFactory cleanStepFactory; NimCompilerCleanStepFactory cleanStepFactory;
NimCodeStyleSettingsPage codeStyleSettingsPage; NimCodeStyleSettingsPage codeStyleSettingsPage;

View File

@@ -69,12 +69,13 @@ public:
RunControl::registerWorkerCreator(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, RunControl::registerWorkerCreator(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE,
[](RunControl *runControl){ return new PerfProfilerRunner(runControl); }); [](RunControl *runControl){ return new PerfProfilerRunner(runControl); });
auto constraint = [](RunConfiguration *) { return true; };
RunControl::registerWorker<PerfProfilerRunner>
(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, constraint);
} }
RunWorkerFactory profilerWorkerFactory{
RunWorkerFactory::make<PerfProfilerRunner>(),
{ProjectExplorer::Constants::PERFPROFILER_RUN_MODE}
};
PerfOptionsPage optionsPage; PerfOptionsPage optionsPage;
PerfProfilerTool profilerTool; PerfProfilerTool profilerTool;
}; };

View File

@@ -565,8 +565,11 @@ public:
CurrentProjectFind m_curretProjectFind; CurrentProjectFind m_curretProjectFind;
CustomExecutableRunConfigurationFactory m_customExecutableRunConfigFactory; CustomExecutableRunConfigurationFactory m_customExecutableRunConfigFactory;
SimpleRunWorkerFactory<SimpleTargetRunner, CustomExecutableRunConfiguration> RunWorkerFactory m_customExecutableRunWorkerFactory{
m_customExecutableRunWorkerFactory; RunWorkerFactory::make<SimpleTargetRunner>(),
{Constants::NORMAL_RUN_MODE},
{m_customExecutableRunConfigFactory.id()}
};
ProjectFileWizardExtension m_projectFileWizardExtension; ProjectFileWizardExtension m_projectFileWizardExtension;
@@ -610,8 +613,6 @@ ProjectExplorerPlugin::~ProjectExplorerPlugin()
delete dd; delete dd;
dd = nullptr; dd = nullptr;
m_instance = nullptr; m_instance = nullptr;
RunWorkerFactory::destroyRemainingRunWorkerFactories();
} }
ProjectExplorerPlugin *ProjectExplorerPlugin::instance() ProjectExplorerPlugin *ProjectExplorerPlugin::instance()

View File

@@ -227,6 +227,7 @@ public:
static RunConfiguration *clone(Target *parent, RunConfiguration *source); static RunConfiguration *clone(Target *parent, RunConfiguration *source);
static const QList<RunConfigurationCreationInfo> creatorsForTarget(Target *parent); static const QList<RunConfigurationCreationInfo> creatorsForTarget(Target *parent);
Core::Id id() const { return m_runConfigBaseId; }
Core::Id runConfigurationBaseId() const { return m_runConfigBaseId; } Core::Id runConfigurationBaseId() const { return m_runConfigBaseId; }
static QString decoratedTargetName(const QString &targetName, Target *kit); static QString decoratedTargetName(const QString &targetName, Target *kit);

View File

@@ -73,7 +73,14 @@ namespace ProjectExplorer {
static QList<RunWorkerFactory *> g_runWorkerFactories; static QList<RunWorkerFactory *> g_runWorkerFactories;
RunWorkerFactory::RunWorkerFactory() RunWorkerFactory::RunWorkerFactory(const WorkerCreator &producer,
const QList<Core::Id> &runModes,
const QList<Core::Id> &runConfigs,
const QList<Core::Id> &deviceTypes)
: m_producer(producer),
m_supportedRunModes(runModes),
m_supportedRunConfigurations(runConfigs),
m_supportedDeviceTypes(deviceTypes)
{ {
g_runWorkerFactories.append(this); g_runWorkerFactories.append(this);
} }
@@ -89,53 +96,32 @@ bool RunWorkerFactory::canRun(RunConfiguration *runConfiguration, Core::Id runMo
return false; return false;
if (!m_supportedRunConfigurations.isEmpty()) { if (!m_supportedRunConfigurations.isEmpty()) {
if (!m_supportedRunConfigurations.contains(runConfiguration->id())) // FIXME: That's to be used after mangled ids are gone.
//if (!m_supportedRunConfigurations.contains(runConfiguration->id()))
// return false;
bool ok = false;
const QString rcid = runConfiguration->id().toString();
for (const Core::Id &id : m_supportedRunConfigurations) {
if (rcid.startsWith(id.toString())) {
ok = true;
break;
}
}
if (!ok)
return false; return false;
} }
for (const Constraint &constraint : m_constraints) { if (!m_supportedDeviceTypes.isEmpty()) {
if (!constraint(runConfiguration)) Target *target = runConfiguration ? runConfiguration->target() : nullptr;
return false; Kit *kit = target ? target->kit() : nullptr;
const Core::Id devid = DeviceTypeKitAspect::deviceTypeId(kit);
return m_supportedDeviceTypes.contains(devid);
} }
return true; return true;
} }
void RunWorkerFactory::setProducer(const WorkerCreator &producer)
{
m_producer = producer;
}
void RunWorkerFactory::addConstraint(const Constraint &constraint)
{
// Default constructed Constraints are not worth keeping.
// FIXME: Make it a QTC_ASSERT once there is no code path
// using this "feature" anymore.
if (!constraint)
return;
m_constraints.append(constraint);
}
void RunWorkerFactory::addSupportedRunMode(Core::Id runMode)
{
m_supportedRunModes.append(runMode);
}
void RunWorkerFactory::setSupportedRunConfigurations(const QList<Core::Id> &ids)
{
m_supportedRunConfigurations = ids;
}
void RunWorkerFactory::addSupportedRunConfiguration(Core::Id id)
{
m_supportedRunConfigurations.append(id);
}
void RunWorkerFactory::destroyRemainingRunWorkerFactories()
{
qDeleteAll(g_runWorkerFactories);
}
/*! /*!
\class ProjectExplorer::RunControl \class ProjectExplorer::RunControl
\brief The RunControl class instances represent one item that is run. \brief The RunControl class instances represent one item that is run.

View File

@@ -50,11 +50,8 @@ class OutputFormatter;
namespace ProjectExplorer { namespace ProjectExplorer {
class GlobalOrProjectAspect; class GlobalOrProjectAspect;
class Node; class Node;
class RunConfigurationFactory;
class RunConfiguration; class RunConfiguration;
class RunConfigurationCreationInfo;
class RunControl; class RunControl;
class RunWorkerFactory;
class Target; class Target;
namespace Internal { namespace Internal {
@@ -142,36 +139,32 @@ private:
const std::unique_ptr<Internal::RunWorkerPrivate> d; const std::unique_ptr<Internal::RunWorkerPrivate> d;
}; };
class PROJECTEXPLORER_EXPORT RunWorkerFactory class PROJECTEXPLORER_EXPORT RunWorkerFactory final
{ {
public: public:
using WorkerCreator = std::function<RunWorker *(RunControl *)>; using WorkerCreator = std::function<RunWorker *(RunControl *)>;
using Constraint = std::function<bool(RunConfiguration *)>;
RunWorkerFactory(); RunWorkerFactory(const WorkerCreator &producer,
virtual ~RunWorkerFactory(); const QList<Core::Id> &runModes,
const QList<Core::Id> &runConfigs = {},
const QList<Core::Id> &deviceTypes = {});
~RunWorkerFactory();
bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const; bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const;
void setProducer(const WorkerCreator &producer);
void addConstraint(const Constraint &constraint);
void addSupportedRunMode(Core::Id runMode);
void setSupportedRunConfigurations(const QList<Core::Id> &ids);
void addSupportedRunConfiguration(Core::Id id);
WorkerCreator producer() const { return m_producer; } WorkerCreator producer() const { return m_producer; }
private: template <typename Worker>
// FIXME: That's temporary until ownership has been transferred to static WorkerCreator make()
// the individual plugins. {
friend class ProjectExplorerPlugin; return [](RunControl *runControl) { return new Worker(runControl); };
static void destroyRemainingRunWorkerFactories(); }
private:
WorkerCreator m_producer;
QList<Core::Id> m_supportedRunModes; QList<Core::Id> m_supportedRunModes;
QList<Core::Id> m_supportedRunConfigurations; QList<Core::Id> m_supportedRunConfigurations;
QList<Constraint> m_constraints; QList<Core::Id> m_supportedDeviceTypes;
WorkerCreator m_producer;
}; };
/** /**
@@ -258,19 +251,10 @@ public:
RunWorker *createWorker(Core::Id id); RunWorker *createWorker(Core::Id id);
using WorkerCreator = RunWorkerFactory::WorkerCreator; using WorkerCreator = RunWorkerFactory::WorkerCreator;
using Constraint = RunWorkerFactory::Constraint; using Constraint = std::function<bool(RunConfiguration *)>;
static void registerWorkerCreator(Core::Id id, const WorkerCreator &workerCreator); static void registerWorkerCreator(Core::Id id, const WorkerCreator &workerCreator);
template <class Worker>
static void registerWorker(Core::Id runMode, const Constraint &constraint)
{
auto factory = new RunWorkerFactory;
factory->setProducer([](RunControl *rc) { return new Worker(rc); });
factory->addSupportedRunMode(runMode);
factory->addConstraint(constraint);
}
bool createMainWorker(); bool createMainWorker();
static bool canRun(RunConfiguration *runConfig, Core::Id runMode); static bool canRun(RunConfiguration *runConfig, Core::Id runMode);
@@ -325,20 +309,4 @@ private:
bool m_useTerminal = false; bool m_useTerminal = false;
}; };
template <class RunWorker, class RunConfig>
class SimpleRunWorkerFactory : public RunWorkerFactory
{
public:
SimpleRunWorkerFactory(Core::Id runMode = ProjectExplorer::Constants::NORMAL_RUN_MODE)
{
addSupportedRunMode(runMode);
addConstraint([](RunConfiguration *runConfig) {
return qobject_cast<RunConfig *>(runConfig) != nullptr;
});
setProducer([](RunControl *runControl) {
return new RunWorker(runControl);
});
}
};
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -810,7 +810,11 @@ class PythonPluginPrivate
public: public:
PythonEditorFactory editorFactory; PythonEditorFactory editorFactory;
PythonRunConfigurationFactory runConfigFactory; PythonRunConfigurationFactory runConfigFactory;
SimpleRunWorkerFactory<SimpleTargetRunner, PythonRunConfiguration> runWorkerFactory; RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.id()}
};
}; };
PythonPlugin::~PythonPlugin() PythonPlugin::~PythonPlugin()

View File

@@ -108,13 +108,12 @@ bool QmlPreviewPlugin::initialize(const QStringList &arguments, QString *errorSt
setFileClassifier(&defaultFileClassifier); setFileClassifier(&defaultFileClassifier);
setFpsHandler(&defaultFpsHandler); setFpsHandler(&defaultFpsHandler);
auto constraint = [](RunConfiguration *runConfiguration) { m_runWorkerFactory.reset(new RunWorkerFactory{
Target *target = runConfiguration ? runConfiguration->target() : nullptr; RunWorkerFactory::make<LocalQmlPreviewSupport>(),
Kit *kit = target ? target->kit() : nullptr; {Constants::QML_PREVIEW_RUN_MODE},
return DeviceTypeKitAspect::deviceTypeId(kit) == Constants::DESKTOP_DEVICE_TYPE; {}, // All runconfig.
}; {Constants::DESKTOP_DEVICE_TYPE}
});
RunControl::registerWorker<LocalQmlPreviewSupport>(Constants::QML_PREVIEW_RUN_MODE, constraint);
Core::ActionContainer *menu = Core::ActionManager::actionContainer( Core::ActionContainer *menu = Core::ActionManager::actionContainer(
Constants::M_BUILDPROJECT); Constants::M_BUILDPROJECT);

View File

@@ -122,6 +122,7 @@ private:
float m_zoomFactor = -1.0; float m_zoomFactor = -1.0;
QmlPreview::QmlPreviewFpsHandler m_fpsHandler = nullptr; QmlPreview::QmlPreviewFpsHandler m_fpsHandler = nullptr;
QString m_locale; QString m_locale;
std::unique_ptr<ProjectExplorer::RunWorkerFactory> m_runWorkerFactory;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -80,34 +80,18 @@ namespace Internal {
Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings) Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings)
bool constraint(RunConfiguration *runConfiguration)
{
Target *target = runConfiguration ? runConfiguration->target() : nullptr;
Kit *kit = target ? target->kit() : nullptr;
return DeviceTypeKitAspect::deviceTypeId(kit)
== ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
}
class QmlProfilerRunWorkerFactory : public RunWorkerFactory
{
public:
QmlProfilerRunWorkerFactory(QmlProfilerTool *tool)
{
addSupportedRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
setProducer([tool](RunControl *runControl) {
return new LocalQmlProfilerSupport(tool, runControl);
});
addConstraint(constraint);
}
};
class QmlProfilerPluginPrivate class QmlProfilerPluginPrivate
{ {
public: public:
QmlProfilerTool m_profilerTool; QmlProfilerTool m_profilerTool;
QmlProfilerOptionsPage m_profilerOptionsPage; QmlProfilerOptionsPage m_profilerOptionsPage;
QmlProfilerActions m_actions; QmlProfilerActions m_actions;
QmlProfilerRunWorkerFactory m_profilerWorkerFactory{&m_profilerTool}; RunWorkerFactory m_profilerWorkerFactory{
RunWorkerFactory::make<LocalQmlProfilerSupport>(),
{ProjectExplorer::Constants::QML_PROFILER_RUN_MODE},
{},
{ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE}
};
}; };
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)

View File

@@ -218,14 +218,12 @@ static QUrl localServerUrl(RunControl *runControl)
return serverUrl; return serverUrl;
} }
LocalQmlProfilerSupport::LocalQmlProfilerSupport(QmlProfilerTool *profilerTool, LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl)
RunControl *runControl) : LocalQmlProfilerSupport(runControl, localServerUrl(runControl))
: LocalQmlProfilerSupport(profilerTool, runControl, localServerUrl(runControl))
{ {
} }
LocalQmlProfilerSupport::LocalQmlProfilerSupport(QmlProfilerTool *profilerTool, LocalQmlProfilerSupport::LocalQmlProfilerSupport(RunControl *runControl, const QUrl &serverUrl)
RunControl *runControl, const QUrl &serverUrl)
: SimpleTargetRunner(runControl) : SimpleTargetRunner(runControl)
{ {
setId("LocalQmlProfilerSupport"); setId("LocalQmlProfilerSupport");
@@ -233,7 +231,7 @@ LocalQmlProfilerSupport::LocalQmlProfilerSupport(QmlProfilerTool *profilerTool,
auto profiler = new QmlProfilerRunner(runControl); auto profiler = new QmlProfilerRunner(runControl);
profiler->setServerUrl(serverUrl); profiler->setServerUrl(serverUrl);
connect(profiler, &QmlProfilerRunner::starting, connect(profiler, &QmlProfilerRunner::starting,
profilerTool, &QmlProfilerTool::finalizeRunControl); QmlProfilerTool::instance(), &QmlProfilerTool::finalizeRunControl);
addStopDependency(profiler); addStopDependency(profiler);
// We need to open the local server before the application tries to connect. // We need to open the local server before the application tries to connect.

View File

@@ -72,8 +72,8 @@ class LocalQmlProfilerSupport : public ProjectExplorer::SimpleTargetRunner
Q_OBJECT Q_OBJECT
public: public:
LocalQmlProfilerSupport(QmlProfilerTool *profilerTool, ProjectExplorer::RunControl *runControl); LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl);
LocalQmlProfilerSupport(QmlProfilerTool *profilerTool, ProjectExplorer::RunControl *runControl, LocalQmlProfilerSupport(ProjectExplorer::RunControl *runControl,
const QUrl &serverUrl); const QUrl &serverUrl);
}; };

View File

@@ -96,6 +96,8 @@ using namespace ProjectExplorer;
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
static QmlProfilerTool *m_instance = nullptr;
class QmlProfilerTool::QmlProfilerToolPrivate class QmlProfilerTool::QmlProfilerToolPrivate
{ {
public: public:
@@ -129,6 +131,7 @@ public:
QmlProfilerTool::QmlProfilerTool() QmlProfilerTool::QmlProfilerTool()
: d(new QmlProfilerToolPrivate) : d(new QmlProfilerToolPrivate)
{ {
m_instance = this;
setObjectName(QLatin1String("QmlProfilerTool")); setObjectName(QLatin1String("QmlProfilerTool"));
d->m_profilerState = new QmlProfilerStateManager(this); d->m_profilerState = new QmlProfilerStateManager(this);
@@ -279,6 +282,12 @@ QmlProfilerTool::~QmlProfilerTool()
{ {
d->m_profilerModelManager->clearAll(); d->m_profilerModelManager->clearAll();
delete d; delete d;
m_instance = nullptr;
}
QmlProfilerTool *QmlProfilerTool::instance()
{
return m_instance;
} }
void QmlProfilerTool::updateRunActions() void QmlProfilerTool::updateRunActions()

View File

@@ -52,6 +52,8 @@ public:
QmlProfilerTool(); QmlProfilerTool();
~QmlProfilerTool() override; ~QmlProfilerTool() override;
static QmlProfilerTool *instance();
void finalizeRunControl(QmlProfilerRunner *runWorker); void finalizeRunControl(QmlProfilerRunner *runWorker);
bool prepareTool(); bool prepareTool();

View File

@@ -45,7 +45,6 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec
void LocalQmlProfilerRunnerTest::testRunner() void LocalQmlProfilerRunnerTest::testRunner()
{ {
QmlProfilerTool tool;
QPointer<ProjectExplorer::RunControl> runControl; QPointer<ProjectExplorer::RunControl> runControl;
QPointer<LocalQmlProfilerSupport> profiler; QPointer<LocalQmlProfilerSupport> profiler;
ProjectExplorer::Runnable debuggee; ProjectExplorer::Runnable debuggee;
@@ -66,7 +65,7 @@ void LocalQmlProfilerRunnerTest::testRunner()
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setRunnable(debuggee); runControl->setRunnable(debuggee);
profiler = new LocalQmlProfilerSupport(&tool, runControl, serverUrl); profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
auto connectRunner = [&]() { auto connectRunner = [&]() {
connect(runControl, &ProjectExplorer::RunControl::aboutToStart, this, [&]() { connect(runControl, &ProjectExplorer::RunControl::aboutToStart, this, [&]() {
@@ -116,7 +115,7 @@ void LocalQmlProfilerRunnerTest::testRunner()
debuggee.commandLineArguments = QString("-test QmlProfiler,"); debuggee.commandLineArguments = QString("-test QmlProfiler,");
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setRunnable(debuggee); runControl->setRunnable(debuggee);
profiler = new LocalQmlProfilerSupport(&tool, runControl, serverUrl); profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
connectRunner(); connectRunner();
runControl->initiateStart(); runControl->initiateStart();
@@ -135,7 +134,7 @@ void LocalQmlProfilerRunnerTest::testRunner()
serverUrl = Utils::urlFromLocalHostAndFreePort(); serverUrl = Utils::urlFromLocalHostAndFreePort();
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setRunnable(debuggee); runControl->setRunnable(debuggee);
profiler = new LocalQmlProfilerSupport(&tool, runControl, serverUrl); profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
connectRunner(); connectRunner();
runControl->initiateStart(); runControl->initiateStart();
@@ -160,7 +159,7 @@ void LocalQmlProfilerRunnerTest::testRunner()
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
runControl->setRunnable(debuggee); runControl->setRunnable(debuggee);
profiler = new LocalQmlProfilerSupport(&tool, runControl, serverUrl); profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
connectRunner(); connectRunner();
runControl->initiateStart(); runControl->initiateStart();

View File

@@ -52,7 +52,7 @@ void QmlProfilerToolTest::testAttachToWaitingApplication()
QVERIFY(settings); QVERIFY(settings);
settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/kitId"), newKit->id().toSetting()); settings->setValue(QLatin1String("AnalyzerQmlAttachDialog/kitId"), newKit->id().toSetting());
QmlProfilerTool profilerTool; QmlProfilerTool &profilerTool = *QmlProfilerTool::instance();
QmlProfilerClientManager *clientManager = profilerTool.clientManager(); QmlProfilerClientManager *clientManager = profilerTool.clientManager();
clientManager->setRetryInterval(10); clientManager->setRetryInterval(10);
@@ -107,7 +107,7 @@ void QmlProfilerToolTest::testAttachToWaitingApplication()
void QmlProfilerToolTest::testClearEvents() void QmlProfilerToolTest::testClearEvents()
{ {
QmlProfilerTool profilerTool; QmlProfilerTool &profilerTool = *QmlProfilerTool::instance();
QmlProfilerModelManager *modelManager = profilerTool.modelManager(); QmlProfilerModelManager *modelManager = profilerTool.modelManager();
QVERIFY(modelManager); QVERIFY(modelManager);
QmlProfilerStateManager *stateManager = profilerTool.stateManager(); QmlProfilerStateManager *stateManager = profilerTool.stateManager();

View File

@@ -44,8 +44,11 @@ class QmlProjectPluginPrivate
{ {
public: public:
QmlProjectRunConfigurationFactory runConfigFactory; QmlProjectRunConfigurationFactory runConfigFactory;
SimpleRunWorkerFactory<SimpleTargetRunner, QmlProjectRunConfiguration> RunWorkerFactory runWorkerFactory{
runWorkerFactory{ProjectExplorer::Constants::NORMAL_RUN_MODE}; RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.id()}
};
}; };
QmlProjectPlugin::~QmlProjectPlugin() QmlProjectPlugin::~QmlProjectPlugin()

View File

@@ -115,12 +115,21 @@ public:
QnxSettingsPage settingsPage; QnxSettingsPage settingsPage;
QnxToolChainFactory toolChainFactory; QnxToolChainFactory toolChainFactory;
SimpleRunWorkerFactory<SimpleTargetRunner, QnxRunConfiguration> RunWorkerFactory runWorkerFactory{
runWorkerFactory{ProjectExplorer::Constants::NORMAL_RUN_MODE}; RunWorkerFactory::make<SimpleTargetRunner>(),
SimpleRunWorkerFactory<QnxDebugSupport, QnxRunConfiguration> {ProjectExplorer::Constants::NORMAL_RUN_MODE},
debugWorkerFactory{ProjectExplorer::Constants::DEBUG_RUN_MODE}; {runConfigFactory.id()}
SimpleRunWorkerFactory<QnxQmlProfilerSupport, QnxRunConfiguration> };
qmlProfilerWorkerFactory; RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<QnxDebugSupport>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE},
{runConfigFactory.id()}
};
RunWorkerFactory qmlProfilerWorkerFactory{
RunWorkerFactory::make<QnxQmlProfilerSupport>(),
{}, // FIXME: Shouldn't this use the run mode id somehow?
{runConfigFactory.id()}
};
}; };
static QnxPluginPrivate *dd = nullptr; static QnxPluginPrivate *dd = nullptr;

View File

@@ -239,16 +239,6 @@ const char QMAKE_RUNCONFIG_ID[] = "Qt4ProjectManager.Qt4RunConfiguration:";
const char QBS_RUNCONFIG_ID[] = "Qbs.RunConfiguration:"; const char QBS_RUNCONFIG_ID[] = "Qbs.RunConfiguration:";
const char CMAKE_RUNCONFIG_ID[] = "CMakeProjectManager.CMakeRunConfiguration."; const char CMAKE_RUNCONFIG_ID[] = "CMakeProjectManager.CMakeRunConfiguration.";
DesktopRunWorkerFactory::DesktopRunWorkerFactory()
{
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
addSupportedRunConfiguration(QMAKE_RUNCONFIG_ID);
addSupportedRunConfiguration(QBS_RUNCONFIG_ID);
addSupportedRunConfiguration(CMAKE_RUNCONFIG_ID);
setProducer([](RunControl *runControl) { return new SimpleTargetRunner(runControl); });
}
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory() CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
{ {
registerRunConfiguration<CMakeRunConfiguration>(CMAKE_RUNCONFIG_ID); registerRunConfiguration<CMakeRunConfiguration>(CMAKE_RUNCONFIG_ID);

View File

@@ -58,12 +58,6 @@ private:
const Kind m_kind; const Kind m_kind;
}; };
class DesktopRunWorkerFactory : public ProjectExplorer::RunWorkerFactory
{
public:
DesktopRunWorkerFactory();
};
class DesktopQmakeRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory class DesktopQmakeRunConfigurationFactory : public ProjectExplorer::RunConfigurationFactory
{ {
public: public:

View File

@@ -71,10 +71,15 @@ public:
CodeGenSettingsPage codeGenSettingsPage; CodeGenSettingsPage codeGenSettingsPage;
QtOptionsPage qtOptionsPage; QtOptionsPage qtOptionsPage;
DesktopRunWorkerFactory desktopRunWorkerFactory; DesktopQmakeRunConfigurationFactory qmakeRunConfigFactory;
DesktopQmakeRunConfigurationFactory desktopQmakeRunConfigFactory; QbsRunConfigurationFactory qbsRunConfigFactory;
QbsRunConfigurationFactory desktopQbsRunConfigFactory; CMakeRunConfigurationFactory cmakeRunConfigFactory;
CMakeRunConfigurationFactory desktopCMakeRunConfigFactory;
RunWorkerFactory desktopRunWorkerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{qmakeRunConfigFactory.id(), qbsRunConfigFactory.id(), cmakeRunConfigFactory.id()}
};
ExamplesWelcomePage examplesPage{true}; ExamplesWelcomePage examplesPage{true};
ExamplesWelcomePage tutorialPage{false}; ExamplesWelcomePage tutorialPage{false};

View File

@@ -83,6 +83,37 @@ public:
GenericDeployStepFactory<RemoteLinuxKillAppStep> remoteLinuxKillAppStepFactory; GenericDeployStepFactory<RemoteLinuxKillAppStep> remoteLinuxKillAppStepFactory;
GenericDeployStepFactory<MakeInstallStep> makeInstallStepFactory; GenericDeployStepFactory<MakeInstallStep> makeInstallStepFactory;
EmbeddedLinuxQtVersionFactory embeddedLinuxQtVersionFactory; EmbeddedLinuxQtVersionFactory embeddedLinuxQtVersionFactory;
const QList<Core::Id> supportedRunConfigs {
runConfigurationFactory.id(),
customRunConfigurationFactory.id(),
"QmlProjectManager.QmlRunConfiguration"
};
RunWorkerFactory runnerFactory{
RunWorkerFactory::make<SimpleTargetRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
supportedRunConfigs,
{Constants::GenericLinuxOsType}
};
RunWorkerFactory debuggerFactory{
RunWorkerFactory::make<LinuxDeviceDebugSupport>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE},
supportedRunConfigs,
{Constants::GenericLinuxOsType}
};
RunWorkerFactory qmlProfilerFactory{
RunWorkerFactory::make<RemoteLinuxQmlProfilerSupport>(),
{ProjectExplorer::Constants::QML_PROFILER_RUN_MODE},
supportedRunConfigs,
{Constants::GenericLinuxOsType}
};
RunWorkerFactory qmlPreviewFactory{
RunWorkerFactory::make<RemoteLinuxQmlPreviewSupport>(),
{ProjectExplorer::Constants::QML_PREVIEW_RUN_MODE},
supportedRunConfigs,
{Constants::GenericLinuxOsType}
};
}; };
static RemoteLinuxPluginPrivate *dd = nullptr; static RemoteLinuxPluginPrivate *dd = nullptr;
@@ -104,25 +135,6 @@ bool RemoteLinuxPlugin::initialize(const QStringList &arguments, QString *errorM
dd = new RemoteLinuxPluginPrivate; dd = new RemoteLinuxPluginPrivate;
auto constraint = [](RunConfiguration *runConfig) {
const Core::Id devType = ProjectExplorer::DeviceTypeKitAspect::deviceTypeId(
runConfig->target()->kit());
if (devType != Constants::GenericLinuxOsType)
return false;
const Core::Id id = runConfig->id();
return id == RemoteLinuxCustomRunConfiguration::runConfigId()
|| id.name().startsWith(RemoteLinuxRunConfiguration::IdPrefix)
|| id.name().startsWith("QmlProjectManager.QmlRunConfiguration");
};
using namespace ProjectExplorer::Constants;
RunControl::registerWorker<SimpleTargetRunner>(NORMAL_RUN_MODE, constraint);
RunControl::registerWorker<LinuxDeviceDebugSupport>(DEBUG_RUN_MODE, constraint);
RunControl::registerWorker<RemoteLinuxQmlProfilerSupport>(QML_PROFILER_RUN_MODE, constraint);
RunControl::registerWorker<RemoteLinuxQmlPreviewSupport>(QML_PREVIEW_RUN_MODE, constraint);
return true; return true;
} }

View File

@@ -219,6 +219,11 @@ public:
bool m_toolBusy = false; bool m_toolBusy = false;
Perspective m_perspective{"Callgrind.Perspective", CallgrindTool::tr("Callgrind")}; Perspective m_perspective{"Callgrind.Perspective", CallgrindTool::tr("Callgrind")};
RunWorkerFactory callgrindRunWorkerFactory{
RunWorkerFactory::make<CallgrindToolRunner>(),
{CALLGRIND_RUN_MODE}
};
}; };
CallgrindToolPrivate::CallgrindToolPrivate() CallgrindToolPrivate::CallgrindToolPrivate()
@@ -999,7 +1004,6 @@ void setupCallgrindRunner(CallgrindToolRunner *toolRunner)
CallgrindTool::CallgrindTool() CallgrindTool::CallgrindTool()
{ {
dd = new CallgrindToolPrivate; dd = new CallgrindToolPrivate;
RunControl::registerWorker<CallgrindToolRunner>(CALLGRIND_RUN_MODE, {});
} }
CallgrindTool::~CallgrindTool() CallgrindTool::~CallgrindTool()

View File

@@ -437,6 +437,11 @@ private:
QString m_exitMsg; QString m_exitMsg;
Perspective m_perspective{"Memcheck.Perspective", MemcheckTool::tr("Memcheck")}; Perspective m_perspective{"Memcheck.Perspective", MemcheckTool::tr("Memcheck")};
RunWorkerFactory memcheckToolRunnerFactory{
RunWorkerFactory::make<MemcheckToolRunner>(),
{MEMCHECK_RUN_MODE, MEMCHECK_WITH_GDB_RUN_MODE}
};
}; };
static MemcheckToolPrivate *dd = nullptr; static MemcheckToolPrivate *dd = nullptr;
@@ -1644,9 +1649,6 @@ void HeobData::debugStopped()
MemcheckTool::MemcheckTool() MemcheckTool::MemcheckTool()
{ {
dd = new MemcheckToolPrivate; dd = new MemcheckToolPrivate;
RunControl::registerWorker<MemcheckToolRunner>(MEMCHECK_RUN_MODE, {});
RunControl::registerWorker<MemcheckToolRunner>(MEMCHECK_WITH_GDB_RUN_MODE, {});
} }
MemcheckTool::~MemcheckTool() MemcheckTool::~MemcheckTool()

View File

@@ -36,6 +36,8 @@
#include <projectexplorer/devicesupport/devicemanager.h> #include <projectexplorer/devicesupport/devicemanager.h>
using namespace ProjectExplorer;
namespace WebAssembly { namespace WebAssembly {
namespace Internal { namespace Internal {
@@ -46,7 +48,11 @@ public:
WebAssemblyDeviceFactory deviceFactory; WebAssemblyDeviceFactory deviceFactory;
WebAssemblyQtVersionFactory qtVersionFactory; WebAssemblyQtVersionFactory qtVersionFactory;
EmrunRunConfigurationFactory emrunRunConfigurationFactory; EmrunRunConfigurationFactory emrunRunConfigurationFactory;
EmrunRunWorkerFactory emrunRunWorkerFactory; RunWorkerFactory emrunRunWorkerFactory{
makeEmrunWorker(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{Constants::WEBASSEMBLY_RUNCONFIGURATION_EMRUN}
};
}; };
static WebAssemblyPluginPrivate *dd = nullptr; static WebAssemblyPluginPrivate *dd = nullptr;

View File

@@ -110,6 +110,10 @@ public:
PortsGatherer *m_portsGatherer; PortsGatherer *m_portsGatherer;
}; };
RunWorkerFactory::WorkerCreator makeEmrunWorker()
{
return RunWorkerFactory::make<EmrunRunWorker>();
}
// Factories // Factories
@@ -120,12 +124,5 @@ EmrunRunConfigurationFactory::EmrunRunConfigurationFactory()
addSupportedTargetDeviceType(Constants::WEBASSEMBLY_DEVICE_TYPE); addSupportedTargetDeviceType(Constants::WEBASSEMBLY_DEVICE_TYPE);
} }
EmrunRunWorkerFactory::EmrunRunWorkerFactory()
{
setProducer([](RunControl *rc) { return new EmrunRunWorker(rc); });
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
addSupportedRunConfiguration(Constants::WEBASSEMBLY_RUNCONFIGURATION_EMRUN);
}
} // namespace Internal } // namespace Internal
} // namespace Webassembly } // namespace Webassembly

View File

@@ -37,11 +37,7 @@ public:
EmrunRunConfigurationFactory(); EmrunRunConfigurationFactory();
}; };
class EmrunRunWorkerFactory : public ProjectExplorer::RunWorkerFactory ProjectExplorer::RunWorkerFactory::WorkerCreator makeEmrunWorker();
{
public:
EmrunRunWorkerFactory();
};
} // namespace Internal } // namespace Internal
} // namespace Webassembly } // namespace Webassembly

View File

@@ -56,6 +56,19 @@ public:
WinRtDeviceFactory localDeviceFactory{Constants::WINRT_DEVICE_TYPE_LOCAL}; WinRtDeviceFactory localDeviceFactory{Constants::WINRT_DEVICE_TYPE_LOCAL};
WinRtDeviceFactory phoneDeviceFactory{Constants::WINRT_DEVICE_TYPE_PHONE}; WinRtDeviceFactory phoneDeviceFactory{Constants::WINRT_DEVICE_TYPE_PHONE};
WinRtDeviceFactory emulatorDeviceFactory{Constants::WINRT_DEVICE_TYPE_EMULATOR}; WinRtDeviceFactory emulatorDeviceFactory{Constants::WINRT_DEVICE_TYPE_EMULATOR};
RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<WinRtRunner>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE},
{runConfigFactory.id()}
};
RunWorkerFactory debugWorkerFactory{
RunWorkerFactory::make<WinRtDebugSupport>(),
{ProjectExplorer::Constants::DEBUG_RUN_MODE},
{runConfigFactory.id()},
{Internal::Constants::WINRT_DEVICE_TYPE_LOCAL}
};
}; };
WinRtPlugin::~WinRtPlugin() WinRtPlugin::~WinRtPlugin()
@@ -70,27 +83,6 @@ bool WinRtPlugin::initialize(const QStringList &arguments, QString *errorMessage
d = new WinRtPluginPrivate; d = new WinRtPluginPrivate;
auto runConstraint = [](RunConfiguration *runConfig) {
IDevice::ConstPtr device = DeviceKitAspect::device(runConfig->target()->kit());
if (!device)
return false;
return qobject_cast<WinRtRunConfiguration *>(runConfig) != nullptr;
};
auto debugConstraint = [](RunConfiguration *runConfig) {
IDevice::ConstPtr device = DeviceKitAspect::device(runConfig->target()->kit());
if (!device)
return false;
if (device->type() != Internal::Constants::WINRT_DEVICE_TYPE_LOCAL)
return false;
return qobject_cast<WinRtRunConfiguration *>(runConfig) != nullptr;
};
RunControl::registerWorker<WinRtRunner>
(ProjectExplorer::Constants::NORMAL_RUN_MODE, runConstraint);
RunControl::registerWorker<WinRtDebugSupport>
(ProjectExplorer::Constants::DEBUG_RUN_MODE, debugConstraint);
return true; return true;
} }