forked from qt-creator/qt-creator
Long overdue changes and refactoring for qemu handling.
Fixes: - react on build/ run configuration changes
- now notices environment changes, like switching Qt versions
- start button is now only shown if we have a valid qemu runtime
- enabled/ disabled state works properly when loading a project
Task-number: QTCREATOR-210, QTCREATORBUG-1252, QTCREATORBUG-1082
Reviewed-by: ck
This commit is contained in:
@@ -39,10 +39,22 @@
|
|||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
enum QemuStatus { QemuStarting, QemuFailedToStart, QemuFinished, QemuCrashed };
|
enum QemuStatus {
|
||||||
|
QemuStarting,
|
||||||
|
QemuFailedToStart,
|
||||||
|
QemuFinished,
|
||||||
|
QemuCrashed,
|
||||||
|
QemuUserReason
|
||||||
|
};
|
||||||
|
|
||||||
#define PREFIX "Qt4ProjectManager.MaemoRunConfiguration"
|
#define PREFIX "Qt4ProjectManager.MaemoRunConfiguration"
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
#define EXEC_SUFFIX ".exe"
|
||||||
|
#else
|
||||||
|
#define EXEC_SUFFIX ""
|
||||||
|
#endif
|
||||||
|
|
||||||
static const QLatin1String MAEMO_RC_ID(PREFIX);
|
static const QLatin1String MAEMO_RC_ID(PREFIX);
|
||||||
static const QLatin1String MAEMO_RC_ID_PREFIX(PREFIX ".");
|
static const QLatin1String MAEMO_RC_ID_PREFIX(PREFIX ".");
|
||||||
|
|
||||||
|
|||||||
@@ -28,55 +28,39 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "maemomanager.h"
|
#include "maemomanager.h"
|
||||||
#include "qtversionmanager.h"
|
|
||||||
|
|
||||||
|
#include "maemoconstants.h"
|
||||||
#include "maemodeviceconfigurations.h"
|
#include "maemodeviceconfigurations.h"
|
||||||
#include "maemopackagecreationfactory.h"
|
#include "maemopackagecreationfactory.h"
|
||||||
#include "maemorunfactories.h"
|
#include "maemorunfactories.h"
|
||||||
#include "maemosettingspage.h"
|
#include "maemosettingspage.h"
|
||||||
#include "maemotoolchain.h"
|
#include "maemotoolchain.h"
|
||||||
#include "maemorunconfiguration.h"
|
#include "qemuruntimemanager.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
|
||||||
#include <coreplugin/coreconstants.h>
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <coreplugin/modemanager.h>
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
#include <qt4projectmanager/qtversionmanager.h>
|
||||||
#include <coreplugin/actionmanager/command.h>
|
|
||||||
|
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QList>
|
|
||||||
#include <QtCore/QTextStream>
|
#include <QtCore/QTextStream>
|
||||||
|
|
||||||
#include <QtGui/QAction>
|
|
||||||
#include <QtGui/QMessageBox>
|
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
MaemoManager *MaemoManager::m_instance = 0;
|
MaemoManager *MaemoManager::m_instance = 0;
|
||||||
|
|
||||||
const QSize iconSize = QSize(24, 20);
|
|
||||||
|
|
||||||
MaemoManager::MaemoManager()
|
MaemoManager::MaemoManager()
|
||||||
: QObject(0)
|
: QObject(0)
|
||||||
, m_runControlFactory(new MaemoRunControlFactory(this))
|
, m_runControlFactory(new MaemoRunControlFactory(this))
|
||||||
, m_runConfigurationFactory(new MaemoRunConfigurationFactory(this))
|
, m_runConfigurationFactory(new MaemoRunConfigurationFactory(this))
|
||||||
, m_packageCreationFactory(new MaemoPackageCreationFactory(this))
|
, m_packageCreationFactory(new MaemoPackageCreationFactory(this))
|
||||||
, m_settingsPage(new MaemoSettingsPage(this))
|
, m_settingsPage(new MaemoSettingsPage(this))
|
||||||
, m_qemuAction(0)
|
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_instance);
|
Q_ASSERT(!m_instance);
|
||||||
|
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
MaemoDeviceConfigurations::instance(this);
|
MaemoDeviceConfigurations::instance(this);
|
||||||
|
|
||||||
icon.addFile(":/qt-maemo/images/qemu-run.png", iconSize);
|
|
||||||
icon.addFile(":/qt-maemo/images/qemu-stop.png", iconSize, QIcon::Normal,
|
|
||||||
QIcon::On);
|
|
||||||
|
|
||||||
ExtensionSystem::PluginManager *pluginManager
|
ExtensionSystem::PluginManager *pluginManager
|
||||||
= ExtensionSystem::PluginManager::instance();
|
= ExtensionSystem::PluginManager::instance();
|
||||||
pluginManager->addObject(m_runControlFactory);
|
pluginManager->addObject(m_runControlFactory);
|
||||||
@@ -103,6 +87,11 @@ MaemoManager &MaemoManager::instance()
|
|||||||
return *m_instance;
|
return *m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MaemoManager::init()
|
||||||
|
{
|
||||||
|
m_qemuRuntimeManager = new QemuRuntimeManager(this);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MaemoManager::isValidMaemoQtVersion(const Qt4ProjectManager::QtVersion *version) const
|
MaemoManager::isValidMaemoQtVersion(const Qt4ProjectManager::QtVersion *version) const
|
||||||
{
|
{
|
||||||
@@ -135,108 +124,5 @@ MaemoManager::maemoToolChain(const QtVersion *version) const
|
|||||||
return new MaemoToolChain(targetRoot);
|
return new MaemoToolChain(targetRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
} // namespace Internal
|
||||||
MaemoManager::addQemuSimulatorStarter(Project *project)
|
|
||||||
{
|
|
||||||
if (projects.contains(project))
|
|
||||||
return;
|
|
||||||
projects.insert(project);
|
|
||||||
|
|
||||||
if (m_qemuAction) {
|
|
||||||
m_qemuAction->setVisible(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_qemuAction = new QAction("Maemo Emulator", this);
|
|
||||||
m_qemuAction->setEnabled(false);
|
|
||||||
m_qemuAction->setIcon(icon.pixmap(iconSize));
|
|
||||||
m_qemuAction->setToolTip(tr("Start Maemo Emulator"));
|
|
||||||
connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(triggered()));
|
|
||||||
|
|
||||||
Core::ICore *core = Core::ICore::instance();
|
|
||||||
Core::ActionManager *actionManager = core->actionManager();
|
|
||||||
Core::Command *qemuCommand = actionManager->registerAction(m_qemuAction,
|
|
||||||
"MaemoEmulator", QList<int>() << Core::Constants::C_GLOBAL_ID);
|
|
||||||
qemuCommand->setAttribute(Core::Command::CA_UpdateText);
|
|
||||||
qemuCommand->setAttribute(Core::Command::CA_UpdateIcon);
|
|
||||||
|
|
||||||
Core::ModeManager *modeManager = core->modeManager();
|
|
||||||
modeManager->addAction(qemuCommand, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MaemoManager::removeQemuSimulatorStarter(Project *project)
|
|
||||||
{
|
|
||||||
if (projects.contains(project)) {
|
|
||||||
projects.remove(project);
|
|
||||||
if (projects.isEmpty() && m_qemuAction)
|
|
||||||
m_qemuAction->setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MaemoManager::setQemuSimulatorStarterEnabled(bool enable)
|
|
||||||
{
|
|
||||||
if (m_qemuAction)
|
|
||||||
m_qemuAction->setEnabled(enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MaemoManager::triggered()
|
|
||||||
{
|
|
||||||
emit startStopQemu();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MaemoManager::qemuStatusChanged(QemuStatus status, const QString &error)
|
|
||||||
{
|
|
||||||
if (!m_qemuAction)
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool running;
|
|
||||||
QString message;
|
|
||||||
switch (status) {
|
|
||||||
case QemuStarting:
|
|
||||||
running = true;
|
|
||||||
break;
|
|
||||||
case QemuFailedToStart:
|
|
||||||
running = false;
|
|
||||||
message = tr("Qemu failed to start: %1").arg(error);
|
|
||||||
break;
|
|
||||||
case QemuCrashed:
|
|
||||||
running = false;
|
|
||||||
message = tr("Qemu crashed");
|
|
||||||
break;
|
|
||||||
case QemuFinished:
|
|
||||||
running = false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Q_ASSERT(!"Missing handling of Qemu status");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!message.isEmpty())
|
|
||||||
QMessageBox::warning(0, tr("Qemu error"), message);
|
|
||||||
updateQemuIcon(running);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoManager::updateQemuIcon(bool running)
|
|
||||||
{
|
|
||||||
if (!m_qemuAction)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QIcon::State state;
|
|
||||||
QString toolTip;
|
|
||||||
if (running) {
|
|
||||||
state = QIcon::On;
|
|
||||||
toolTip = tr("Stop Maemo Emulator");
|
|
||||||
} else {
|
|
||||||
state = QIcon::Off;
|
|
||||||
toolTip = tr("Start Maemo Emulator");
|
|
||||||
}
|
|
||||||
|
|
||||||
m_qemuAction->setToolTip(toolTip);
|
|
||||||
m_qemuAction->setIcon(icon.pixmap(iconSize, QIcon::Normal, state));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -30,20 +30,11 @@
|
|||||||
#ifndef MAEMOMANAGER_H
|
#ifndef MAEMOMANAGER_H
|
||||||
#define MAEMOMANAGER_H
|
#define MAEMOMANAGER_H
|
||||||
|
|
||||||
#include "maemoconstants.h"
|
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QSet>
|
|
||||||
|
|
||||||
#include <QtGui/QIcon>
|
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QAction);
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class Project;
|
|
||||||
class ToolChain;
|
class ToolChain;
|
||||||
}
|
}
|
||||||
using ProjectExplorer::Project;
|
|
||||||
using ProjectExplorer::ToolChain;
|
using ProjectExplorer::ToolChain;
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
@@ -54,34 +45,24 @@ class MaemoPackageCreationFactory;
|
|||||||
class MaemoRunControlFactory;
|
class MaemoRunControlFactory;
|
||||||
class MaemoRunConfigurationFactory;
|
class MaemoRunConfigurationFactory;
|
||||||
class MaemoSettingsPage;
|
class MaemoSettingsPage;
|
||||||
|
class QemuRuntimeManager;
|
||||||
|
|
||||||
class MaemoManager : public QObject
|
class MaemoManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MaemoManager();
|
MaemoManager();
|
||||||
~MaemoManager();
|
~MaemoManager();
|
||||||
static MaemoManager &instance();
|
static MaemoManager &instance();
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
bool isValidMaemoQtVersion(const Qt4ProjectManager::QtVersion *version) const;
|
bool isValidMaemoQtVersion(const Qt4ProjectManager::QtVersion *version) const;
|
||||||
void addVersion(const Qt4ProjectManager::QtVersion *version) { Q_UNUSED(version); }
|
|
||||||
ToolChain *maemoToolChain(const Qt4ProjectManager::QtVersion *version) const;
|
ToolChain *maemoToolChain(const Qt4ProjectManager::QtVersion *version) const;
|
||||||
|
|
||||||
void addQemuSimulatorStarter(Project *project);
|
|
||||||
void removeQemuSimulatorStarter(Project *project);
|
|
||||||
|
|
||||||
void setQemuSimulatorStarterEnabled(bool state);
|
|
||||||
void updateQemuIcon(bool running);
|
|
||||||
|
|
||||||
MaemoSettingsPage *settingsPage() const { return m_settingsPage; }
|
MaemoSettingsPage *settingsPage() const { return m_settingsPage; }
|
||||||
|
|
||||||
public slots:
|
|
||||||
void triggered();
|
|
||||||
void qemuStatusChanged(QemuStatus status, const QString &error);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void startStopQemu();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static MaemoManager *m_instance;
|
static MaemoManager *m_instance;
|
||||||
|
|
||||||
@@ -89,11 +70,7 @@ private:
|
|||||||
MaemoRunConfigurationFactory *m_runConfigurationFactory;
|
MaemoRunConfigurationFactory *m_runConfigurationFactory;
|
||||||
MaemoPackageCreationFactory *m_packageCreationFactory;
|
MaemoPackageCreationFactory *m_packageCreationFactory;
|
||||||
MaemoSettingsPage *m_settingsPage;
|
MaemoSettingsPage *m_settingsPage;
|
||||||
|
QemuRuntimeManager *m_qemuRuntimeManager;
|
||||||
QIcon icon;
|
|
||||||
int m_runCount;
|
|
||||||
QSet<Project*> projects;
|
|
||||||
QAction *m_qemuAction;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -26,13 +26,13 @@
|
|||||||
** contact the sales department at http://qt.nokia.com/contact.
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
**
|
**
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "maemorunconfiguration.h"
|
#include "maemorunconfiguration.h"
|
||||||
|
|
||||||
#include "maemoconstants.h"
|
|
||||||
#include "maemomanager.h"
|
|
||||||
#include "maemopackagecreationstep.h"
|
#include "maemopackagecreationstep.h"
|
||||||
#include "maemorunconfigurationwidget.h"
|
#include "maemorunconfigurationwidget.h"
|
||||||
#include "maemotoolchain.h"
|
#include "maemotoolchain.h"
|
||||||
|
#include "qemuruntimemanager.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
@@ -45,9 +45,6 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
|
||||||
#include <QtCore/QProcess>
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include <QtCore/QStringBuilder>
|
#include <QtCore/QStringBuilder>
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
@@ -59,8 +56,6 @@ MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent,
|
|||||||
const QString &proFilePath)
|
const QString &proFilePath)
|
||||||
: RunConfiguration(parent, QLatin1String(MAEMO_RC_ID))
|
: RunConfiguration(parent, QLatin1String(MAEMO_RC_ID))
|
||||||
, m_proFilePath(proFilePath)
|
, m_proFilePath(proFilePath)
|
||||||
, m_cachedSimulatorInformationValid(false)
|
|
||||||
, qemu(0)
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -69,20 +64,11 @@ MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent,
|
|||||||
MaemoRunConfiguration *source)
|
MaemoRunConfiguration *source)
|
||||||
: RunConfiguration(parent, source)
|
: RunConfiguration(parent, source)
|
||||||
, m_proFilePath(source->m_proFilePath)
|
, m_proFilePath(source->m_proFilePath)
|
||||||
, m_simulator(source->m_simulator)
|
|
||||||
, m_simulatorArgs(source->m_simulatorArgs)
|
|
||||||
, m_simulatorPath(source->m_simulatorPath)
|
|
||||||
, m_visibleSimulatorParameter(source->m_visibleSimulatorParameter)
|
|
||||||
, m_simulatorLibPath(source->m_simulatorLibPath)
|
|
||||||
, m_simulatorSshPort(source->m_simulatorSshPort)
|
|
||||||
, m_simulatorGdbServerPort(source->m_simulatorGdbServerPort)
|
|
||||||
, m_cachedSimulatorInformationValid(false)
|
|
||||||
, m_gdbPath(source->m_gdbPath)
|
, m_gdbPath(source->m_gdbPath)
|
||||||
, m_devConfig(source->m_devConfig)
|
, m_devConfig(source->m_devConfig)
|
||||||
, m_arguments(source->m_arguments)
|
, m_arguments(source->m_arguments)
|
||||||
, m_lastDeployed(source->m_lastDeployed)
|
, m_lastDeployed(source->m_lastDeployed)
|
||||||
, m_debuggingHelpersLastDeployed(source->m_debuggingHelpersLastDeployed)
|
, m_debuggingHelpersLastDeployed(source->m_debuggingHelpersLastDeployed)
|
||||||
, qemu(0)
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -98,28 +84,10 @@ void MaemoRunConfiguration::init()
|
|||||||
connect(qt4Target()->qt4Project(),
|
connect(qt4Target()->qt4Project(),
|
||||||
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
|
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
|
||||||
this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*)));
|
this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*)));
|
||||||
|
|
||||||
qemu = new QProcess(this);
|
|
||||||
connect(qemu, SIGNAL(error(QProcess::ProcessError)), this,
|
|
||||||
SLOT(qemuProcessError(QProcess::ProcessError)));
|
|
||||||
connect(qemu, SIGNAL(finished(int, QProcess::ExitStatus)), this,
|
|
||||||
SLOT(qemuProcessFinished()));
|
|
||||||
|
|
||||||
connect(&MaemoManager::instance(), SIGNAL(startStopQemu()), this,
|
|
||||||
SLOT(startStopQemu()));
|
|
||||||
connect(this, SIGNAL(qemuProcessStatus(QemuStatus, QString)),
|
|
||||||
&MaemoManager::instance(),
|
|
||||||
SLOT(qemuStatusChanged(QemuStatus,QString)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaemoRunConfiguration::~MaemoRunConfiguration()
|
MaemoRunConfiguration::~MaemoRunConfiguration()
|
||||||
{
|
{
|
||||||
if (qemu && qemu->state() != QProcess::NotRunning) {
|
|
||||||
qemu->terminate();
|
|
||||||
qemu->kill();
|
|
||||||
}
|
|
||||||
delete qemu;
|
|
||||||
qemu = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt4Target *MaemoRunConfiguration::qt4Target() const
|
Qt4Target *MaemoRunConfiguration::qt4Target() const
|
||||||
@@ -161,8 +129,6 @@ QVariantMap MaemoRunConfiguration::toMap() const
|
|||||||
addDeployTimesToMap(DebuggingHelpersLastDeployedKey,
|
addDeployTimesToMap(DebuggingHelpersLastDeployedKey,
|
||||||
m_debuggingHelpersLastDeployed, map);
|
m_debuggingHelpersLastDeployed, map);
|
||||||
|
|
||||||
map.insert(SimulatorPathKey, m_simulatorPath);
|
|
||||||
|
|
||||||
const QDir dir = QDir(target()->project()->projectDirectory());
|
const QDir dir = QDir(target()->project()->projectDirectory());
|
||||||
map.insert(ProFileKey, dir.relativeFilePath(m_proFilePath));
|
map.insert(ProFileKey, dir.relativeFilePath(m_proFilePath));
|
||||||
|
|
||||||
@@ -192,8 +158,6 @@ bool MaemoRunConfiguration::fromMap(const QVariantMap &map)
|
|||||||
getDeployTimesFromMap(DebuggingHelpersLastDeployedKey,
|
getDeployTimesFromMap(DebuggingHelpersLastDeployedKey,
|
||||||
m_debuggingHelpersLastDeployed, map);
|
m_debuggingHelpersLastDeployed, map);
|
||||||
|
|
||||||
m_simulatorPath = map.value(SimulatorPathKey).toString();
|
|
||||||
|
|
||||||
const QDir dir = QDir(target()->project()->projectDirectory());
|
const QDir dir = QDir(target()->project()->projectDirectory());
|
||||||
m_proFilePath = dir.filePath(map.value(ProFileKey).toString());
|
m_proFilePath = dir.filePath(map.value(ProFileKey).toString());
|
||||||
|
|
||||||
@@ -351,40 +315,15 @@ QString MaemoRunConfiguration::executable() const
|
|||||||
+ QLatin1Char('/') + ti.target));
|
+ QLatin1Char('/') + ti.target));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaemoRunConfiguration::simulatorSshPort() const
|
QString MaemoRunConfiguration::runtimeGdbServerPort() const
|
||||||
{
|
{
|
||||||
updateSimulatorInformation();
|
if (Qt4BuildConfiguration *qt4bc = activeQt4BuildConfiguration()) {
|
||||||
return m_simulatorSshPort;
|
Runtime rt;
|
||||||
}
|
const int id = qt4bc->qtVersion()->uniqueId();
|
||||||
|
if (QemuRuntimeManager::instance().runtimeForQtVersion(id, &rt))
|
||||||
QString MaemoRunConfiguration::simulatorGdbServerPort() const
|
return rt.m_gdbServerPort;
|
||||||
{
|
}
|
||||||
updateSimulatorInformation();;
|
return QLatin1String("13219");
|
||||||
return m_simulatorGdbServerPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MaemoRunConfiguration::simulatorPath() const
|
|
||||||
{
|
|
||||||
updateSimulatorInformation();
|
|
||||||
return m_simulatorPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MaemoRunConfiguration::visibleSimulatorParameter() const
|
|
||||||
{
|
|
||||||
updateSimulatorInformation();
|
|
||||||
return m_visibleSimulatorParameter;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MaemoRunConfiguration::simulator() const
|
|
||||||
{
|
|
||||||
updateSimulatorInformation();
|
|
||||||
return m_simulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MaemoRunConfiguration::simulatorArgs() const
|
|
||||||
{
|
|
||||||
updateSimulatorInformation();
|
|
||||||
return m_simulatorArgs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRunConfiguration::setArguments(const QStringList &args)
|
void MaemoRunConfiguration::setArguments(const QStringList &args)
|
||||||
@@ -392,137 +331,6 @@ void MaemoRunConfiguration::setArguments(const QStringList &args)
|
|||||||
m_arguments = args;
|
m_arguments = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MaemoRunConfiguration::isQemuRunning() const
|
|
||||||
{
|
|
||||||
return (qemu && qemu->state() != QProcess::NotRunning);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfiguration::updateSimulatorInformation() const
|
|
||||||
{
|
|
||||||
if (m_cachedSimulatorInformationValid)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_simulator.clear();
|
|
||||||
m_simulatorPath.clear();
|
|
||||||
m_simulatorArgs.clear();
|
|
||||||
m_visibleSimulatorParameter.clear();
|
|
||||||
m_simulatorLibPath.clear();
|
|
||||||
m_simulatorSshPort.clear();
|
|
||||||
m_simulatorGdbServerPort.clear();
|
|
||||||
m_cachedSimulatorInformationValid = true;
|
|
||||||
|
|
||||||
if (const MaemoToolChain *tc = toolchain())
|
|
||||||
m_simulatorPath = QDir::toNativeSeparators(tc->simulatorRoot());
|
|
||||||
|
|
||||||
if (!m_simulatorPath.isEmpty()) {
|
|
||||||
m_visibleSimulatorParameter = tr("'%1' does not contain a valid Maemo "
|
|
||||||
"simulator image.").arg(m_simulatorPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
QDir dir = QDir(m_simulatorPath);
|
|
||||||
if (!m_simulatorPath.isEmpty() && dir.exists(m_simulatorPath)) {
|
|
||||||
const QStringList &files = dir.entryList(QDir::Files | QDir::NoSymLinks
|
|
||||||
| QDir::NoDotAndDotDot);
|
|
||||||
if (files.count() >= 2) {
|
|
||||||
const QLatin1String info("information");
|
|
||||||
if (files.contains(info)) {
|
|
||||||
QFile file(m_simulatorPath + QLatin1Char('/') + info);
|
|
||||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
||||||
QMap<QString, QString> map;
|
|
||||||
QTextStream stream(&file);
|
|
||||||
while (!stream.atEnd()) {
|
|
||||||
const QString &line = stream.readLine().trimmed();
|
|
||||||
const int index = line.indexOf(QLatin1Char('='));
|
|
||||||
map.insert(line.mid(0, index).remove(QLatin1Char('\'')),
|
|
||||||
line.mid(index + 1).remove(QLatin1Char('\'')));
|
|
||||||
}
|
|
||||||
|
|
||||||
m_simulator = map.value(QLatin1String("qemu"));
|
|
||||||
m_simulatorArgs = map.value(QLatin1String("qemu_args"));
|
|
||||||
const QString &libPathSpec
|
|
||||||
= map.value(QLatin1String("libpath"));
|
|
||||||
m_simulatorLibPath
|
|
||||||
= libPathSpec.mid(libPathSpec.indexOf(QLatin1Char('=')) + 1);
|
|
||||||
m_simulatorSshPort = map.value(QLatin1String("sshport"));
|
|
||||||
m_simulatorGdbServerPort
|
|
||||||
= map.value(QLatin1String("redirport2"));
|
|
||||||
|
|
||||||
m_visibleSimulatorParameter = m_simulator
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
+ QLatin1String(".exe")
|
|
||||||
#endif
|
|
||||||
+ QLatin1Char(' ') + m_simulatorArgs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m_visibleSimulatorParameter = tr("Simulator could not be found. Please "
|
|
||||||
"check the Qt Version you are using and that a simulator image is "
|
|
||||||
"already installed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
emit cachedSimulatorInformationChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfiguration::startStopQemu()
|
|
||||||
{
|
|
||||||
ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance();
|
|
||||||
if (explorer->session()->startupProject() != target()->project())
|
|
||||||
return;
|
|
||||||
|
|
||||||
const MaemoDeviceConfig &config = deviceConfig();
|
|
||||||
if (!config.isValid()|| config.type != MaemoDeviceConfig::Simulator)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (qemu->state() != QProcess::NotRunning) {
|
|
||||||
if (qemu->state() == QProcess::Running) {
|
|
||||||
qemu->terminate();
|
|
||||||
qemu->kill();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString root = maddeRoot();
|
|
||||||
if (root.isEmpty() || simulator().isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
const QLatin1Char colon(';');
|
|
||||||
const QString path = QDir::toNativeSeparators(root + QLatin1Char('/'));
|
|
||||||
const QLatin1String key("PATH");
|
|
||||||
env.insert(key, env.value(key) % colon % path % QLatin1String("bin"));
|
|
||||||
env.insert(key, env.value(key) % colon % path % QLatin1String("madlib"));
|
|
||||||
#elif defined(Q_OS_UNIX)
|
|
||||||
const QLatin1String key("LD_LIBRARY_PATH");
|
|
||||||
env.insert(key, env.value(key) % QLatin1Char(':') % m_simulatorLibPath);
|
|
||||||
#endif
|
|
||||||
qemu->setProcessEnvironment(env);
|
|
||||||
qemu->setWorkingDirectory(simulatorPath());
|
|
||||||
|
|
||||||
const QString app = root % QLatin1String("/madlib/") % simulator()
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
% QLatin1String(".exe")
|
|
||||||
#endif
|
|
||||||
; // keep
|
|
||||||
|
|
||||||
qemu->start(app % QLatin1Char(' ') % simulatorArgs(), QIODevice::ReadWrite);
|
|
||||||
emit qemuProcessStatus(QemuStarting);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfiguration::qemuProcessFinished()
|
|
||||||
{
|
|
||||||
const QemuStatus status
|
|
||||||
= qemu->exitStatus() == QProcess::CrashExit ? QemuCrashed : QemuFinished;
|
|
||||||
emit qemuProcessStatus(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfiguration::qemuProcessError(QProcess::ProcessError error)
|
|
||||||
{
|
|
||||||
if (error == QProcess::FailedToStart)
|
|
||||||
emit qemuProcessStatus(QemuFailedToStart, qemu->errorString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfiguration::updateDeviceConfigurations()
|
void MaemoRunConfiguration::updateDeviceConfigurations()
|
||||||
{
|
{
|
||||||
const MaemoDeviceConfigurations &configManager
|
const MaemoDeviceConfigurations &configManager
|
||||||
|
|||||||
@@ -36,10 +36,8 @@
|
|||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
|
|
||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
#include <QtCore/QProcess>
|
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QProcess)
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QWidget)
|
QT_FORWARD_DECLARE_CLASS(QWidget)
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
@@ -88,29 +86,19 @@ public:
|
|||||||
void setArguments(const QStringList &args);
|
void setArguments(const QStringList &args);
|
||||||
void setDeviceConfig(const MaemoDeviceConfig &deviceConfig);
|
void setDeviceConfig(const MaemoDeviceConfig &deviceConfig);
|
||||||
MaemoDeviceConfig deviceConfig() const;
|
MaemoDeviceConfig deviceConfig() const;
|
||||||
|
QString runtimeGdbServerPort() const;
|
||||||
QString simulator() const;
|
|
||||||
QString simulatorArgs() const;
|
|
||||||
QString simulatorPath() const;
|
|
||||||
QString simulatorSshPort() const;
|
|
||||||
QString simulatorGdbServerPort() const;
|
|
||||||
QString visibleSimulatorParameter() const;
|
|
||||||
|
|
||||||
const QString sshCmd() const;
|
const QString sshCmd() const;
|
||||||
const QString scpCmd() const;
|
const QString scpCmd() const;
|
||||||
const QString gdbCmd() const;
|
const QString gdbCmd() const;
|
||||||
const QString dumperLib() const;
|
const QString dumperLib() const;
|
||||||
|
|
||||||
bool isQemuRunning() const;
|
|
||||||
|
|
||||||
virtual QVariantMap toMap() const;
|
virtual QVariantMap toMap() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void deviceConfigurationsUpdated();
|
void deviceConfigurationsUpdated();
|
||||||
void deviceConfigurationChanged(ProjectExplorer::Target *target);
|
void deviceConfigurationChanged(ProjectExplorer::Target *target);
|
||||||
void targetInformationChanged() const;
|
void targetInformationChanged() const;
|
||||||
void cachedSimulatorInformationChanged() const;
|
|
||||||
void qemuProcessStatus(QemuStatus, const QString &error = QString());
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MaemoRunConfiguration(Qt4Target *parent, MaemoRunConfiguration *source);
|
MaemoRunConfiguration(Qt4Target *parent, MaemoRunConfiguration *source);
|
||||||
@@ -120,13 +108,8 @@ private slots:
|
|||||||
void proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
|
void proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro);
|
||||||
void updateDeviceConfigurations();
|
void updateDeviceConfigurations();
|
||||||
|
|
||||||
void startStopQemu();
|
|
||||||
void qemuProcessFinished();
|
|
||||||
void qemuProcessError(QProcess::ProcessError error);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void updateSimulatorInformation() const;
|
|
||||||
const QString cmd(const QString &cmdName) const;
|
const QString cmd(const QString &cmdName) const;
|
||||||
const MaemoToolChain *toolchain() const;
|
const MaemoToolChain *toolchain() const;
|
||||||
bool fileNeedsDeployment(const QString &path, const QDateTime &lastDeployed) const;
|
bool fileNeedsDeployment(const QString &path, const QDateTime &lastDeployed) const;
|
||||||
@@ -138,16 +121,6 @@ private:
|
|||||||
const QVariantMap &map);
|
const QVariantMap &map);
|
||||||
|
|
||||||
QString m_proFilePath;
|
QString m_proFilePath;
|
||||||
|
|
||||||
mutable QString m_simulator;
|
|
||||||
mutable QString m_simulatorArgs;
|
|
||||||
mutable QString m_simulatorPath;
|
|
||||||
mutable QString m_visibleSimulatorParameter;
|
|
||||||
mutable QString m_simulatorLibPath;
|
|
||||||
mutable QString m_simulatorSshPort;
|
|
||||||
mutable QString m_simulatorGdbServerPort;
|
|
||||||
mutable bool m_cachedSimulatorInformationValid;
|
|
||||||
|
|
||||||
mutable QString m_gdbPath;
|
mutable QString m_gdbPath;
|
||||||
|
|
||||||
MaemoDeviceConfig m_devConfig;
|
MaemoDeviceConfig m_devConfig;
|
||||||
@@ -156,8 +129,6 @@ private:
|
|||||||
// These map host names to deploy times.
|
// These map host names to deploy times.
|
||||||
QMap<QString, QDateTime> m_lastDeployed;
|
QMap<QString, QDateTime> m_lastDeployed;
|
||||||
QMap<QString, QDateTime> m_debuggingHelpersLastDeployed;
|
QMap<QString, QDateTime> m_debuggingHelpersLastDeployed;
|
||||||
|
|
||||||
QProcess *qemu;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -88,14 +88,7 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
|
|||||||
m_argsLineEdit = new QLineEdit(m_runConfiguration->arguments().join(" "));
|
m_argsLineEdit = new QLineEdit(m_runConfiguration->arguments().join(" "));
|
||||||
mainLayout->addRow(tr("Arguments:"), m_argsLineEdit);
|
mainLayout->addRow(tr("Arguments:"), m_argsLineEdit);
|
||||||
|
|
||||||
mainLayout->addItem(new QSpacerItem(10, 10));
|
|
||||||
m_simNameLabel = new QLabel(tr("Simulator:"));
|
|
||||||
m_simValueLabel = new QLabel(m_runConfiguration->visibleSimulatorParameter());
|
|
||||||
mainLayout->addRow(m_simNameLabel, m_simValueLabel);
|
|
||||||
resetDeviceConfigurations();
|
resetDeviceConfigurations();
|
||||||
|
|
||||||
connect(m_runConfiguration, SIGNAL(cachedSimulatorInformationChanged()),
|
|
||||||
this, SLOT(updateSimulatorPath()));
|
|
||||||
connect(m_runConfiguration, SIGNAL(deviceConfigurationsUpdated()),
|
connect(m_runConfiguration, SIGNAL(deviceConfigurationsUpdated()),
|
||||||
this, SLOT(resetDeviceConfigurations()));
|
this, SLOT(resetDeviceConfigurations()));
|
||||||
|
|
||||||
@@ -128,27 +121,13 @@ void MaemoRunConfigurationWidget::updateTargetInformation()
|
|||||||
m_executableLabel->setText(m_runConfiguration->executable());
|
m_executableLabel->setText(m_runConfiguration->executable());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRunConfigurationWidget::updateSimulatorPath()
|
|
||||||
{
|
|
||||||
m_simValueLabel->setText(m_runConfiguration->visibleSimulatorParameter());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfigurationWidget::deviceConfigurationChanged(const QString &name)
|
void MaemoRunConfigurationWidget::deviceConfigurationChanged(const QString &name)
|
||||||
{
|
{
|
||||||
const MaemoDeviceConfig &devConfig
|
const MaemoDeviceConfig &devConfig
|
||||||
= MaemoDeviceConfigurations::instance().find(name);
|
= MaemoDeviceConfigurations::instance().find(name);
|
||||||
setSimInfoVisible(devConfig);
|
|
||||||
m_runConfiguration->setDeviceConfig(devConfig);
|
m_runConfiguration->setDeviceConfig(devConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRunConfigurationWidget::setSimInfoVisible(const MaemoDeviceConfig &devConf)
|
|
||||||
{
|
|
||||||
const bool isSimulator
|
|
||||||
= devConf.isValid() && devConf.type == MaemoDeviceConfig::Simulator;
|
|
||||||
m_simNameLabel->setVisible(isSimulator);
|
|
||||||
m_simValueLabel->setVisible(isSimulator);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfigurationWidget::resetDeviceConfigurations()
|
void MaemoRunConfigurationWidget::resetDeviceConfigurations()
|
||||||
{
|
{
|
||||||
m_devConfBox->clear();
|
m_devConfBox->clear();
|
||||||
@@ -159,7 +138,6 @@ void MaemoRunConfigurationWidget::resetDeviceConfigurations()
|
|||||||
m_devConfBox->addItem(MaemoDeviceConfig().name);
|
m_devConfBox->addItem(MaemoDeviceConfig().name);
|
||||||
const MaemoDeviceConfig &devConf = m_runConfiguration->deviceConfig();
|
const MaemoDeviceConfig &devConf = m_runConfiguration->deviceConfig();
|
||||||
m_devConfBox->setCurrentIndex(m_devConfBox->findText(devConf.name));
|
m_devConfBox->setCurrentIndex(m_devConfBox->findText(devConf.name));
|
||||||
setSimInfoVisible(devConf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRunConfigurationWidget::showSettingsDialog(const QString &link)
|
void MaemoRunConfigurationWidget::showSettingsDialog(const QString &link)
|
||||||
|
|||||||
@@ -62,20 +62,14 @@ private slots:
|
|||||||
void deviceConfigurationChanged(const QString &name);
|
void deviceConfigurationChanged(const QString &name);
|
||||||
void resetDeviceConfigurations();
|
void resetDeviceConfigurations();
|
||||||
void showSettingsDialog(const QString &link);
|
void showSettingsDialog(const QString &link);
|
||||||
|
|
||||||
void updateSimulatorPath();
|
|
||||||
void updateTargetInformation();
|
void updateTargetInformation();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setSimInfoVisible(const MaemoDeviceConfig &devConf);
|
|
||||||
|
|
||||||
QLineEdit *m_configNameLineEdit;
|
QLineEdit *m_configNameLineEdit;
|
||||||
QLineEdit *m_argsLineEdit;
|
QLineEdit *m_argsLineEdit;
|
||||||
QLabel *m_executableLabel;
|
QLabel *m_executableLabel;
|
||||||
QLabel *m_debuggerLabel;
|
QLabel *m_debuggerLabel;
|
||||||
QComboBox *m_devConfBox;
|
QComboBox *m_devConfBox;
|
||||||
QLabel *m_simNameLabel;
|
|
||||||
QLabel *m_simValueLabel;
|
|
||||||
MaemoRunConfiguration *m_runConfiguration;
|
MaemoRunConfiguration *m_runConfiguration;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -491,8 +491,10 @@ QString MaemoDebugRunControl::gdbServerPort() const
|
|||||||
{
|
{
|
||||||
return m_devConfig.type == MaemoDeviceConfig::Physical
|
return m_devConfig.type == MaemoDeviceConfig::Physical
|
||||||
? QString::number(m_devConfig.gdbServerPort)
|
? QString::number(m_devConfig.gdbServerPort)
|
||||||
: m_runConfig->simulatorGdbServerPort();
|
: m_runConfig->runtimeGdbServerPort(); // During configuration we don't
|
||||||
|
// know which port to use, so we display something in the config dialog,
|
||||||
|
// but we will make sure we use the right port from the information file.
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -31,18 +31,16 @@
|
|||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "maemorunfactories.h"
|
#include "maemorunfactories.h"
|
||||||
|
|
||||||
#include "maemoconstants.h"
|
#include "maemoconstants.h"
|
||||||
#include "maemomanager.h"
|
|
||||||
#include "maemorunconfiguration.h"
|
#include "maemorunconfiguration.h"
|
||||||
#include "maemoruncontrol.h"
|
#include "maemoruncontrol.h"
|
||||||
#include "qt4projectmanagerconstants.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorer.h>
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/session.h>
|
|
||||||
#include <qt4projectmanager/qt4project.h>
|
#include <qt4projectmanager/qt4project.h>
|
||||||
|
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -63,14 +61,6 @@ QString targetFromId(const QString &id)
|
|||||||
MaemoRunConfigurationFactory::MaemoRunConfigurationFactory(QObject *parent)
|
MaemoRunConfigurationFactory::MaemoRunConfigurationFactory(QObject *parent)
|
||||||
: IRunConfigurationFactory(parent)
|
: IRunConfigurationFactory(parent)
|
||||||
{
|
{
|
||||||
ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance();
|
|
||||||
connect(explorer->session(), SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
||||||
this, SLOT(projectAdded(ProjectExplorer::Project*)));
|
|
||||||
connect(explorer->session(), SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
|
||||||
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
|
|
||||||
connect(explorer->session(),
|
|
||||||
SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), this,
|
|
||||||
SLOT(projectChanged(ProjectExplorer::Project*)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaemoRunConfigurationFactory::~MaemoRunConfigurationFactory()
|
MaemoRunConfigurationFactory::~MaemoRunConfigurationFactory()
|
||||||
@@ -151,106 +141,8 @@ RunConfiguration *MaemoRunConfigurationFactory::clone(Target *parent,
|
|||||||
return new MaemoRunConfiguration(static_cast<Qt4Target *>(parent), old);
|
return new MaemoRunConfiguration(static_cast<Qt4Target *>(parent), old);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoRunConfigurationFactory::projectAdded(ProjectExplorer::Project *project)
|
|
||||||
{
|
|
||||||
connect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)), this,
|
|
||||||
SLOT(targetAdded(ProjectExplorer::Target*)));
|
|
||||||
connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)), this,
|
|
||||||
SLOT(targetRemoved(ProjectExplorer::Target*)));
|
|
||||||
connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
||||||
this, SLOT(targetChanged(ProjectExplorer::Target*)));
|
|
||||||
|
|
||||||
foreach (Target *target, project->targets())
|
|
||||||
targetAdded(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfigurationFactory::projectRemoved(ProjectExplorer::Project *project)
|
|
||||||
{
|
|
||||||
disconnect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)), this,
|
|
||||||
SLOT(targetAdded(ProjectExplorer::Target*)));
|
|
||||||
disconnect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)), this,
|
|
||||||
SLOT(targetRemoved(ProjectExplorer::Target*)));
|
|
||||||
disconnect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
||||||
this, SLOT(targetChanged(ProjectExplorer::Target*)));
|
|
||||||
|
|
||||||
foreach (Target *target, project->targets())
|
|
||||||
targetRemoved(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfigurationFactory::projectChanged(ProjectExplorer::Project *project)
|
|
||||||
{
|
|
||||||
if (project)
|
|
||||||
updateMaemoEmulatorStarter(project->target(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfigurationFactory::targetAdded(ProjectExplorer::Target *target)
|
|
||||||
{
|
|
||||||
if (!target || target->id() != QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))
|
|
||||||
return;
|
|
||||||
|
|
||||||
MaemoManager::instance().addQemuSimulatorStarter(target->project());
|
|
||||||
foreach (RunConfiguration *runConfig, target->runConfigurations()) {
|
|
||||||
if (MaemoRunConfiguration *mrc = qobject_cast<MaemoRunConfiguration *> (runConfig)) {
|
|
||||||
connect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)),
|
|
||||||
this, SLOT(targetChanged(ProjectExplorer::Target*)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateMaemoEmulatorStarter(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfigurationFactory::targetRemoved(ProjectExplorer::Target *target)
|
|
||||||
{
|
|
||||||
if (!target || target->id() != QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))
|
|
||||||
return;
|
|
||||||
|
|
||||||
MaemoManager::instance().removeQemuSimulatorStarter(target->project());
|
|
||||||
foreach (RunConfiguration *runConfig, target->runConfigurations()) {
|
|
||||||
if (MaemoRunConfiguration *mrc = qobject_cast<MaemoRunConfiguration *> (runConfig)) {
|
|
||||||
disconnect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)),
|
|
||||||
this, SLOT(targetChanged(ProjectExplorer::Target*)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateMaemoEmulatorStarter(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfigurationFactory::targetChanged(ProjectExplorer::Target *target)
|
|
||||||
{
|
|
||||||
if (target)
|
|
||||||
updateMaemoEmulatorStarter(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoRunConfigurationFactory::updateMaemoEmulatorStarter(Target *target) const
|
|
||||||
{
|
|
||||||
bool enable = false;
|
|
||||||
bool isRunning = false;
|
|
||||||
|
|
||||||
if (target) {
|
|
||||||
MaemoRunConfiguration *mrc = 0;
|
|
||||||
if (target->project()->activeTarget() == target)
|
|
||||||
mrc = qobject_cast<MaemoRunConfiguration *> (target->activeRunConfiguration());
|
|
||||||
|
|
||||||
if (mrc) {
|
|
||||||
isRunning = mrc->isQemuRunning();
|
|
||||||
const MaemoDeviceConfig &config = mrc ? mrc->deviceConfig() : MaemoDeviceConfig();
|
|
||||||
|
|
||||||
ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance();
|
|
||||||
if (config.isValid()
|
|
||||||
&& !mrc->simulatorPath().isEmpty()
|
|
||||||
&& config.type == MaemoDeviceConfig::Simulator
|
|
||||||
&& explorer->startupProject() == target->project()) {
|
|
||||||
enable = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MaemoManager::instance().updateQemuIcon(isRunning);
|
|
||||||
MaemoManager::instance().setQemuSimulatorStarterEnabled(enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -- MaemoRunControlFactory
|
// #pragma mark -- MaemoRunControlFactory
|
||||||
|
|
||||||
|
|
||||||
MaemoRunControlFactory::MaemoRunControlFactory(QObject *parent)
|
MaemoRunControlFactory::MaemoRunControlFactory(QObject *parent)
|
||||||
: IRunControlFactory(parent)
|
: IRunControlFactory(parent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ using ProjectExplorer::Target;
|
|||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class MaemoRunConfiguration;
|
|
||||||
|
|
||||||
class MaemoRunConfigurationFactory : public IRunConfigurationFactory
|
class MaemoRunConfigurationFactory : public IRunConfigurationFactory
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -71,18 +69,6 @@ public:
|
|||||||
|
|
||||||
bool canClone(Target *parent, RunConfiguration *source) const;
|
bool canClone(Target *parent, RunConfiguration *source) const;
|
||||||
RunConfiguration *clone(Target *parent, RunConfiguration *source);
|
RunConfiguration *clone(Target *parent, RunConfiguration *source);
|
||||||
|
|
||||||
private slots:
|
|
||||||
void projectAdded(ProjectExplorer::Project *project);
|
|
||||||
void projectRemoved(ProjectExplorer::Project *project);
|
|
||||||
void projectChanged(ProjectExplorer::Project *project);
|
|
||||||
|
|
||||||
void targetAdded(ProjectExplorer::Target *target);
|
|
||||||
void targetRemoved(ProjectExplorer::Target *target);
|
|
||||||
void targetChanged(ProjectExplorer::Target *target);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void updateMaemoEmulatorStarter(ProjectExplorer::Target *target) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MaemoRunControlFactory : public IRunControlFactory
|
class MaemoRunControlFactory : public IRunControlFactory
|
||||||
|
|||||||
@@ -28,11 +28,11 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "maemotoolchain.h"
|
#include "maemotoolchain.h"
|
||||||
#include "qtversionmanager.h"
|
#include "maemoconstants.h"
|
||||||
|
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
#include <QtCore/QStringBuilder>
|
#include <QtCore/QStringBuilder>
|
||||||
#include <QtCore/QtDebug>
|
#include <QtCore/QTextStream>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Qt4ProjectManager::Internal;
|
using namespace Qt4ProjectManager::Internal;
|
||||||
@@ -41,7 +41,6 @@ MaemoToolChain::MaemoToolChain(const QString &targetRoot)
|
|||||||
: GccToolChain(targetRoot % QLatin1String("/bin/gcc"))
|
: GccToolChain(targetRoot % QLatin1String("/bin/gcc"))
|
||||||
, m_maddeInitialized(false)
|
, m_maddeInitialized(false)
|
||||||
, m_sysrootInitialized(false)
|
, m_sysrootInitialized(false)
|
||||||
, m_simulatorInitialized(false)
|
|
||||||
, m_targetRoot(targetRoot)
|
, m_targetRoot(targetRoot)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -77,7 +76,6 @@ bool MaemoToolChain::equals(ToolChain *other) const
|
|||||||
MaemoToolChain *toolChain = static_cast<MaemoToolChain*> (other);
|
MaemoToolChain *toolChain = static_cast<MaemoToolChain*> (other);
|
||||||
return other->type() == type()
|
return other->type() == type()
|
||||||
&& toolChain->sysrootRoot() == sysrootRoot()
|
&& toolChain->sysrootRoot() == sysrootRoot()
|
||||||
&& toolChain->simulatorRoot() == simulatorRoot()
|
|
||||||
&& toolChain->targetRoot() == targetRoot();
|
&& toolChain->targetRoot() == targetRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,13 +98,6 @@ QString MaemoToolChain::sysrootRoot() const
|
|||||||
return m_sysrootRoot;
|
return m_sysrootRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaemoToolChain::simulatorRoot() const
|
|
||||||
{
|
|
||||||
if (!m_simulatorInitialized)
|
|
||||||
setSimulatorRoot();
|
|
||||||
return m_simulatorRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoToolChain::setMaddeRoot() const
|
void MaemoToolChain::setMaddeRoot() const
|
||||||
{
|
{
|
||||||
QDir dir(targetRoot());
|
QDir dir(targetRoot());
|
||||||
@@ -116,41 +107,6 @@ void MaemoToolChain::setMaddeRoot() const
|
|||||||
m_maddeRoot = dir.absolutePath();
|
m_maddeRoot = dir.absolutePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoToolChain::setSimulatorRoot() const
|
|
||||||
{
|
|
||||||
QString target = QDir::cleanPath(targetRoot());
|
|
||||||
target = target.mid(target.lastIndexOf(QLatin1Char('/')) + 1);
|
|
||||||
|
|
||||||
QFile file(maddeRoot() + QLatin1String("/cache/madde.conf"));
|
|
||||||
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
||||||
QTextStream stream(&file);
|
|
||||||
while (!stream.atEnd()) {
|
|
||||||
QString line = stream.readLine().trimmed();
|
|
||||||
if (!line.startsWith(QLatin1String("target")))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const QStringList &list = line.split(QLatin1Char(' '));
|
|
||||||
if (list.count() <= 1 || list.at(1) != target)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
line = stream.readLine().trimmed();
|
|
||||||
while (!stream.atEnd() && line != QLatin1String("end")) {
|
|
||||||
if (line.startsWith(QLatin1String("runtime"))) {
|
|
||||||
const QStringList &list = line.split(QLatin1Char(' '));
|
|
||||||
if (list.count() > 1) {
|
|
||||||
m_simulatorRoot = maddeRoot()
|
|
||||||
+ QLatin1String("/runtimes/") + list.at(1).trimmed();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
line = stream.readLine().trimmed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_simulatorInitialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MaemoToolChain::setSysroot() const
|
void MaemoToolChain::setSysroot() const
|
||||||
{
|
{
|
||||||
QFile file(QDir::cleanPath(targetRoot()) + QLatin1String("/information"));
|
QFile file(QDir::cleanPath(targetRoot()) + QLatin1String("/information"));
|
||||||
|
|||||||
@@ -36,12 +36,6 @@ namespace Qt4ProjectManager {
|
|||||||
class QtVersion;
|
class QtVersion;
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
#define EXEC_SUFFIX ".exe"
|
|
||||||
#else
|
|
||||||
#define EXEC_SUFFIX ""
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class MaemoToolChain : public ProjectExplorer::GccToolChain
|
class MaemoToolChain : public ProjectExplorer::GccToolChain
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -55,14 +49,12 @@ public:
|
|||||||
QString maddeRoot() const;
|
QString maddeRoot() const;
|
||||||
QString targetRoot() const;
|
QString targetRoot() const;
|
||||||
QString sysrootRoot() const;
|
QString sysrootRoot() const;
|
||||||
QString simulatorRoot() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool equals(ToolChain *other) const;
|
bool equals(ToolChain *other) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setMaddeRoot() const;
|
void setMaddeRoot() const;
|
||||||
void setSimulatorRoot() const;
|
|
||||||
void setSysroot() const;
|
void setSysroot() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -72,9 +64,6 @@ private:
|
|||||||
mutable QString m_sysrootRoot;
|
mutable QString m_sysrootRoot;
|
||||||
mutable bool m_sysrootInitialized;
|
mutable bool m_sysrootInitialized;
|
||||||
|
|
||||||
mutable QString m_simulatorRoot;
|
|
||||||
mutable bool m_simulatorInitialized;
|
|
||||||
|
|
||||||
const QString m_targetRoot;
|
const QString m_targetRoot;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
615
src/plugins/qt4projectmanager/qt-maemo/qemuruntimemanager.cpp
Normal file
615
src/plugins/qt4projectmanager/qt-maemo/qemuruntimemanager.cpp
Normal file
@@ -0,0 +1,615 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at qt-sales@nokia.com.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "qemuruntimemanager.h"
|
||||||
|
|
||||||
|
#include "maemorunconfiguration.h"
|
||||||
|
#include "maemotoolchain.h"
|
||||||
|
#include "qtversionmanager.h"
|
||||||
|
#include "qt4project.h"
|
||||||
|
#include "qt4projectmanagerconstants.h"
|
||||||
|
|
||||||
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/actionmanager/command.h>
|
||||||
|
#include <coreplugin/coreconstants.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/modemanager.h>
|
||||||
|
|
||||||
|
#include <projectexplorer/projectexplorer.h>
|
||||||
|
#include <projectexplorer/session.h>
|
||||||
|
|
||||||
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QSet>
|
||||||
|
#include <QtCore/QTextStream>
|
||||||
|
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Qt4ProjectManager;
|
||||||
|
using namespace Qt4ProjectManager::Internal;
|
||||||
|
|
||||||
|
QemuRuntimeManager *QemuRuntimeManager::m_instance = 0;
|
||||||
|
|
||||||
|
const QSize iconSize = QSize(24, 20);
|
||||||
|
const QLatin1String binQmake("/bin/qmake" EXEC_SUFFIX);
|
||||||
|
|
||||||
|
QemuRuntimeManager::QemuRuntimeManager(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, m_qemuAction(0)
|
||||||
|
, m_qemuProcess(new QProcess(this))
|
||||||
|
, m_runningQtId(-1)
|
||||||
|
, m_needsSetup(true)
|
||||||
|
, m_userTerminated(false)
|
||||||
|
{
|
||||||
|
Q_ASSERT(!m_instance);
|
||||||
|
m_instance = this;
|
||||||
|
|
||||||
|
m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-run.png", iconSize);
|
||||||
|
m_qemuStarterIcon.addFile(":/qt-maemo/images/qemu-stop.png", iconSize,
|
||||||
|
QIcon::Normal, QIcon::On);
|
||||||
|
|
||||||
|
m_qemuAction = new QAction("Maemo Emulator", this);
|
||||||
|
m_qemuAction->setEnabled(false);
|
||||||
|
m_qemuAction->setVisible(false);
|
||||||
|
m_qemuAction->setIcon(m_qemuStarterIcon.pixmap(iconSize));
|
||||||
|
m_qemuAction->setToolTip(tr("Start Maemo Emulator"));
|
||||||
|
connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(startRuntime()));
|
||||||
|
|
||||||
|
Core::ICore *core = Core::ICore::instance();
|
||||||
|
Core::ActionManager *actionManager = core->actionManager();
|
||||||
|
Core::Command *qemuCommand = actionManager->registerAction(m_qemuAction,
|
||||||
|
"MaemoEmulator", QList<int>() << Core::Constants::C_GLOBAL_ID);
|
||||||
|
qemuCommand->setAttribute(Core::Command::CA_UpdateText);
|
||||||
|
qemuCommand->setAttribute(Core::Command::CA_UpdateIcon);
|
||||||
|
|
||||||
|
Core::ModeManager *modeManager = core->modeManager();
|
||||||
|
modeManager->addAction(qemuCommand, 1);
|
||||||
|
|
||||||
|
// listen to qt version changes to update the start button
|
||||||
|
connect(QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>)),
|
||||||
|
this, SLOT(qtVersionsChanged(QList<int>)));
|
||||||
|
|
||||||
|
// listen to project add, remove and startup changes to udate start button
|
||||||
|
SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
||||||
|
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)), this,
|
||||||
|
SLOT(projectAdded(ProjectExplorer::Project*)));
|
||||||
|
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)), this,
|
||||||
|
SLOT(projectRemoved(ProjectExplorer::Project*)));
|
||||||
|
connect(session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
||||||
|
this, SLOT(projectChanged(ProjectExplorer::Project*)));
|
||||||
|
|
||||||
|
connect(m_qemuProcess, SIGNAL(error(QProcess::ProcessError)), this,
|
||||||
|
SLOT(qemuProcessError(QProcess::ProcessError)));
|
||||||
|
connect(m_qemuProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this,
|
||||||
|
SLOT(qemuProcessFinished()));
|
||||||
|
connect(this, SIGNAL(qemuProcessStatus(QemuStatus, QString)),
|
||||||
|
this, SLOT(qemuStatusChanged(QemuStatus, QString)));
|
||||||
|
}
|
||||||
|
|
||||||
|
QemuRuntimeManager::~QemuRuntimeManager()
|
||||||
|
{
|
||||||
|
terminateRuntime();
|
||||||
|
}
|
||||||
|
|
||||||
|
QemuRuntimeManager &QemuRuntimeManager::instance()
|
||||||
|
{
|
||||||
|
Q_ASSERT(m_instance);
|
||||||
|
return *m_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QemuRuntimeManager::runtimeForQtVersion(int uniqueId, Runtime *rt) const
|
||||||
|
{
|
||||||
|
bool found = m_runtimes.contains(uniqueId);
|
||||||
|
if (found)
|
||||||
|
*rt = m_runtimes.value(uniqueId);
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::qtVersionsChanged(const QList<int> &uniqueIds)
|
||||||
|
{
|
||||||
|
if (m_needsSetup)
|
||||||
|
setupRuntimes();
|
||||||
|
|
||||||
|
QtVersionManager *manager = QtVersionManager::instance();
|
||||||
|
foreach (int uniqueId, uniqueIds) {
|
||||||
|
if (manager->isValidId(uniqueId)) {
|
||||||
|
const QString &qmake = manager->version(uniqueId)->qmakeCommand();
|
||||||
|
const QString &runtimeRoot = runtimeForQtVersion(qmake);
|
||||||
|
if (runtimeRoot.isEmpty() || !QFile::exists(runtimeRoot)) {
|
||||||
|
// no runtime available, or runtime needs to be installed
|
||||||
|
m_runtimes.remove(uniqueId);
|
||||||
|
} else {
|
||||||
|
// valid maemo qt version, also has a runtime installed
|
||||||
|
Runtime runtime(runtimeRoot);
|
||||||
|
fillRuntimeInformation(&runtime);
|
||||||
|
m_runtimes.insert(uniqueId, runtime);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// this qt version has been removed from the settings
|
||||||
|
m_runtimes.remove(uniqueId);
|
||||||
|
if (uniqueId == m_runningQtId) {
|
||||||
|
terminateRuntime();
|
||||||
|
emit qemuProcessStatus(QemuUserReason, tr("Qemu has been shut "
|
||||||
|
"down, because you removed the corresponding Qt version."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// make visible only if we have a runtime and a maemo target
|
||||||
|
m_qemuAction->setVisible(!m_runtimes.isEmpty() && sessionHasMaemoTarget());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::projectAdded(ProjectExplorer::Project *project)
|
||||||
|
{
|
||||||
|
// handle all target related changes, add, remove, etc...
|
||||||
|
connect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)), this,
|
||||||
|
SLOT(targetAdded(ProjectExplorer::Target*)));
|
||||||
|
connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)), this,
|
||||||
|
SLOT(targetRemoved(ProjectExplorer::Target*)));
|
||||||
|
connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
||||||
|
this, SLOT(targetChanged(ProjectExplorer::Target*)));
|
||||||
|
|
||||||
|
foreach (Target *target, project->targets())
|
||||||
|
targetAdded(target);
|
||||||
|
m_qemuAction->setVisible(!m_runtimes.isEmpty() && sessionHasMaemoTarget());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::projectRemoved(ProjectExplorer::Project *project)
|
||||||
|
{
|
||||||
|
disconnect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)), this,
|
||||||
|
SLOT(targetAdded(ProjectExplorer::Target*)));
|
||||||
|
disconnect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)), this,
|
||||||
|
SLOT(targetRemoved(ProjectExplorer::Target*)));
|
||||||
|
disconnect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
||||||
|
this, SLOT(targetChanged(ProjectExplorer::Target*)));
|
||||||
|
|
||||||
|
foreach (Target *target, project->targets())
|
||||||
|
targetRemoved(target);
|
||||||
|
m_qemuAction->setVisible(!m_runtimes.isEmpty() && sessionHasMaemoTarget());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::projectChanged(ProjectExplorer::Project *project)
|
||||||
|
{
|
||||||
|
if (project)
|
||||||
|
toogleStarterButton(project->activeTarget());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool targetIsMaemo(const QString &id)
|
||||||
|
{
|
||||||
|
return id == QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::targetAdded(ProjectExplorer::Target *target)
|
||||||
|
{
|
||||||
|
if (!target || !targetIsMaemo(target->id()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// handle all run configuration changes, add, remove, etc...
|
||||||
|
connect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
||||||
|
this, SLOT(runConfigurationAdded(ProjectExplorer::RunConfiguration*)));
|
||||||
|
connect(target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
||||||
|
this, SLOT(runConfigurationRemoved(ProjectExplorer::RunConfiguration*)));
|
||||||
|
connect(target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
|
||||||
|
this, SLOT(runConfigurationChanged(ProjectExplorer::RunConfiguration*)));
|
||||||
|
|
||||||
|
// handle all build configuration changes, add, remove, etc...
|
||||||
|
connect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
||||||
|
this, SLOT(buildConfigurationAdded(ProjectExplorer::BuildConfiguration*)));
|
||||||
|
connect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
||||||
|
this, SLOT(buildConfigurationRemoved(ProjectExplorer::BuildConfiguration*)));
|
||||||
|
connect(target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
||||||
|
this, SLOT(buildConfigurationChanged(ProjectExplorer::BuildConfiguration*)));
|
||||||
|
|
||||||
|
// handle the qt version changes the build configuration uses
|
||||||
|
connect(target, SIGNAL(environmentChanged()), this, SLOT(environmentChanged()));
|
||||||
|
|
||||||
|
foreach (RunConfiguration *runConfig, target->runConfigurations()) {
|
||||||
|
MaemoRunConfiguration *mrc = qobject_cast<MaemoRunConfiguration *> (runConfig);
|
||||||
|
if (mrc) { // handle device configuration change too
|
||||||
|
connect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)),
|
||||||
|
this, SLOT(deviceConfigurationChanged(ProjectExplorer::Target*)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_qemuAction->setVisible(!m_runtimes.isEmpty() && sessionHasMaemoTarget());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::targetRemoved(ProjectExplorer::Target *target)
|
||||||
|
{
|
||||||
|
if (!target || !targetIsMaemo(target->id()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
disconnect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
||||||
|
this, SLOT(runConfigurationAdded(ProjectExplorer::RunConfiguration*)));
|
||||||
|
disconnect(target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
||||||
|
this, SLOT(runConfigurationRemoved(ProjectExplorer::RunConfiguration*)));
|
||||||
|
disconnect(target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
|
||||||
|
this, SLOT(runConfigurationChanged(ProjectExplorer::RunConfiguration*)));
|
||||||
|
|
||||||
|
disconnect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
||||||
|
this, SLOT(buildConfigurationAdded(ProjectExplorer::BuildConfiguration*)));
|
||||||
|
disconnect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
||||||
|
this, SLOT(buildConfigurationRemoved(ProjectExplorer::BuildConfiguration*)));
|
||||||
|
disconnect(target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
||||||
|
this, SLOT(buildConfigurationChanged(ProjectExplorer::BuildConfiguration*)));
|
||||||
|
|
||||||
|
disconnect(target, SIGNAL(environmentChanged()), this, SLOT(environmentChanged()));
|
||||||
|
|
||||||
|
foreach (RunConfiguration *runConfig, target->runConfigurations()) {
|
||||||
|
MaemoRunConfiguration *mrc = qobject_cast<MaemoRunConfiguration *> (runConfig);
|
||||||
|
if (mrc) {
|
||||||
|
disconnect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)),
|
||||||
|
this, SLOT(deviceConfigurationChanged(ProjectExplorer::Target*)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_qemuAction->setVisible(!m_runtimes.isEmpty() && sessionHasMaemoTarget());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::targetChanged(ProjectExplorer::Target *target)
|
||||||
|
{
|
||||||
|
if (target)
|
||||||
|
toogleStarterButton(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::runConfigurationAdded(ProjectExplorer::RunConfiguration *rc)
|
||||||
|
{
|
||||||
|
if (!rc || !targetIsMaemo(rc->target()->id()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
MaemoRunConfiguration *mrc = qobject_cast<MaemoRunConfiguration *> (rc);
|
||||||
|
if (mrc) { // handle device configuration change too
|
||||||
|
connect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)),
|
||||||
|
this, SLOT(deviceConfigurationChanged(ProjectExplorer::Target*)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::runConfigurationRemoved(ProjectExplorer::RunConfiguration *rc)
|
||||||
|
{
|
||||||
|
if (!rc || rc->target()->id() != QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID))
|
||||||
|
return;
|
||||||
|
|
||||||
|
MaemoRunConfiguration *mrc = qobject_cast<MaemoRunConfiguration *> (rc);
|
||||||
|
if (mrc) {
|
||||||
|
disconnect(mrc, SIGNAL(deviceConfigurationChanged(ProjectExplorer::Target*)),
|
||||||
|
this, SLOT(deviceConfigurationChanged(ProjectExplorer::Target*)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::runConfigurationChanged(ProjectExplorer::RunConfiguration *rc)
|
||||||
|
{
|
||||||
|
if (rc)
|
||||||
|
m_qemuAction->setEnabled(targetUsesRuntimeConfig(rc->target()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::buildConfigurationAdded(ProjectExplorer::BuildConfiguration *bc)
|
||||||
|
{
|
||||||
|
if (!bc || !targetIsMaemo(bc->target()->id()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
connect(bc, SIGNAL(environmentChanged()), this, SLOT(environmentChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::buildConfigurationRemoved(ProjectExplorer::BuildConfiguration *bc)
|
||||||
|
{
|
||||||
|
if (!bc || !targetIsMaemo(bc->target()->id()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
disconnect(bc, SIGNAL(environmentChanged()), this, SLOT(environmentChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc)
|
||||||
|
{
|
||||||
|
if (bc)
|
||||||
|
toogleStarterButton(bc->target());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::environmentChanged()
|
||||||
|
{
|
||||||
|
// likely to happen when the qt version changes the build config is using
|
||||||
|
if (ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance()) {
|
||||||
|
if (Project *project = explorer->session()->startupProject())
|
||||||
|
toogleStarterButton(project->activeTarget());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::deviceConfigurationChanged(ProjectExplorer::Target *target)
|
||||||
|
{
|
||||||
|
m_qemuAction->setEnabled(targetUsesRuntimeConfig(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::startRuntime()
|
||||||
|
{
|
||||||
|
m_userTerminated = false;
|
||||||
|
Project *p = ProjectExplorerPlugin::instance()->session()->startupProject();
|
||||||
|
if (!p)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Qt4Target *qt4Target = qobject_cast<Qt4Target*> (p->activeTarget());
|
||||||
|
if (!qt4Target)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Qt4BuildConfiguration *bc = qt4Target->activeBuildConfiguration();
|
||||||
|
if (!bc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QtVersion *version = bc->qtVersion();
|
||||||
|
if (version && m_runtimes.contains(version->uniqueId())) {
|
||||||
|
m_runningQtId = version->uniqueId();
|
||||||
|
const QString root =
|
||||||
|
QDir::toNativeSeparators(maddeRoot(version->qmakeCommand())
|
||||||
|
+ QLatin1Char('/'));
|
||||||
|
const Runtime rt = m_runtimes.value(version->uniqueId());
|
||||||
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
const QLatin1Char colon(';');
|
||||||
|
const QLatin1String key("PATH");
|
||||||
|
env.insert(key, env.value(key) % colon % root % QLatin1String("bin"));
|
||||||
|
env.insert(key, env.value(key) % colon % root % QLatin1String("madlib"));
|
||||||
|
#elif defined(Q_OS_UNIX)
|
||||||
|
const QLatin1String key("LD_LIBRARY_PATH");
|
||||||
|
env.insert(key, env.value(key) % QLatin1Char(':') % rt.m_libPath);
|
||||||
|
#endif
|
||||||
|
m_qemuProcess->setProcessEnvironment(env);
|
||||||
|
m_qemuProcess->setWorkingDirectory(rt.m_root);
|
||||||
|
|
||||||
|
const QString app = root % QLatin1String("madlib/") % rt.m_bin
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
% QLatin1String(".exe")
|
||||||
|
#endif
|
||||||
|
; // keep
|
||||||
|
|
||||||
|
m_qemuProcess->start(app % QLatin1Char(' ') % rt.m_args,
|
||||||
|
QIODevice::ReadWrite);
|
||||||
|
emit qemuProcessStatus(QemuStarting);
|
||||||
|
connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(terminateRuntime()));
|
||||||
|
disconnect(m_qemuAction, SIGNAL(triggered()), this, SLOT(startRuntime()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::terminateRuntime()
|
||||||
|
{
|
||||||
|
m_userTerminated = true;
|
||||||
|
|
||||||
|
if (m_qemuProcess->state() != QProcess::NotRunning) {
|
||||||
|
m_qemuProcess->terminate();
|
||||||
|
m_qemuProcess->kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(m_qemuAction, SIGNAL(triggered()), this, SLOT(startRuntime()));
|
||||||
|
disconnect(m_qemuAction, SIGNAL(triggered()), this, SLOT(terminateRuntime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::qemuProcessFinished()
|
||||||
|
{
|
||||||
|
m_runningQtId = -1;
|
||||||
|
QemuStatus status = QemuFinished;
|
||||||
|
|
||||||
|
if (!m_userTerminated) {
|
||||||
|
status = m_qemuProcess->exitStatus() == QProcess::CrashExit
|
||||||
|
? QemuCrashed : QemuFinished;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_userTerminated = false;
|
||||||
|
emit qemuProcessStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::qemuProcessError(QProcess::ProcessError error)
|
||||||
|
{
|
||||||
|
if (error == QProcess::FailedToStart)
|
||||||
|
emit qemuProcessStatus(QemuFailedToStart, m_qemuProcess->errorString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::qemuStatusChanged(QemuStatus status, const QString &error)
|
||||||
|
{
|
||||||
|
QString message;
|
||||||
|
bool running = false;
|
||||||
|
|
||||||
|
switch (status) {
|
||||||
|
case QemuStarting:
|
||||||
|
running = true;
|
||||||
|
break;
|
||||||
|
case QemuFailedToStart:
|
||||||
|
message = tr("Qemu failed to start: %1").arg(error);
|
||||||
|
break;
|
||||||
|
case QemuCrashed:
|
||||||
|
message = tr("Qemu crashed");
|
||||||
|
break;
|
||||||
|
case QemuFinished:
|
||||||
|
break;
|
||||||
|
case QemuUserReason:
|
||||||
|
message = error;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT(!"Missing handling of Qemu status");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!message.isEmpty())
|
||||||
|
QMessageBox::warning(0, tr("Qemu error"), message);
|
||||||
|
updateStarterIcon(running);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- private
|
||||||
|
|
||||||
|
void QemuRuntimeManager::setupRuntimes()
|
||||||
|
{
|
||||||
|
m_needsSetup = false;
|
||||||
|
|
||||||
|
const QList<QtVersion*> &versions = QtVersionManager::instance()
|
||||||
|
->versionsForTargetId(Constants::MAEMO_DEVICE_TARGET_ID);
|
||||||
|
|
||||||
|
QList<int> uniqueIds;
|
||||||
|
foreach (QtVersion *version, versions)
|
||||||
|
uniqueIds.append(version->uniqueId());
|
||||||
|
qtVersionsChanged(uniqueIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::updateStarterIcon(bool running)
|
||||||
|
{
|
||||||
|
QIcon::State state;
|
||||||
|
QString toolTip;
|
||||||
|
if (running) {
|
||||||
|
state = QIcon::On;
|
||||||
|
toolTip = tr("Stop Maemo Emulator");
|
||||||
|
} else {
|
||||||
|
state = QIcon::Off;
|
||||||
|
toolTip = tr("Start Maemo Emulator");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_qemuAction->setToolTip(toolTip);
|
||||||
|
m_qemuAction->setIcon(m_qemuStarterIcon.pixmap(iconSize, QIcon::Normal,
|
||||||
|
state));
|
||||||
|
}
|
||||||
|
|
||||||
|
void QemuRuntimeManager::toogleStarterButton(Target *target)
|
||||||
|
{
|
||||||
|
if (m_needsSetup)
|
||||||
|
setupRuntimes();
|
||||||
|
|
||||||
|
int uniqueId = -1;
|
||||||
|
if (target) {
|
||||||
|
if (Qt4Target *qt4Target = qobject_cast<Qt4Target*>(target)) {
|
||||||
|
if (Qt4BuildConfiguration *bc = qt4Target->activeBuildConfiguration()) {
|
||||||
|
if (QtVersion *version = bc->qtVersion())
|
||||||
|
uniqueId = version->uniqueId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isRunning = m_qemuProcess->state() != QProcess::NotRunning;
|
||||||
|
if (m_runningQtId == uniqueId)
|
||||||
|
isRunning = false;
|
||||||
|
|
||||||
|
m_qemuAction->setEnabled(m_runtimes.contains(uniqueId)
|
||||||
|
&& targetUsesRuntimeConfig(target) && !isRunning);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QemuRuntimeManager::sessionHasMaemoTarget() const
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance();
|
||||||
|
const QList<Project*> &projects = explorer->session()->projects();
|
||||||
|
foreach (const Project *p, projects)
|
||||||
|
result |= p->target(QLatin1String(Constants::MAEMO_DEVICE_TARGET_ID)) != 0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QemuRuntimeManager::targetUsesRuntimeConfig(Target *target)
|
||||||
|
{
|
||||||
|
if (!target)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
MaemoRunConfiguration *mrc =
|
||||||
|
qobject_cast<MaemoRunConfiguration *> (target->activeRunConfiguration());
|
||||||
|
if (mrc) {
|
||||||
|
const MaemoDeviceConfig &config = mrc->deviceConfig();
|
||||||
|
if (config.isValid() && config.type == MaemoDeviceConfig::Simulator)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QemuRuntimeManager::maddeRoot(const QString &qmake) const
|
||||||
|
{
|
||||||
|
QDir dir(QDir::cleanPath(qmake).remove(binQmake));
|
||||||
|
dir.cdUp(); dir.cdUp();
|
||||||
|
return dir.absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QemuRuntimeManager::targetRoot(const QString &qmake) const
|
||||||
|
{
|
||||||
|
const QString target = QDir::cleanPath(qmake).remove(binQmake);
|
||||||
|
return target.mid(target.lastIndexOf(QLatin1Char('/')) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QemuRuntimeManager::fillRuntimeInformation(Runtime *runtime) const
|
||||||
|
{
|
||||||
|
const QStringList files = QDir(runtime->m_root).entryList(QDir::Files
|
||||||
|
| QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
||||||
|
|
||||||
|
const QLatin1String infoFile("information");
|
||||||
|
// we need at least the information file and a second one, most likely
|
||||||
|
// the image file qemu is going to load
|
||||||
|
if (files.contains(infoFile) && files.count() > 1) {
|
||||||
|
QFile file(runtime->m_root + QLatin1Char('/') + infoFile);
|
||||||
|
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
QMap<QString, QString> map;
|
||||||
|
QTextStream stream(&file);
|
||||||
|
while (!stream.atEnd()) {
|
||||||
|
const QString &line = stream.readLine().trimmed();
|
||||||
|
const int index = line.indexOf(QLatin1Char('='));
|
||||||
|
map.insert(line.mid(0, index).remove(QLatin1Char('\'')),
|
||||||
|
line.mid(index + 1).remove(QLatin1Char('\'')));
|
||||||
|
}
|
||||||
|
|
||||||
|
runtime->m_bin = map.value(QLatin1String("qemu"));
|
||||||
|
runtime->m_args = map.value(QLatin1String("qemu_args"));
|
||||||
|
const QString &libPathSpec = map.value(QLatin1String("libpath"));
|
||||||
|
runtime->m_libPath =
|
||||||
|
libPathSpec.mid(libPathSpec.indexOf(QLatin1Char('=')) + 1);
|
||||||
|
runtime->m_sshPort = map.value(QLatin1String("sshport"));
|
||||||
|
runtime->m_gdbServerPort = map.value(QLatin1String("redirport2"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QemuRuntimeManager::runtimeForQtVersion(const QString &qmakeCommand) const
|
||||||
|
{
|
||||||
|
const QString &target = targetRoot(qmakeCommand);
|
||||||
|
const QString &madRoot = maddeRoot(qmakeCommand);
|
||||||
|
|
||||||
|
QFile file(madRoot + QLatin1String("/cache/madde.conf"));
|
||||||
|
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
QTextStream stream(&file);
|
||||||
|
while (!stream.atEnd()) {
|
||||||
|
QString line = stream.readLine().trimmed();
|
||||||
|
if (!line.startsWith(QLatin1String("target")))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const QStringList &list = line.split(QLatin1Char(' '));
|
||||||
|
if (list.count() <= 1 || list.at(1) != target)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
line = stream.readLine().trimmed();
|
||||||
|
while (!stream.atEnd() && line != QLatin1String("end")) {
|
||||||
|
if (line.startsWith(QLatin1String("runtime"))) {
|
||||||
|
const QStringList &list = line.split(QLatin1Char(' '));
|
||||||
|
if (list.count() > 1) {
|
||||||
|
return madRoot
|
||||||
|
+ QLatin1String("/runtimes/") + list.at(1).trimmed();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
line = stream.readLine().trimmed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
142
src/plugins/qt4projectmanager/qt-maemo/qemuruntimemanager.h
Normal file
142
src/plugins/qt4projectmanager/qt-maemo/qemuruntimemanager.h
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, 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.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at qt-sales@nokia.com.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef QEMURUNTIMEMANAGER_H
|
||||||
|
#define QEMURUNTIMEMANAGER_H
|
||||||
|
|
||||||
|
#include "maemoconstants.h"
|
||||||
|
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QProcess>
|
||||||
|
|
||||||
|
#include <QtGui/QIcon>
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QAction);
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QStringList);
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class BuildConfiguration;
|
||||||
|
class Project;
|
||||||
|
class RunConfiguration;
|
||||||
|
class Target;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Qt4ProjectManager {
|
||||||
|
class QtVersion;
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
struct Runtime
|
||||||
|
{
|
||||||
|
Runtime() {}
|
||||||
|
Runtime(const QString &root)
|
||||||
|
: m_root(root) {}
|
||||||
|
|
||||||
|
QString m_bin;
|
||||||
|
QString m_root;
|
||||||
|
QString m_args;
|
||||||
|
QString m_libPath;
|
||||||
|
QString m_sshPort;
|
||||||
|
QString m_gdbServerPort;
|
||||||
|
};
|
||||||
|
|
||||||
|
class QemuRuntimeManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
QemuRuntimeManager(QObject *parent = 0);
|
||||||
|
~QemuRuntimeManager();
|
||||||
|
|
||||||
|
static QemuRuntimeManager& instance();
|
||||||
|
|
||||||
|
bool runtimeForQtVersion(int uniqueId, Runtime *rt) const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void qemuProcessStatus(QemuStatus, const QString &error = QString());
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void qtVersionsChanged(const QList<int> &uniqueIds);
|
||||||
|
|
||||||
|
void projectAdded(ProjectExplorer::Project *project);
|
||||||
|
void projectRemoved(ProjectExplorer::Project *project);
|
||||||
|
void projectChanged(ProjectExplorer::Project *project);
|
||||||
|
|
||||||
|
void targetAdded(ProjectExplorer::Target *target);
|
||||||
|
void targetRemoved(ProjectExplorer::Target *target);
|
||||||
|
void targetChanged(ProjectExplorer::Target *target);
|
||||||
|
|
||||||
|
void runConfigurationAdded(ProjectExplorer::RunConfiguration *rc);
|
||||||
|
void runConfigurationRemoved(ProjectExplorer::RunConfiguration *rc);
|
||||||
|
void runConfigurationChanged(ProjectExplorer::RunConfiguration *rc);
|
||||||
|
|
||||||
|
void buildConfigurationAdded(ProjectExplorer::BuildConfiguration *bc);
|
||||||
|
void buildConfigurationRemoved(ProjectExplorer::BuildConfiguration *bc);
|
||||||
|
void buildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc);
|
||||||
|
|
||||||
|
void environmentChanged(); // needed to check for qt version
|
||||||
|
void deviceConfigurationChanged(ProjectExplorer::Target *target);
|
||||||
|
|
||||||
|
void startRuntime();
|
||||||
|
void terminateRuntime();
|
||||||
|
|
||||||
|
void qemuProcessFinished();
|
||||||
|
void qemuProcessError(QProcess::ProcessError error);
|
||||||
|
void qemuStatusChanged(QemuStatus status, const QString &error);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupRuntimes();
|
||||||
|
bool sessionHasMaemoTarget() const;
|
||||||
|
|
||||||
|
void updateStarterIcon(bool running);
|
||||||
|
void toogleStarterButton(ProjectExplorer::Target *target);
|
||||||
|
bool targetUsesRuntimeConfig(ProjectExplorer::Target *target);
|
||||||
|
|
||||||
|
QString maddeRoot(const QString &qmake) const;
|
||||||
|
QString targetRoot(const QString &qmake) const;
|
||||||
|
|
||||||
|
bool fillRuntimeInformation(Runtime *runtime) const;
|
||||||
|
QString runtimeForQtVersion(const QString &qmakeCommand) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QAction *m_qemuAction;
|
||||||
|
QProcess *m_qemuProcess;
|
||||||
|
|
||||||
|
int m_runningQtId;
|
||||||
|
bool m_needsSetup;
|
||||||
|
bool m_userTerminated;
|
||||||
|
QIcon m_qemuStarterIcon;
|
||||||
|
QMap<int, Runtime> m_runtimes;
|
||||||
|
static QemuRuntimeManager *m_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Qt4ProjectManager
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
|
#endif // QEMURUNTIMEMANAGER_H
|
||||||
@@ -15,7 +15,8 @@ HEADERS += \
|
|||||||
$$PWD/maemopackagecreationstep.h \
|
$$PWD/maemopackagecreationstep.h \
|
||||||
$$PWD/maemopackagecreationfactory.h \
|
$$PWD/maemopackagecreationfactory.h \
|
||||||
$$PWD/maemopackagecreationwidget.h \
|
$$PWD/maemopackagecreationwidget.h \
|
||||||
$$PWD/maemopackagecontents.h
|
$$PWD/maemopackagecontents.h \
|
||||||
|
$$PWD/qemuruntimemanager.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/maemoconfigtestdialog.cpp \
|
$$PWD/maemoconfigtestdialog.cpp \
|
||||||
@@ -33,7 +34,8 @@ SOURCES += \
|
|||||||
$$PWD/maemopackagecreationstep.cpp \
|
$$PWD/maemopackagecreationstep.cpp \
|
||||||
$$PWD/maemopackagecreationfactory.cpp \
|
$$PWD/maemopackagecreationfactory.cpp \
|
||||||
$$PWD/maemopackagecreationwidget.cpp \
|
$$PWD/maemopackagecreationwidget.cpp \
|
||||||
$$PWD/maemopackagecontents.cpp
|
$$PWD/maemopackagecontents.cpp \
|
||||||
|
$$PWD/qemuruntimemanager.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
$$PWD/maemoconfigtestdialog.ui \
|
$$PWD/maemoconfigtestdialog.ui \
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
|
|||||||
addAutoReleasedObject(new LinguistExternalEditor);
|
addAutoReleasedObject(new LinguistExternalEditor);
|
||||||
|
|
||||||
addAutoReleasedObject(new S60Manager);
|
addAutoReleasedObject(new S60Manager);
|
||||||
addAutoReleasedObject(new MaemoManager);
|
addAutoReleasedObject(m_maemoManager = new MaemoManager);
|
||||||
|
|
||||||
new ProFileCacheManager(this);
|
new ProFileCacheManager(this);
|
||||||
|
|
||||||
@@ -228,6 +228,7 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
|
|||||||
void Qt4ProjectManagerPlugin::extensionsInitialized()
|
void Qt4ProjectManagerPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
m_qt4ProjectManager->init();
|
m_qt4ProjectManager->init();
|
||||||
|
m_maemoManager->init(); // depends on the Qt4ProjectManager
|
||||||
}
|
}
|
||||||
|
|
||||||
void Qt4ProjectManagerPlugin::updateContextMenu(Project *project,
|
void Qt4ProjectManagerPlugin::updateContextMenu(Project *project,
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ class QMakeStepFactory;
|
|||||||
class MakeStepFactory;
|
class MakeStepFactory;
|
||||||
class EmbeddedPropertiesPage;
|
class EmbeddedPropertiesPage;
|
||||||
class GettingStartedWelcomePage;
|
class GettingStartedWelcomePage;
|
||||||
|
class MaemoManager;
|
||||||
|
|
||||||
class Qt4ProjectManagerPlugin : public ExtensionSystem::IPlugin
|
class Qt4ProjectManagerPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
@@ -85,6 +86,7 @@ private:
|
|||||||
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
|
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
|
||||||
ProFileEditorFactory *m_proFileEditorFactory;
|
ProFileEditorFactory *m_proFileEditorFactory;
|
||||||
Qt4Manager *m_qt4ProjectManager;
|
Qt4Manager *m_qt4ProjectManager;
|
||||||
|
MaemoManager *m_maemoManager;
|
||||||
|
|
||||||
int m_projectContext;
|
int m_projectContext;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user