Commit 5cd63974 authored by Friedemann Kleint's avatar Friedemann Kleint

S60: Split run configurations

creating a debug run configuration. Import the debugger
into Qt4ProjectManager.
parent 12536eeb
include(debugger_dependencies.pri)
LIBS *= -l$$qtLibraryTarget(Debugger)
......@@ -33,12 +33,21 @@
#include "launcher.h"
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/toolchain.h>
#include <QtCore/QProcess>
#include <QtGui/QWidget>
#include <QtGui/QLabel>
#include <QtGui/QLineEdit>
#include <QtGui/QComboBox>
#include <QtCore/QProcess>
QT_BEGIN_NAMESPACE
class QLabel;
class QLineEdit;
class QComboBox;
QT_END_NAMESPACE
namespace Debugger {
class DebuggerStartParameters;
}
namespace Qt4ProjectManager {
namespace Internal {
......@@ -75,6 +84,8 @@ public:
QString packageFileName() const;
QString executableFileName() const;
ProjectExplorer::ToolChain::ToolChainType toolChainType() const;
signals:
void targetInformationChanged();
......@@ -131,26 +142,23 @@ public:
QSharedPointer<ProjectExplorer::RunConfiguration> create(ProjectExplorer::Project *project, const QString &type);
};
class S60DeviceRunControlFactory : public ProjectExplorer::IRunControlFactory
{
Q_OBJECT
public:
explicit S60DeviceRunControlFactory(QObject *parent = 0);
bool canRun(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration, const QString &mode) const;
ProjectExplorer::RunControl* create(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration, const QString &mode);
QString displayName() const;
QWidget *configurationWidget(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration);
};
/* S60DeviceRunControlBase: Builds and signs package and starts launcher
* to deploy. Subclasses can configure the launcher to run or start a debugger. */
class S60DeviceRunControl : public ProjectExplorer::RunControl
class S60DeviceRunControlBase : public ProjectExplorer::RunControl
{
Q_OBJECT
public:
explicit S60DeviceRunControl(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration);
~S60DeviceRunControl() {}
void start();
void stop();
bool isRunning() const;
explicit S60DeviceRunControlBase(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration);
~S60DeviceRunControlBase() {}
virtual void start();
virtual void stop();
virtual bool isRunning() const;
protected:
virtual void initLauncher(const QString &executable, trk::Launcher *) = 0;
virtual void handleLauncherFinished() = 0;
void processFailed(const QString &program, QProcess::ProcessError errorCode);
private slots:
void readStandardError();
......@@ -163,15 +171,9 @@ private slots:
void printCreateFileFailed(const QString &filename, const QString &errorMessage);
void printCopyProgress(int progress);
void printInstallingNotice();
void printStartingNotice();
void printRunNotice(uint pid);
void printRunFailNotice(const QString &errorMessage);
void printApplicationOutput(const QString &output);
void runFinished();
void launcherFinished();
private:
void processFailed(const QString &program, QProcess::ProcessError errorCode);
QString m_serialPortName;
QString m_serialPortFriendlyName;
QString m_targetName;
......@@ -191,6 +193,46 @@ private:
trk::Launcher *m_launcher;
};
// Configure launcher to run the application
class S60DeviceRunControl : public S60DeviceRunControlBase
{
Q_OBJECT
public:
explicit S60DeviceRunControl(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration);
protected:
virtual void initLauncher(const QString &executable, trk::Launcher *);
virtual void handleLauncherFinished();
private slots:
void printStartingNotice();
void printRunNotice(uint pid);
void printRunFailNotice(const QString &errorMessage);
void printApplicationOutput(const QString &output);
private:
};
class S60DeviceDebugRunControl : public S60DeviceRunControlBase
{
Q_DISABLE_COPY(S60DeviceDebugRunControl)
Q_OBJECT
public:
explicit S60DeviceDebugRunControl(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration);
virtual ~S60DeviceDebugRunControl();
virtual void stop();
protected:
virtual void initLauncher(const QString &executable, trk::Launcher *);
virtual void handleLauncherFinished();
private slots:
void debuggingFinished();
private:
QSharedPointer<Debugger::DebuggerStartParameters> m_startParams;
};
} // namespace Internal
} // namespace Qt4ProjectManager
......
......@@ -254,36 +254,6 @@ QSharedPointer<RunConfiguration> S60EmulatorRunConfigurationFactory::create(Proj
return rc;
}
// ======== S60EmulatorRunControlFactory
S60EmulatorRunControlFactory::S60EmulatorRunControlFactory(QObject *parent)
: IRunControlFactory(parent)
{
}
bool S60EmulatorRunControlFactory::canRun(const QSharedPointer<RunConfiguration> &runConfiguration, const QString &mode) const
{
return (mode == ProjectExplorer::Constants::RUNMODE)
&& (!runConfiguration.objectCast<S60EmulatorRunConfiguration>().isNull());
}
RunControl* S60EmulatorRunControlFactory::create(const QSharedPointer<RunConfiguration> &runConfiguration, const QString &mode)
{
QSharedPointer<S60EmulatorRunConfiguration> rc = runConfiguration.objectCast<S60EmulatorRunConfiguration>();
QTC_ASSERT(!rc.isNull() && mode == ProjectExplorer::Constants::RUNMODE, return 0);
return new S60EmulatorRunControl(rc);
}
QString S60EmulatorRunControlFactory::displayName() const
{
return tr("Run in Emulator");
}
QWidget *S60EmulatorRunControlFactory::configurationWidget(const QSharedPointer<ProjectExplorer::RunConfiguration> & /* runConfiguration */)
{
return 0;
}
// ======== S60EmulatorRunControl
S60EmulatorRunControl::S60EmulatorRunControl(const QSharedPointer<RunConfiguration> &runConfiguration)
......
......@@ -99,17 +99,6 @@ public:
QSharedPointer<ProjectExplorer::RunConfiguration> create(ProjectExplorer::Project *project, const QString &type);
};
class S60EmulatorRunControlFactory : public ProjectExplorer::IRunControlFactory
{
Q_OBJECT
public:
explicit S60EmulatorRunControlFactory(QObject *parent = 0);
bool canRun(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration, const QString &mode) const;
ProjectExplorer::RunControl* create(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration, const QString &mode);
QString displayName() const;
QWidget *configurationWidget(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration);
};
class S60EmulatorRunControl : public ProjectExplorer::RunControl
{
Q_OBJECT
......
......@@ -39,10 +39,14 @@
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <debugger/debuggermanager.h>
#include <utils/qtcassert.h>
#include <QtGui/QMainWindow>
using namespace Qt4ProjectManager::Internal;
namespace Qt4ProjectManager {
namespace Internal {
S60Manager *S60Manager::m_instance = 0;
......@@ -50,30 +54,72 @@ namespace {
static const char *S60_AUTODETECTION_SOURCE = "QTS60";
}
// ======== Parametrizable Factory for RunControls, depending on the configuration
// class and mode.
template <class RunControl, class RunConfiguration>
class RunControlFactory : public ProjectExplorer::IRunControlFactory
{
public:
explicit RunControlFactory(const QString &mode,
const QString &name,
QObject *parent = 0) :
IRunControlFactory(parent), m_mode(mode), m_name(name) {}
bool canRun(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration, const QString &mode) const {
return (mode == m_mode)
&& (!runConfiguration.objectCast<RunConfiguration>().isNull());
}
ProjectExplorer::RunControl* create(const QSharedPointer<ProjectExplorer::RunConfiguration> &runConfiguration, const QString &mode) {
const QSharedPointer<RunConfiguration> rc = runConfiguration.objectCast<RunConfiguration>();
QTC_ASSERT(!rc.isNull() && mode == m_mode, return 0);
return new RunControl(rc);
}
QString displayName() const {
return m_name;
}
QWidget *configurationWidget(const QSharedPointer<ProjectExplorer::RunConfiguration> & /*runConfiguration */) {
return 0;
}
private:
const QString m_mode;
const QString m_name;
};
// ======== S60Manager
S60Manager *S60Manager::instance() { return m_instance; }
S60Manager::S60Manager(QObject *parent)
: QObject(parent),
m_devices(new S60Devices(this)),
m_devicesPreferencePane(new S60DevicesPreferencePane(m_devices, this)),
m_s60EmulatorRunConfigurationFactory(new S60EmulatorRunConfigurationFactory(this)),
m_s60EmulatorRunConfigurationRunner(new S60EmulatorRunControlFactory(this)),
m_s60DeviceRunConfigurationFactory(new S60DeviceRunConfigurationFactory(this)),
m_s60DeviceRunConfigurationRunner(new S60DeviceRunControlFactory(this)),
m_serialDeviceLister(new SerialDeviceLister(this))
{
m_instance = this;
m_devices->detectQtForDevices();
ExtensionSystem::PluginManager::instance()
->addObject(m_devicesPreferencePane);
ExtensionSystem::PluginManager::instance()
->addObject(m_s60EmulatorRunConfigurationFactory);
ExtensionSystem::PluginManager::instance()
->addObject(m_s60EmulatorRunConfigurationRunner);
ExtensionSystem::PluginManager::instance()
->addObject(m_s60DeviceRunConfigurationFactory);
ExtensionSystem::PluginManager::instance()
->addObject(m_s60DeviceRunConfigurationRunner);
addAutoReleasedObject(new S60DevicesPreferencePane(m_devices, this));
m_devices->detectQtForDevices(); // Order!
addAutoReleasedObject(new S60EmulatorRunConfigurationFactory(this));
addAutoReleasedObject(new RunControlFactory<S60EmulatorRunControl,
S60EmulatorRunConfiguration>
(QLatin1String(ProjectExplorer::Constants::RUNMODE),
tr("Run in Emulator"), parent));
addAutoReleasedObject(new S60DeviceRunConfigurationFactory(this));
addAutoReleasedObject(new RunControlFactory<S60DeviceRunControl,
S60DeviceRunConfiguration>
(QLatin1String(ProjectExplorer::Constants::RUNMODE),
tr("Run on Device"), parent));
if (Debugger::DebuggerManager::instance())
addAutoReleasedObject(new RunControlFactory<S60DeviceDebugRunControl,
S60DeviceRunConfiguration>
(QLatin1String(ProjectExplorer::Constants::DEBUGMODE),
tr("Debug on Device"), parent));
updateQtVersions();
connect(m_devices, SIGNAL(qtVersionsChanged()),
this, SLOT(updateQtVersions()));
......@@ -83,23 +129,22 @@ S60Manager::S60Manager(QObject *parent)
S60Manager::~S60Manager()
{
ExtensionSystem::PluginManager::instance()
->removeObject(m_s60DeviceRunConfigurationRunner);
ExtensionSystem::PluginManager::instance()
->removeObject(m_s60DeviceRunConfigurationFactory);
ExtensionSystem::PluginManager::instance()
->removeObject(m_s60EmulatorRunConfigurationRunner);
ExtensionSystem::PluginManager::instance()
->removeObject(m_s60EmulatorRunConfigurationFactory);
ExtensionSystem::PluginManager::instance()
->removeObject(m_devicesPreferencePane);
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
for (int i = m_pluginObjects.size() - 1; i >= 0; i--)
pm->removeObject(m_pluginObjects.at(i));
}
void S60Manager::addAutoReleasedObject(QObject *o)
{
ExtensionSystem::PluginManager::instance()->addObject(o);
m_pluginObjects.push_back(o);
}
QString S60Manager::deviceIdFromDetectionSource(const QString &autoDetectionSource) const
{
if (autoDetectionSource.startsWith(S60_AUTODETECTION_SOURCE))
return autoDetectionSource.mid(QString(S60_AUTODETECTION_SOURCE).length()+1);
return "";
return QString();
}
void S60Manager::updateQtVersions()
......@@ -185,3 +230,6 @@ S60Devices::Device S60Manager::deviceForQtVersion(const Qt4ProjectManager::QtVer
}
return device;
}
}
}
......@@ -42,12 +42,6 @@
namespace Qt4ProjectManager {
namespace Internal {
class S60DevicesPreferencePane;
class S60EmulatorRunConfigurationFactory;
class S60EmulatorRunControlFactory;
class S60DeviceRunConfigurationFactory;
class S60DeviceRunControlFactory;
class S60Manager : public QObject
{
Q_OBJECT
......@@ -71,13 +65,12 @@ private slots:
void updateQtVersions();
private:
void addAutoReleasedObject(QObject *p);
static S60Manager *m_instance;
S60Devices *m_devices;
S60DevicesPreferencePane *m_devicesPreferencePane;
S60EmulatorRunConfigurationFactory *m_s60EmulatorRunConfigurationFactory;
S60EmulatorRunControlFactory *m_s60EmulatorRunConfigurationRunner;
S60DeviceRunConfigurationFactory *m_s60DeviceRunConfigurationFactory;
S60DeviceRunControlFactory *m_s60DeviceRunConfigurationRunner;
QObjectList m_pluginObjects;
SerialDeviceLister *m_serialDeviceLister;
};
......
......@@ -3,3 +3,4 @@ include(../../plugins/cpptools/cpptools.pri)
include(../../plugins/cppeditor/cppeditor.pri)
include(../../plugins/help/help.pri)
include(../../plugins/designer/designer.pri)
include(../../plugins/debugger/debugger.pri)
......@@ -497,7 +497,11 @@ void Launcher::installRemotePackageSilently(const QString &fileName)
void Launcher::handleInstallPackageFinished(const TrkResult &)
{
startInferiorIfNeeded();
if (d->m_fileName.isEmpty()) {
emit finished();
} else {
startInferiorIfNeeded();
}
}
void Launcher::startInferiorIfNeeded()
......
......@@ -5,15 +5,19 @@
#include <QtCore/QStringList>
static const char *usageC =
"\nUsage: %1 <trk_port_name> [-v] [-i remote_sis_file | -I local_sis_file remote_sis_file] <remote_executable_name>\n"
"\nUsage: %1 <trk_port_name> [-v] [-i remote_sis_file | -I local_sis_file remote_sis_file] [<remote_executable_name>]\n"
"\nOptions:\n -v verbose\n"
" -f turn serial message frame off\n\n"
"\nPing:\n"
"%1 COM5\n"
"\nRemote launch:\n"
"%1 COM5 C:\\sys\\bin\\test.exe\n"
"\nInstallation:\n"
"%1 -i COM5 C:\\Data\\test_gcce_udeb.sisx\n"
"\nInstallation and remote launch:\n"
"%1 -i COM5 C:\\Data\\test_gcce_udeb.sisx C:\\sys\\bin\\test.exe\n"
"\nCopy from local file, installation:\n"
"%1 -I COM5 C:\\Projects\\test\\test_gcce_udeb.sisx C:\\Data\\test_gcce_udeb.sisx\n"
"\nCopy from local file, installation and remote launch:\n"
"%1 -I COM5 C:\\Projects\\test\\test_gcce_udeb.sisx C:\\Data\\test_gcce_udeb.sisx C:\\sys\\bin\\test.exe\n";
......@@ -68,17 +72,19 @@ static bool parseArguments(const QStringList &arguments, trk::Launcher &launcher
launcher.setFileName(arguments.at(a + 1));
return true;
}
if (remainingArgsCount == 3 && install && !customInstall) {
if ((remainingArgsCount == 3 || remainingArgsCount == 2) && install && !customInstall) {
launcher.setTrkServerName(arguments.at(a)); // ping
launcher.setInstallFileName(arguments.at(a + 1));
launcher.setFileName(arguments.at(a + 2));
if (remainingArgsCount == 3)
launcher.setFileName(arguments.at(a + 2));
return true;
}
if (remainingArgsCount == 4 && !install && customInstall) {
if ((remainingArgsCount == 4 || remainingArgsCount == 3) && !install && customInstall) {
launcher.setTrkServerName(arguments.at(a)); // ping
launcher.setCopyFileName(arguments.at(a + 1), arguments.at(a + 2));
launcher.setInstallFileName(arguments.at(a + 2));
launcher.setFileName(arguments.at(a + 3));
if (remainingArgsCount == 4)
launcher.setFileName(arguments.at(a + 3));
return true;
}
return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment