forked from qt-creator/qt-creator
WinRT: Dissolve RunControlFactory
Less code, and it's what most other targets do nowadays. Change-Id: I2cf55d1a32ad10427ce2508536d03bca8921b451 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -24,21 +24,28 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "winrtplugin.h"
|
#include "winrtplugin.h"
|
||||||
|
#include "winrtconstants.h"
|
||||||
#include "winrtrunfactories.h"
|
#include "winrtrunfactories.h"
|
||||||
#include "winrtdevice.h"
|
#include "winrtdevice.h"
|
||||||
#include "winrtdevicefactory.h"
|
#include "winrtdevicefactory.h"
|
||||||
#include "winrtdeployconfiguration.h"
|
#include "winrtdeployconfiguration.h"
|
||||||
#include "winrtqtversionfactory.h"
|
#include "winrtqtversionfactory.h"
|
||||||
|
#include "winrtrunconfiguration.h"
|
||||||
|
#include "winrtruncontrol.h"
|
||||||
|
#include "winrtdebugsupport.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||||
|
#include <projectexplorer/devicesupport/idevice.h>
|
||||||
|
#include <projectexplorer/kitinformation.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
|
||||||
using ExtensionSystem::PluginManager;
|
using namespace ProjectExplorer;
|
||||||
using ProjectExplorer::DeviceManager;
|
|
||||||
|
|
||||||
namespace WinRt {
|
namespace WinRt {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -54,10 +61,33 @@ bool WinRtPlugin::initialize(const QStringList &arguments, QString *errorMessage
|
|||||||
Q_UNUSED(errorMessage)
|
Q_UNUSED(errorMessage)
|
||||||
|
|
||||||
addAutoReleasedObject(new Internal::WinRtRunConfigurationFactory);
|
addAutoReleasedObject(new Internal::WinRtRunConfigurationFactory);
|
||||||
addAutoReleasedObject(new Internal::WinRtRunControlFactory);
|
|
||||||
addAutoReleasedObject(new Internal::WinRtQtVersionFactory);
|
addAutoReleasedObject(new Internal::WinRtQtVersionFactory);
|
||||||
addAutoReleasedObject(new Internal::WinRtDeployConfigurationFactory);
|
addAutoReleasedObject(new Internal::WinRtDeployConfigurationFactory);
|
||||||
addAutoReleasedObject(new Internal::WinRtDeployStepFactory);
|
addAutoReleasedObject(new Internal::WinRtDeployStepFactory);
|
||||||
|
|
||||||
|
auto runConstraint = [](RunConfiguration *runConfig) {
|
||||||
|
IDevice::ConstPtr device = DeviceKitInformation::device(runConfig->target()->kit());
|
||||||
|
if (!device)
|
||||||
|
return false;
|
||||||
|
return qobject_cast<WinRtRunConfiguration *>(runConfig) != nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto debugConstraint = [](RunConfiguration *runConfig) {
|
||||||
|
IDevice::ConstPtr device = DeviceKitInformation::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);
|
||||||
|
RunControl::registerWorker<WinRtDebugSupport>
|
||||||
|
(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, debugConstraint);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,14 +27,12 @@
|
|||||||
#include "winrtrunconfiguration.h"
|
#include "winrtrunconfiguration.h"
|
||||||
#include "winrtruncontrol.h"
|
#include "winrtruncontrol.h"
|
||||||
#include "winrtconstants.h"
|
#include "winrtconstants.h"
|
||||||
#include "winrtdebugsupport.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/kit.h>
|
#include <projectexplorer/kit.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <qmakeprojectmanager/qmakeproject.h>
|
#include <qmakeprojectmanager/qmakeproject.h>
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using QmakeProjectManager::QmakeProject;
|
using QmakeProjectManager::QmakeProject;
|
||||||
@@ -124,54 +122,5 @@ bool WinRtRunConfigurationFactory::canHandle(Target *parent) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WinRtRunControlFactory::WinRtRunControlFactory()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WinRtRunControlFactory::canRun(RunConfiguration *runConfiguration,
|
|
||||||
Core::Id mode) const
|
|
||||||
{
|
|
||||||
if (!runConfiguration)
|
|
||||||
return false;
|
|
||||||
IDevice::ConstPtr device = DeviceKitInformation::device(runConfiguration->target()->kit());
|
|
||||||
if (!device)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE
|
|
||||||
|| mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) {
|
|
||||||
if (device->type() != Constants::WINRT_DEVICE_TYPE_LOCAL)
|
|
||||||
return false;
|
|
||||||
return qobject_cast<WinRtRunConfiguration *>(runConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
|
|
||||||
return qobject_cast<WinRtRunConfiguration *>(runConfiguration);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
RunControl *WinRtRunControlFactory::create(
|
|
||||||
RunConfiguration *runConfiguration, Core::Id mode, QString *)
|
|
||||||
{
|
|
||||||
RunControl *runControl = nullptr;
|
|
||||||
if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) {
|
|
||||||
runControl = new RunControl(runConfiguration, mode);
|
|
||||||
(void) new WinRtRunner(runControl);
|
|
||||||
return runControl;
|
|
||||||
} else if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE
|
|
||||||
|| mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) {
|
|
||||||
runControl = new RunControl(runConfiguration, mode);
|
|
||||||
(void) new WinRtDebugSupport(runControl);
|
|
||||||
return runControl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString WinRtRunControlFactory::displayName() const
|
|
||||||
{
|
|
||||||
return tr("WinRT Run Control Factory");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace WinRt
|
} // namespace WinRt
|
||||||
|
|||||||
@@ -52,17 +52,5 @@ private:
|
|||||||
virtual ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent, const QVariantMap &map) override;
|
virtual ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent, const QVariantMap &map) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WinRtRunControlFactory : public ProjectExplorer::IRunControlFactory
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
WinRtRunControlFactory();
|
|
||||||
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
|
|
||||||
Core::Id mode) const override;
|
|
||||||
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
|
|
||||||
Core::Id mode, QString *errorMessage) override;
|
|
||||||
QString displayName() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace WinRt
|
} // namespace WinRt
|
||||||
|
|||||||
Reference in New Issue
Block a user