From 2ebce73d13dcdd5300384daf348a2ffd51f52b24 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 28 Aug 2012 15:48:16 +0200 Subject: [PATCH] Madde: Add deploy step for starting Qemu. Until now, the code is duplicated in all deploy steps that need access to the device, which obviously doesn't scale. We now do it once in a dedicated step. Change-Id: I27f67f28a2e9ccaf9d2b3a5a9635d84b14f5eb07 Reviewed-by: Tobias Hunger --- src/plugins/madde/madde.pro | 6 +- src/plugins/madde/madde.qbs | 2 + src/plugins/madde/maddeqemustartstep.cpp | 128 ++++++++++++++++++ src/plugins/madde/maddeqemustartstep.h | 61 +++++++++ .../maddeuploadandinstallpackagesteps.cpp | 27 ---- src/plugins/madde/maemodeploybymountsteps.cpp | 25 +--- src/plugins/madde/maemodeploystepfactory.cpp | 28 ++-- .../madde/qt4maemodeployconfiguration.cpp | 16 ++- 8 files changed, 224 insertions(+), 69 deletions(-) create mode 100644 src/plugins/madde/maddeqemustartstep.cpp create mode 100644 src/plugins/madde/maddeqemustartstep.h diff --git a/src/plugins/madde/madde.pro b/src/plugins/madde/madde.pro index b72a2043393..73bf1efad46 100644 --- a/src/plugins/madde/madde.pro +++ b/src/plugins/madde/madde.pro @@ -49,7 +49,8 @@ HEADERS += \ maddedevicetester.h \ maddedeviceconfigurationfactory.h \ maddedevice.h \ - maemoapplicationrunnerhelperactions.h + maemoapplicationrunnerhelperactions.h \ + maddeqemustartstep.h SOURCES += \ maddeplugin.cpp \ @@ -92,7 +93,8 @@ SOURCES += \ maddedevicetester.cpp \ maemorunconfiguration.cpp \ maddedevice.cpp \ - maemoapplicationrunnerhelperactions.cpp + maemoapplicationrunnerhelperactions.cpp \ + maddeqemustartstep.cpp FORMS += \ maemopackagecreationwidget.ui \ diff --git a/src/plugins/madde/madde.qbs b/src/plugins/madde/madde.qbs index 9ed834d1dbf..260ca820504 100644 --- a/src/plugins/madde/madde.qbs +++ b/src/plugins/madde/madde.qbs @@ -30,6 +30,8 @@ QtcPlugin { "maddeplugin.h", "maddeuploadandinstallpackagesteps.cpp", "maddeuploadandinstallpackagesteps.h", + "maddeqemustartstep.cpp", + "maddeqemustartstep.h", "maemoconstants.h", "maemodeploybymountsteps.cpp", "maemodeploybymountsteps.h", diff --git a/src/plugins/madde/maddeqemustartstep.cpp b/src/plugins/madde/maddeqemustartstep.cpp new file mode 100644 index 00000000000..a2748712d5e --- /dev/null +++ b/src/plugins/madde/maddeqemustartstep.cpp @@ -0,0 +1,128 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: http://www.qt-project.org/ +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +**************************************************************************/ +#include "maddeqemustartstep.h" + +#include "maemoqemumanager.h" + +#include +#include +#include +#include + +using namespace ProjectExplorer; +using namespace RemoteLinux; + +namespace Madde { +namespace Internal { +class MaddeQemuStartService : public AbstractRemoteLinuxDeployService +{ + Q_OBJECT +public: + MaddeQemuStartService(QObject *parent = 0) : AbstractRemoteLinuxDeployService(parent) {} + +private: + bool isDeploymentNecessary() const { return true; } + + void doDeviceSetup() + { + emit progressMessage(tr("Checking whether to start Qemu...")); + if (deviceConfiguration()->machineType() == IDevice::Hardware) { + emit progressMessage(tr("Target device is not an emulator. Nothing to do.")); + handleDeviceSetupDone(true); + return; + } + + if (MaemoQemuManager::instance().qemuIsRunning()) { + emit progressMessage(tr("Qemu is already running. Nothing to do.")); + handleDeviceSetupDone(true); + return; + } + + MaemoQemuRuntime rt; + const int qtId = QtSupport::QtProfileInformation::qtVersionId(profile()); + if (MaemoQemuManager::instance().runtimeForQtVersion(qtId, &rt)) { + MaemoQemuManager::instance().startRuntime(); + emit errorMessage(tr("Cannot deploy: Qemu was not running. " + "It has now been started up for you, but it will take " + "a bit of time until it is ready. Please try again then.")); + } else { + emit errorMessage(tr("Cannot deploy: You want to deploy to Qemu, but it is not enabled " + "for this Qt version.")); + } + handleDeviceSetupDone(false); + } + + void stopDeviceSetup() { handleDeviceSetupDone(false); } + void doDeploy() { handleDeploymentDone(); } + void stopDeployment() { handleDeploymentDone(); } +}; + +MaddeQemuStartStep::MaddeQemuStartStep(BuildStepList *bsl) + : AbstractRemoteLinuxDeployStep(bsl, stepId()) +{ + ctor(); + setDefaultDisplayName(stepDisplayName()); +} + +MaddeQemuStartStep::MaddeQemuStartStep(BuildStepList *bsl, MaddeQemuStartStep *other) + : AbstractRemoteLinuxDeployStep(bsl, other) +{ + ctor(); +} + +AbstractRemoteLinuxDeployService *MaddeQemuStartStep::deployService() const +{ + return m_service; +} + +bool MaddeQemuStartStep::initInternal(QString *error) +{ + return deployService()->isDeploymentPossible(error); +} + +void MaddeQemuStartStep::ctor() +{ + m_service = new MaddeQemuStartService(this); +} + +Core::Id MaddeQemuStartStep::stepId() +{ + return Core::Id("Madde.MaddeQemuCheckStep"); +} + +QString MaddeQemuStartStep::stepDisplayName() +{ + return tr("Start Qemu, if necessary"); +} + +} // namespace Internal +} // namespace Madde + +#include "maddeqemustartstep.moc" diff --git a/src/plugins/madde/maddeqemustartstep.h b/src/plugins/madde/maddeqemustartstep.h new file mode 100644 index 00000000000..384faeddf84 --- /dev/null +++ b/src/plugins/madde/maddeqemustartstep.h @@ -0,0 +1,61 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: http://www.qt-project.org/ +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +**************************************************************************/ +#ifndef MAEMOQEMUCHECKSTEP_H +#define MAEMOQEMUCHECKSTEP_H + +#include + +namespace Madde { +namespace Internal { +class MaddeQemuStartService; + +class MaddeQemuStartStep : public RemoteLinux::AbstractRemoteLinuxDeployStep +{ + Q_OBJECT +public: + MaddeQemuStartStep(ProjectExplorer::BuildStepList *bsl); + MaddeQemuStartStep(ProjectExplorer::BuildStepList *bsl, MaddeQemuStartStep *other); + + static Core::Id stepId(); + static QString stepDisplayName(); + +private: + void ctor(); + + RemoteLinux::AbstractRemoteLinuxDeployService *deployService() const; + bool initInternal(QString *error = 0); + + MaddeQemuStartService *m_service; +}; + +} // namespace Internal +} // namespace Madde + +#endif // MAEMOQEMUCHECKSTEP_H diff --git a/src/plugins/madde/maddeuploadandinstallpackagesteps.cpp b/src/plugins/madde/maddeuploadandinstallpackagesteps.cpp index 6818171b449..9a5c918f45a 100644 --- a/src/plugins/madde/maddeuploadandinstallpackagesteps.cpp +++ b/src/plugins/madde/maddeuploadandinstallpackagesteps.cpp @@ -35,7 +35,6 @@ #include "maemoqemumanager.h" #include -#include #include #include #include @@ -57,32 +56,6 @@ protected: { } - void doDeviceSetup() - { - if (deviceConfiguration()->machineType() == IDevice::Hardware) { - handleDeviceSetupDone(true); - return; - } - - if (MaemoQemuManager::instance().qemuIsRunning()) { - handleDeviceSetupDone(true); - return; - } - - MaemoQemuRuntime rt; - const int qtId = QtSupport::QtProfileInformation::qtVersionId(profile()); - if (MaemoQemuManager::instance().runtimeForQtVersion(qtId, &rt)) { - MaemoQemuManager::instance().startRuntime(); - emit errorMessage(tr("Cannot deploy: Qemu was not running. " - "It has now been started up for you, but it will take " - "a bit of time until it is ready. Please try again then.")); - } else { - emit errorMessage(tr("Cannot deploy: You want to deploy to Qemu, but it is not enabled " - "for this Qt version.")); - } - handleDeviceSetupDone(false); - } - private: QString uploadDir() const { diff --git a/src/plugins/madde/maemodeploybymountsteps.cpp b/src/plugins/madde/maemodeploybymountsteps.cpp index 0503b9d72ef..88806ca38ca 100644 --- a/src/plugins/madde/maemodeploybymountsteps.cpp +++ b/src/plugins/madde/maemodeploybymountsteps.cpp @@ -40,8 +40,6 @@ #include #include #include -#include -#include #include #include #include @@ -156,28 +154,7 @@ void AbstractMaemoDeployByMountService::doDeviceSetup() { QTC_ASSERT(m_state == Inactive, return); - if (deviceConfiguration()->machineType() == IDevice::Hardware) { - handleDeviceSetupDone(true); - return; - } - - if (MaemoQemuManager::instance().qemuIsRunning()) { - handleDeviceSetupDone(true); - return; - } - - MaemoQemuRuntime rt; - const int qtId = QtSupport::QtProfileInformation::qtVersionId(profile()); - if (MaemoQemuManager::instance().runtimeForQtVersion(qtId, &rt)) { - MaemoQemuManager::instance().startRuntime(); - emit errorMessage(tr("Cannot deploy: Qemu was not running. " - "It has now been started up for you, but it will take " - "a bit of time until it is ready. Please try again then.")); - } else { - emit errorMessage(tr("Cannot deploy: You want to deploy to Qemu, but it is not enabled " - "for this Qt version.")); - } - handleDeviceSetupDone(false); + handleDeviceSetupDone(true); } void AbstractMaemoDeployByMountService::stopDeviceSetup() diff --git a/src/plugins/madde/maemodeploystepfactory.cpp b/src/plugins/madde/maemodeploystepfactory.cpp index b1ea5655e47..475bd7b8f19 100644 --- a/src/plugins/madde/maemodeploystepfactory.cpp +++ b/src/plugins/madde/maemodeploystepfactory.cpp @@ -31,6 +31,7 @@ #include "maemodeploystepfactory.h" #include "maemoconstants.h" +#include "maddeqemustartstep.h" #include "maddeuploadandinstallpackagesteps.h" #include "maemodeploybymountsteps.h" #include "maemoinstalltosysrootstep.h" @@ -73,16 +74,18 @@ QList MaemoDeployStepFactory::availableCreationIds(BuildStepList *pare platform = version->platformName(); if (platform == QtSupport::Constants::MAEMO_FREMANTLE_PLATFORM) { - ids << Core::Id(MaemoMakeInstallToSysrootStep::Id) - << Core::Id(MaemoInstallDebianPackageToSysrootStep::Id) - << Core::Id(MaemoUploadAndInstallPackageStep::stepId()) - << Core::Id(MaemoInstallPackageViaMountStep::stepId()) - << Core::Id(MaemoCopyFilesViaMountStep::stepId()); + ids << MaemoMakeInstallToSysrootStep::Id + << MaemoInstallDebianPackageToSysrootStep::Id + << MaemoUploadAndInstallPackageStep::stepId() + << MaemoInstallPackageViaMountStep::stepId() + << MaemoCopyFilesViaMountStep::stepId() + << MaddeQemuStartStep::stepId(); } else if (platform == QtSupport::Constants::MEEGO_HARMATTAN_PLATFORM) { - ids << Core::Id(MaemoMakeInstallToSysrootStep::Id) - << Core::Id(MaemoInstallDebianPackageToSysrootStep::Id) - << Core::Id(MaemoUploadAndInstallPackageStep::stepId()) - << Core::Id(GenericDirectUploadStep::stepId()); + ids << MaemoMakeInstallToSysrootStep::Id + << MaemoInstallDebianPackageToSysrootStep::Id + << MaemoUploadAndInstallPackageStep::stepId() + << GenericDirectUploadStep::stepId() + << MaddeQemuStartStep::stepId(); } return ids; @@ -106,6 +109,8 @@ QString MaemoDeployStepFactory::displayNameForId(const Core::Id id) const return GenericDirectUploadStep::displayName(); if (id == RemoteLinuxCheckForFreeDiskSpaceStep::stepId()) return RemoteLinuxCheckForFreeDiskSpaceStep::stepDisplayName(); + if (id == MaddeQemuStartStep::stepId()) + return MaddeQemuStartStep::stepDisplayName(); return QString(); } @@ -136,7 +141,8 @@ BuildStep *MaemoDeployStepFactory::create(BuildStepList *parent, const Core::Id return new GenericDirectUploadStep(parent, id); if (id == RemoteLinuxCheckForFreeDiskSpaceStep::stepId()) return new RemoteLinuxCheckForFreeDiskSpaceStep(parent); - + if (id == MaddeQemuStartStep::stepId()) + return new MaddeQemuStartStep(parent); return 0; } @@ -187,6 +193,8 @@ BuildStep *MaemoDeployStepFactory::clone(BuildStepList *parent, BuildStep *produ qobject_cast(product)); } else if (RemoteLinuxCheckForFreeDiskSpaceStep * const other = qobject_cast(product)) { return new RemoteLinuxCheckForFreeDiskSpaceStep(parent, other); + } else if (MaddeQemuStartStep * const other = qobject_cast(product)) { + return new MaddeQemuStartStep(parent, other); } return 0; diff --git a/src/plugins/madde/qt4maemodeployconfiguration.cpp b/src/plugins/madde/qt4maemodeployconfiguration.cpp index afe60a1fbda..667f110a60f 100644 --- a/src/plugins/madde/qt4maemodeployconfiguration.cpp +++ b/src/plugins/madde/qt4maemodeployconfiguration.cpp @@ -30,6 +30,7 @@ #include "qt4maemodeployconfiguration.h" #include "debianmanager.h" +#include "maddeqemustartstep.h" #include "maddeuploadandinstallpackagesteps.h" #include "maemoconstants.h" #include "maemodeploybymountsteps.h" @@ -304,18 +305,21 @@ DeployConfiguration *Qt4MaemoDeployConfigurationFactory::create(Target *parent, if (id == Qt4MaemoDeployConfiguration::fremantleWithoutPackagingId()) { dc->stepList()->insertStep(0, new MaemoMakeInstallToSysrootStep(dc->stepList())); - dc->stepList()->insertStep(1, new RemoteLinuxCheckForFreeDiskSpaceStep(dc->stepList())); - dc->stepList()->insertStep(2, new MaemoCopyFilesViaMountStep(dc->stepList())); + dc->stepList()->insertStep(1, new MaddeQemuStartStep(dc->stepList())); + dc->stepList()->insertStep(2, new RemoteLinuxCheckForFreeDiskSpaceStep(dc->stepList())); + dc->stepList()->insertStep(3, new MaemoCopyFilesViaMountStep(dc->stepList())); } else if (id == Qt4MaemoDeployConfiguration::fremantleWithPackagingId()) { dc->stepList()->insertStep(0, new MaemoDebianPackageCreationStep(dc->stepList())); dc->stepList()->insertStep(1, new MaemoInstallDebianPackageToSysrootStep(dc->stepList())); - dc->stepList()->insertStep(2, new RemoteLinuxCheckForFreeDiskSpaceStep(dc->stepList())); - dc->stepList()->insertStep(3, new MaemoInstallPackageViaMountStep(dc->stepList())); + dc->stepList()->insertStep(2, new MaddeQemuStartStep(dc->stepList())); + dc->stepList()->insertStep(3, new RemoteLinuxCheckForFreeDiskSpaceStep(dc->stepList())); + dc->stepList()->insertStep(4, new MaemoInstallPackageViaMountStep(dc->stepList())); } else if (id == Qt4MaemoDeployConfiguration::harmattanId()) { dc->stepList()->insertStep(0, new MaemoDebianPackageCreationStep(dc->stepList())); dc->stepList()->insertStep(1, new MaemoInstallDebianPackageToSysrootStep(dc->stepList())); - dc->stepList()->insertStep(2, new RemoteLinuxCheckForFreeDiskSpaceStep(dc->stepList())); - dc->stepList()->insertStep(3, new MaemoUploadAndInstallPackageStep(dc->stepList())); + dc->stepList()->insertStep(2, new MaddeQemuStartStep(dc->stepList())); + dc->stepList()->insertStep(3, new RemoteLinuxCheckForFreeDiskSpaceStep(dc->stepList())); + dc->stepList()->insertStep(4, new MaemoUploadAndInstallPackageStep(dc->stepList())); } return dc; }