RemoteLinux/Qnx: Disentangle deploy step factories further

Change-Id: I5d6c9a6de05bf8284be13f877642de39f7c3d22d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-03-28 18:22:17 +02:00
parent 3cd0dad3d4
commit a8abb5ca50
8 changed files with 81 additions and 99 deletions

View File

@@ -4,6 +4,7 @@
#include "devicecheckbuildstep.h"
#include "../kitinformation.h"
#include "../projectexplorerconstants.h"
#include "../projectexplorertr.h"
#include "devicemanager.h"
@@ -12,60 +13,61 @@
#include <QMessageBox>
using namespace ProjectExplorer;
namespace ProjectExplorer {
DeviceCheckBuildStep::DeviceCheckBuildStep(BuildStepList *bsl, Utils::Id id)
: BuildStep(bsl, id)
class DeviceCheckBuildStep : public BuildStep
{
setWidgetExpandedByDefault(false);
}
bool DeviceCheckBuildStep::init()
{
IDevice::ConstPtr device = DeviceKitAspect::device(kit());
if (!device) {
Utils::Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(kit());
IDeviceFactory *factory = IDeviceFactory::find(deviceTypeId);
if (!factory || !factory->canCreate()) {
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
return false;
}
QMessageBox msgBox(QMessageBox::Question, Tr::tr("Set Up Device"),
Tr::tr("There is no device set up for this kit. Do you want to add a device?"),
QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
if (msgBox.exec() == QMessageBox::No) {
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
return false;
}
IDevice::Ptr newDevice = factory->create();
if (newDevice.isNull()) {
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
return false;
}
DeviceManager *dm = DeviceManager::instance();
dm->addDevice(newDevice);
DeviceKitAspect::setDevice(kit(), newDevice);
public:
DeviceCheckBuildStep(BuildStepList *bsl, Utils::Id id)
: BuildStep(bsl, id)
{
setWidgetExpandedByDefault(false);
}
return true;
bool init() override
{
IDevice::ConstPtr device = DeviceKitAspect::device(kit());
if (!device) {
Utils::Id deviceTypeId = DeviceTypeKitAspect::deviceTypeId(kit());
IDeviceFactory *factory = IDeviceFactory::find(deviceTypeId);
if (!factory || !factory->canCreate()) {
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
return false;
}
QMessageBox msgBox(QMessageBox::Question, Tr::tr("Set Up Device"),
Tr::tr("There is no device set up for this kit. Do you want to add a device?"),
QMessageBox::Yes|QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
if (msgBox.exec() == QMessageBox::No) {
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
return false;
}
IDevice::Ptr newDevice = factory->create();
if (newDevice.isNull()) {
emit addOutput(Tr::tr("No device configured."), BuildStep::OutputFormat::ErrorMessage);
return false;
}
DeviceManager *dm = DeviceManager::instance();
dm->addDevice(newDevice);
DeviceKitAspect::setDevice(kit(), newDevice);
}
return true;
}
void doRun() override { emit finished(true); }
};
// Factory
DeviceCheckBuildStepFactory::DeviceCheckBuildStepFactory()
{
registerStep<DeviceCheckBuildStep>(Constants::DEVICE_CHECK_STEP);
setDisplayName(Tr::tr("Check for a configured device"));
}
void DeviceCheckBuildStep::doRun()
{
emit finished(true);
}
Utils::Id DeviceCheckBuildStep::stepId()
{
return "ProjectExplorer.DeviceCheckBuildStep";
}
QString DeviceCheckBuildStep::displayName()
{
return Tr::tr("Check for a configured device");
}
} // ProjectExplorer

View File

@@ -8,18 +8,10 @@
namespace ProjectExplorer {
class PROJECTEXPLORER_EXPORT DeviceCheckBuildStep : public BuildStep
class PROJECTEXPLORER_EXPORT DeviceCheckBuildStepFactory : public BuildStepFactory
{
Q_OBJECT
public:
DeviceCheckBuildStep(BuildStepList *bsl, Utils::Id id);
bool init() override;
void doRun() override;
static Utils::Id stepId();
static QString displayName();
DeviceCheckBuildStepFactory();
};
} // namespace ProjectExplorer
} // ProjectExplorer

View File

@@ -134,6 +134,7 @@ const char BUILDSTEPS_DEPLOY[] = "ProjectExplorer.BuildSteps.Deploy";
const char COPY_FILE_STEP[] = "ProjectExplorer.CopyFileStep";
const char COPY_DIRECTORY_STEP[] = "ProjectExplorer.CopyDirectoryStep";
const char DEVICE_CHECK_STEP[] = "ProjectExplorer.DeviceCheckBuildStep";
// Language

View File

@@ -15,5 +15,6 @@ const char QNX_QNX_OS_TYPE[] = "QnxOsType"; // Also used for device type.
const char QNX_TOOLCHAIN_ID[] = "Qnx.QccToolChain";
const char QNX_TMP_DIR[] = "/tmp"; // /var/run is root:root drwxr-xr-x
const char QNX_DIRECT_UPLOAD_STEP_ID[] ="Qnx.DirectUploadStep";
} // Qnx::Constants

View File

@@ -43,21 +43,22 @@ using namespace ProjectExplorer;
namespace Qnx::Internal {
class QnxUploadStep : public RemoteLinux::GenericDirectUploadStep
// FIXME: Remove...
class QnxUploadStepFactory : public RemoteLinux::GenericDirectUploadStepFactory
{
public:
QnxUploadStep(BuildStepList *bsl, Utils::Id id) : GenericDirectUploadStep(bsl, id) {}
static Utils::Id stepId() { return "Qnx.DirectUploadStep"; }
QnxUploadStepFactory()
{
registerStep<RemoteLinux::GenericDirectUploadStep>(Constants::QNX_DIRECT_UPLOAD_STEP_ID);
}
};
template <class Step>
class GenericQnxDeployStepFactory : public BuildStepFactory
template <class Factory>
class QnxDeployStepFactory : public RemoteLinux::MakeInstallStepFactory
{
public:
GenericQnxDeployStepFactory()
QnxDeployStepFactory()
{
registerStep<Step>(Step::stepId());
setDisplayName(Step::displayName());
setSupportedConfiguration(Constants::QNX_QNX_DEPLOYCONFIGURATION_ID);
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
}
@@ -78,8 +79,8 @@ public:
return prj->deploymentKnowledge() == DeploymentKnowledge::Bad
&& prj->hasMakeInstallEquivalent();
});
addInitialStep(DeviceCheckBuildStep::stepId());
addInitialStep(QnxUploadStep::stepId());
addInitialStep(ProjectExplorer::Constants::DEVICE_CHECK_STEP);
addInitialStep(Constants::QNX_DIRECT_UPLOAD_STEP_ID);
}
};
@@ -95,9 +96,9 @@ public:
QnxQtVersionFactory qtVersionFactory;
QnxDeviceFactory deviceFactory;
QnxDeployConfigurationFactory deployConfigFactory;
GenericQnxDeployStepFactory<QnxUploadStep> directUploadDeployFactory;
GenericQnxDeployStepFactory<RemoteLinux::MakeInstallStep> makeInstallDeployFactory;
GenericQnxDeployStepFactory<DeviceCheckBuildStep> checkBuildDeployFactory;
QnxDeployStepFactory<QnxUploadStepFactory> directUploadDeployFactory;
QnxDeployStepFactory<RemoteLinux::MakeInstallStepFactory> makeInstallDeployFactory;
QnxDeployStepFactory<DeviceCheckBuildStepFactory> checkBuildDeployFactory;
QnxRunConfigurationFactory runConfigFactory;
QnxSettingsPage settingsPage;
QnxToolChainFactory toolChainFactory;

