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 <tobias.hunger@nokia.com>
This commit is contained in:
Christian Kandeler
2012-08-28 15:48:16 +02:00
parent 909f936a32
commit 2ebce73d13
8 changed files with 224 additions and 69 deletions

View File

@@ -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 \

View File

@@ -30,6 +30,8 @@ QtcPlugin {
"maddeplugin.h",
"maddeuploadandinstallpackagesteps.cpp",
"maddeuploadandinstallpackagesteps.h",
"maddeqemustartstep.cpp",
"maddeqemustartstep.h",
"maemoconstants.h",
"maemodeploybymountsteps.cpp",
"maemodeploybymountsteps.h",

View File

@@ -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 <qtsupport/baseqtversion.h>
#include <qtsupport/qtprofileinformation.h>
#include <remotelinux/abstractremotelinuxdeployservice.h>
#include <utils/qtcassert.h>
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"

View File

@@ -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 <remotelinux/abstractremotelinuxdeploystep.h>
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

View File

@@ -35,7 +35,6 @@
#include "maemoqemumanager.h"
#include <projectexplorer/target.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtprofileinformation.h>
#include <remotelinux/abstractuploadandinstallpackageservice.h>
#include <remotelinux/remotelinuxdeployconfiguration.h>
@@ -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
{

View File

@@ -40,8 +40,6 @@
#include <projectexplorer/project.h>
#include <projectexplorer/target.h>
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtprofileinformation.h>
#include <remotelinux/abstractremotelinuxdeployservice.h>
#include <remotelinux/deployablefile.h>
#include <remotelinux/deploymentinfo.h>
@@ -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()

View File

@@ -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<Core::Id> 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<GenericDirectUploadStep *>(product));
} else if (RemoteLinuxCheckForFreeDiskSpaceStep * const other = qobject_cast<RemoteLinuxCheckForFreeDiskSpaceStep *>(product)) {
return new RemoteLinuxCheckForFreeDiskSpaceStep(parent, other);
} else if (MaddeQemuStartStep * const other = qobject_cast<MaddeQemuStartStep *>(product)) {
return new MaddeQemuStartStep(parent, other);
}
return 0;

View File

@@ -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;
}