View File

@@ -322,16 +322,6 @@ GenericDirectUploadStep::~GenericDirectUploadStep()
delete d;
}
Utils::Id GenericDirectUploadStep::stepId()
{
return Constants::DirectUploadStepId;
}
QString GenericDirectUploadStep::displayName()
{
return Tr::tr("Upload files via SFTP");
}
// Factory
GenericDirectUploadStepFactory::GenericDirectUploadStepFactory()
@@ -340,4 +330,4 @@ GenericDirectUploadStepFactory::GenericDirectUploadStepFactory()
setDisplayName(Tr::tr("Upload files via SFTP"));
}
} //namespace RemoteLinux
} // RemoteLinux

View File

@@ -20,9 +20,6 @@ public:
bool isDeploymentNecessary() const final;
Utils::Tasking::Group deployRecipe() final;
static Utils::Id stepId();
static QString displayName();
private:
friend class GenericDirectUploadStepPrivate;
class GenericDirectUploadStepPrivate *d;

View File

@@ -34,16 +34,14 @@ using namespace Utils;
namespace RemoteLinux {
namespace Internal {
template <class Step>
class GenericDeployStepFactory : public ProjectExplorer::BuildStepFactory
template <class Factory>
class RemoteLinuxDeployStepFactory : public Factory
{
public:
GenericDeployStepFactory()
RemoteLinuxDeployStepFactory()
{
registerStep<Step>(Step::stepId());
setDisplayName(Step::displayName());
setSupportedConfiguration(RemoteLinux::Constants::DeployToGenericLinux);
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
Factory::setSupportedConfiguration(RemoteLinux::Constants::DeployToGenericLinux);
Factory::setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_DEPLOY);
}
};
@@ -56,11 +54,11 @@ public:
RemoteLinuxDeployConfigurationFactory deployConfigurationFactory;
TarPackageCreationStepFactory tarPackageCreationStepFactory;
TarPackageDeployStepFactory tarPackageDeployStepFactory;
GenericDeployStepFactory<GenericDirectUploadStep> genericDirectUploadStepFactory;
GenericDeployStepFactory<RsyncDeployStep> rsyncDeployStepFactory;
RemoteLinuxDeployStepFactory<GenericDirectUploadStepFactory> genericDirectUploadStepFactory;
RemoteLinuxDeployStepFactory<RsyncDeployStepFactory> rsyncDeployStepFactory;
CustomCommandDeployStepFactory customCommandDeployStepFactory;
KillAppStepFactory killAppStepFactory;
GenericDeployStepFactory<MakeInstallStep> makeInstallStepFactory;
RemoteLinuxDeployStepFactory<MakeInstallStepFactory> makeInstallStepFactory;
RemoteLinuxRunWorkerFactory runWorkerFactory;
RemoteLinuxDebugWorkerFactory debugWorkerFactory;
RemoteLinuxQmlToolingWorkerFactory qmlToolingWorkerFactory;