2009-05-26 15:31:29 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2009-05-26 15:31:29 +02:00
|
|
|
**
|
2009-10-12 18:28:48 +02:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2009-05-26 15:31:29 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** No Commercial Usage
|
2009-05-26 15:31:29 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
2009-05-26 15:31:29 +02:00
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
2009-05-26 15:31:29 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "s60manager.h"
|
2010-03-18 10:59:06 +01:00
|
|
|
#include "qtversionmanager.h"
|
2009-05-26 15:31:29 +02:00
|
|
|
|
|
|
|
|
#include "s60devicespreferencepane.h"
|
2009-05-28 18:36:52 +02:00
|
|
|
#include "winscwtoolchain.h"
|
2009-06-05 16:10:26 +02:00
|
|
|
#include "gccetoolchain.h"
|
2009-08-05 17:06:52 +02:00
|
|
|
#include "rvcttoolchain.h"
|
2009-06-16 15:11:47 +02:00
|
|
|
#include "s60emulatorrunconfiguration.h"
|
2009-08-17 11:47:17 +02:00
|
|
|
#include "s60devicerunconfiguration.h"
|
2010-02-25 16:51:27 +01:00
|
|
|
#include "s60createpackagestep.h"
|
2010-07-15 13:58:18 +02:00
|
|
|
#include "s60deploystep.h"
|
2011-01-18 16:45:42 +01:00
|
|
|
#include "s60runcontrolfactory.h"
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
#include "qt4symbiantargetfactory.h"
|
2009-05-26 15:31:29 +02:00
|
|
|
|
2010-11-03 10:03:48 +01:00
|
|
|
#include <symbianutils/symbiandevicemanager.h>
|
|
|
|
|
|
2009-07-31 16:49:26 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2009-05-26 15:31:29 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2009-09-28 17:17:11 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2011-01-10 10:14:23 +01:00
|
|
|
#include <debugger/debuggerconstants.h>
|
2009-09-28 17:17:11 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2009-05-26 15:31:29 +02:00
|
|
|
|
2009-07-31 16:49:26 +02:00
|
|
|
#include <QtGui/QMainWindow>
|
|
|
|
|
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
|
2009-10-29 12:19:56 +01:00
|
|
|
namespace {
|
2010-02-18 10:22:50 +01:00
|
|
|
const char S60_AUTODETECTION_SOURCE[] = "QTS60";
|
2009-10-29 12:19:56 +01:00
|
|
|
}
|
|
|
|
|
|
2009-09-28 17:17:11 +02:00
|
|
|
namespace Qt4ProjectManager {
|
|
|
|
|
namespace Internal {
|
2009-05-26 15:31:29 +02:00
|
|
|
|
2009-05-28 18:36:52 +02:00
|
|
|
S60Manager *S60Manager::m_instance = 0;
|
|
|
|
|
|
2009-09-28 17:17:11 +02:00
|
|
|
// ======== 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) {}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode) const {
|
2009-09-28 17:17:11 +02:00
|
|
|
return (mode == m_mode)
|
2009-10-08 18:37:18 +02:00
|
|
|
&& (qobject_cast<RunConfiguration *>(runConfiguration) != 0);
|
2009-09-28 17:17:11 +02:00
|
|
|
}
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
ProjectExplorer::RunControl* create(ProjectExplorer::RunConfiguration *runConfiguration, const QString &mode) {
|
|
|
|
|
RunConfiguration *rc = qobject_cast<RunConfiguration *>(runConfiguration);
|
|
|
|
|
QTC_ASSERT(rc && mode == m_mode, return 0);
|
2010-04-30 13:19:31 +02:00
|
|
|
return new RunControl(rc, mode);
|
2009-09-28 17:17:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString displayName() const {
|
|
|
|
|
return m_name;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
QWidget *createConfigurationWidget(ProjectExplorer::RunConfiguration * /*runConfiguration */) {
|
2009-09-28 17:17:11 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const QString m_mode;
|
|
|
|
|
const QString m_name;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ======== S60Manager
|
|
|
|
|
|
2009-05-28 18:36:52 +02:00
|
|
|
S60Manager *S60Manager::instance() { return m_instance; }
|
|
|
|
|
|
2009-05-26 15:31:29 +02:00
|
|
|
S60Manager::S60Manager(QObject *parent)
|
2010-04-14 15:53:35 +02:00
|
|
|
: QObject(parent), m_devices(S60Devices::createS60Devices(this))
|
2009-05-26 15:31:29 +02:00
|
|
|
{
|
2009-05-28 18:36:52 +02:00
|
|
|
m_instance = this;
|
2010-04-14 15:53:35 +02:00
|
|
|
|
2009-12-17 18:01:41 +01:00
|
|
|
#ifdef QTCREATOR_WITH_S60
|
2009-09-28 17:17:11 +02:00
|
|
|
addAutoReleasedObject(new S60DevicesPreferencePane(m_devices, this));
|
2009-12-17 18:01:41 +01:00
|
|
|
#endif
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
addAutoReleasedObject(new S60EmulatorRunConfigurationFactory);
|
2009-09-28 17:17:11 +02:00
|
|
|
addAutoReleasedObject(new RunControlFactory<S60EmulatorRunControl,
|
|
|
|
|
S60EmulatorRunConfiguration>
|
|
|
|
|
(QLatin1String(ProjectExplorer::Constants::RUNMODE),
|
|
|
|
|
tr("Run in Emulator"), parent));
|
2010-01-19 13:41:02 +01:00
|
|
|
addAutoReleasedObject(new S60DeviceRunConfigurationFactory);
|
2011-01-18 16:45:42 +01:00
|
|
|
addAutoReleasedObject(new S60RunControlFactory(QLatin1String(ProjectExplorer::Constants::RUNMODE),
|
2009-09-28 17:17:11 +02:00
|
|
|
tr("Run on Device"), parent));
|
2010-02-25 16:51:27 +01:00
|
|
|
addAutoReleasedObject(new S60CreatePackageStepFactory);
|
2010-07-15 13:58:18 +02:00
|
|
|
addAutoReleasedObject(new S60DeployStepFactory);
|
2009-09-28 17:17:11 +02:00
|
|
|
|
2010-11-10 11:39:01 +01:00
|
|
|
addAutoReleasedObject(new RunControlFactory<S60DeviceDebugRunControl,
|
|
|
|
|
S60DeviceRunConfiguration>
|
2010-11-12 20:18:29 +01:00
|
|
|
(QLatin1String(Debugger::Constants::DEBUGMODE),
|
2010-11-10 11:39:01 +01:00
|
|
|
tr("Debug on Device"), parent));
|
2010-12-10 19:02:19 +01:00
|
|
|
addAutoReleasedObject(new Qt4SymbianTargetFactory);
|
|
|
|
|
|
2009-05-28 13:22:23 +02:00
|
|
|
updateQtVersions();
|
2009-05-28 16:48:02 +02:00
|
|
|
connect(m_devices, SIGNAL(qtVersionsChanged()),
|
|
|
|
|
this, SLOT(updateQtVersions()));
|
2009-07-31 16:49:26 +02:00
|
|
|
connect(Core::ICore::instance()->mainWindow(), SIGNAL(deviceChange()),
|
2010-02-05 17:34:02 +01:00
|
|
|
SymbianUtils::SymbianDeviceManager::instance(), SLOT(update()));
|
2009-05-26 15:31:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
S60Manager::~S60Manager()
|
|
|
|
|
{
|
2009-09-28 17:17:11 +02:00
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
2009-11-04 17:11:35 +01:00
|
|
|
for (int i = m_pluginObjects.size() - 1; i >= 0; i--) {
|
2009-09-28 17:17:11 +02:00
|
|
|
pm->removeObject(m_pluginObjects.at(i));
|
2009-11-04 17:11:35 +01:00
|
|
|
delete m_pluginObjects.at(i);
|
|
|
|
|
}
|
2009-09-28 17:17:11 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-26 12:17:14 +01:00
|
|
|
bool S60Manager::hasRvct2Compiler()
|
2010-02-17 17:38:48 +01:00
|
|
|
{
|
2010-11-26 12:17:14 +01:00
|
|
|
return RVCT2ToolChain::configuredRvctVersions().contains(qMakePair(2, 2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool S60Manager::hasRvct4Compiler()
|
|
|
|
|
{
|
|
|
|
|
return RVCT2ToolChain::configuredRvctVersions().contains(qMakePair(2, 2));
|
2010-02-17 17:38:48 +01:00
|
|
|
}
|
|
|
|
|
|
2009-09-28 17:17:11 +02:00
|
|
|
void S60Manager::addAutoReleasedObject(QObject *o)
|
|
|
|
|
{
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->addObject(o);
|
|
|
|
|
m_pluginObjects.push_back(o);
|
2009-05-26 15:31:29 +02:00
|
|
|
}
|
2009-05-28 13:22:23 +02:00
|
|
|
|
2009-06-16 15:11:47 +02:00
|
|
|
QString S60Manager::deviceIdFromDetectionSource(const QString &autoDetectionSource) const
|
|
|
|
|
{
|
|
|
|
|
if (autoDetectionSource.startsWith(S60_AUTODETECTION_SOURCE))
|
|
|
|
|
return autoDetectionSource.mid(QString(S60_AUTODETECTION_SOURCE).length()+1);
|
2009-09-28 17:17:11 +02:00
|
|
|
return QString();
|
2009-06-16 15:11:47 +02:00
|
|
|
}
|
|
|
|
|
|
2009-11-13 15:47:35 +01:00
|
|
|
static inline QString qmakeFromQtDir(const QString &qtDir)
|
|
|
|
|
{
|
|
|
|
|
QString qmake = qtDir + QLatin1String("/bin/qmake");
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
qmake += QLatin1String(".exe");
|
|
|
|
|
#endif
|
|
|
|
|
return qmake;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-28 13:22:23 +02:00
|
|
|
void S60Manager::updateQtVersions()
|
|
|
|
|
{
|
|
|
|
|
// This assumes that the QtVersionManager has already read
|
|
|
|
|
// the Qt versions from the settings
|
|
|
|
|
QtVersionManager *versionManager = QtVersionManager::instance();
|
|
|
|
|
QList<QtVersion *> versions = versionManager->versions();
|
|
|
|
|
QList<QtVersion *> handledVersions;
|
|
|
|
|
QList<QtVersion *> versionsToAdd;
|
|
|
|
|
foreach (const S60Devices::Device &device, m_devices->devices()) {
|
|
|
|
|
if (device.qt.isEmpty()) // no Qt version found for this sdk
|
|
|
|
|
continue;
|
|
|
|
|
QtVersion *deviceVersion = 0;
|
|
|
|
|
// look if we have a respective Qt version already
|
|
|
|
|
foreach (QtVersion *version, versions) {
|
|
|
|
|
if (version->isAutodetected()
|
2009-06-16 15:11:47 +02:00
|
|
|
&& deviceIdFromDetectionSource(version->autodetectionSource()) == device.id) {
|
2009-05-28 13:22:23 +02:00
|
|
|
deviceVersion = version;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (deviceVersion) {
|
2009-11-13 15:47:35 +01:00
|
|
|
deviceVersion->setQMakeCommand(qmakeFromQtDir(device.qt));
|
2010-01-07 18:17:24 +01:00
|
|
|
deviceVersion->setDisplayName(QString("%1 (Qt %2)").arg(device.id, deviceVersion->qtVersionString()));
|
2009-05-28 13:22:23 +02:00
|
|
|
handledVersions.append(deviceVersion);
|
|
|
|
|
} else {
|
2009-11-13 15:47:35 +01:00
|
|
|
deviceVersion = new QtVersion(QString("%1 (Qt %2)").arg(device.id), qmakeFromQtDir(device.qt),
|
2009-05-28 13:22:23 +02:00
|
|
|
true, QString("%1.%2").arg(S60_AUTODETECTION_SOURCE, device.id));
|
2010-01-07 18:17:24 +01:00
|
|
|
deviceVersion->setDisplayName(deviceVersion->displayName().arg(deviceVersion->qtVersionString()));
|
2009-05-28 13:22:23 +02:00
|
|
|
versionsToAdd.append(deviceVersion);
|
|
|
|
|
}
|
2009-10-27 17:59:53 +01:00
|
|
|
deviceVersion->setS60SDKDirectory(device.epocRoot);
|
2009-05-28 13:22:23 +02:00
|
|
|
}
|
|
|
|
|
// remove old autodetected versions
|
|
|
|
|
foreach (QtVersion *version, versions) {
|
|
|
|
|
if (version->isAutodetected()
|
|
|
|
|
&& version->autodetectionSource().startsWith(S60_AUTODETECTION_SOURCE)
|
|
|
|
|
&& !handledVersions.contains(version)) {
|
|
|
|
|
versionManager->removeVersion(version);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// add new versions
|
|
|
|
|
foreach (QtVersion *version, versionsToAdd) {
|
|
|
|
|
versionManager->addVersion(version);
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-05-28 18:36:52 +02:00
|
|
|
|
|
|
|
|
ProjectExplorer::ToolChain *S60Manager::createWINSCWToolChain(const Qt4ProjectManager::QtVersion *version) const
|
|
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(version);
|
2009-08-04 10:11:11 +02:00
|
|
|
return new WINSCWToolChain(deviceForQtVersion(version), version->mwcDirectory());
|
2009-05-28 18:36:52 +02:00
|
|
|
}
|
2009-06-05 16:10:26 +02:00
|
|
|
|
|
|
|
|
ProjectExplorer::ToolChain *S60Manager::createGCCEToolChain(const Qt4ProjectManager::QtVersion *version) const
|
|
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(version);
|
2010-11-01 14:14:17 +01:00
|
|
|
return GCCEToolChain::create(deviceForQtVersion(version), version->gcceDirectory(), ProjectExplorer::ToolChain_GCCE);
|
2009-11-13 15:47:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::ToolChain *S60Manager::createGCCE_GnuPocToolChain(const Qt4ProjectManager::QtVersion *version) const
|
|
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(version);
|
2010-11-01 14:14:17 +01:00
|
|
|
return GCCEToolChain::create(deviceForQtVersion(version), version->gcceDirectory(), ProjectExplorer::ToolChain_GCCE_GNUPOC);
|
2009-08-04 10:11:11 +02:00
|
|
|
}
|
|
|
|
|
|
2009-10-27 17:59:53 +01:00
|
|
|
ProjectExplorer::ToolChain *S60Manager::createRVCTToolChain(
|
|
|
|
|
const Qt4ProjectManager::QtVersion *version,
|
2010-11-01 14:14:17 +01:00
|
|
|
ProjectExplorer::ToolChainType type) const
|
2009-08-05 17:06:52 +02:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(version);
|
2010-11-26 12:17:14 +01:00
|
|
|
if (type == ProjectExplorer::ToolChain_RVCT2_ARMV5
|
|
|
|
|
|| type == ProjectExplorer::ToolChain_RVCT2_ARMV6
|
|
|
|
|
|| type == ProjectExplorer::ToolChain_RVCT_ARMV5_GNUPOC)
|
|
|
|
|
return new RVCT2ToolChain(deviceForQtVersion(version), type);
|
|
|
|
|
if (type == ProjectExplorer::ToolChain_RVCT4_ARMV5
|
|
|
|
|
|| type == ProjectExplorer::ToolChain_RVCT4_ARMV6)
|
|
|
|
|
return new RVCT4ToolChain(deviceForQtVersion(version), type);
|
|
|
|
|
return 0;
|
2009-08-05 17:06:52 +02:00
|
|
|
}
|
|
|
|
|
|
2009-08-04 10:11:11 +02:00
|
|
|
S60Devices::Device S60Manager::deviceForQtVersion(const Qt4ProjectManager::QtVersion *version) const
|
|
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(version);
|
2009-08-04 10:11:11 +02:00
|
|
|
S60Devices::Device device;
|
|
|
|
|
QString deviceId;
|
|
|
|
|
if (version->isAutodetected())
|
|
|
|
|
deviceId = deviceIdFromDetectionSource(version->autodetectionSource());
|
|
|
|
|
if (deviceId.isEmpty()) { // it's not an s60 autodetected version
|
2009-10-27 17:59:53 +01:00
|
|
|
// try to find a device entry belonging to the root given in Qt prefs
|
|
|
|
|
QString sdkRoot = version->s60SDKDirectory();
|
2010-02-12 11:56:42 +01:00
|
|
|
if (sdkRoot.isEmpty()) { // no sdk explicitly set in the preferences
|
|
|
|
|
// check if EPOCROOT is set and use that
|
|
|
|
|
QString epocRootEnv = QProcessEnvironment::systemEnvironment()
|
|
|
|
|
.value(QLatin1String("EPOCROOT"));
|
|
|
|
|
if (!epocRootEnv.isEmpty())
|
|
|
|
|
sdkRoot = QDir::fromNativeSeparators(epocRootEnv);
|
|
|
|
|
}
|
|
|
|
|
if (sdkRoot.isEmpty()) { // no sdk set via preference or EPOCROOT
|
|
|
|
|
// try default device
|
|
|
|
|
device = m_devices->defaultDevice();
|
|
|
|
|
} else {
|
|
|
|
|
device = m_devices->deviceForEpocRoot(sdkRoot);
|
|
|
|
|
}
|
2009-10-27 17:59:53 +01:00
|
|
|
if (device.epocRoot.isEmpty()) { // no device found
|
|
|
|
|
// check if we can construct a dummy one
|
|
|
|
|
if (QFile::exists(QString::fromLatin1("%1/epoc32").arg(sdkRoot))) {
|
|
|
|
|
device.epocRoot = sdkRoot;
|
|
|
|
|
device.toolsRoot = device.epocRoot;
|
|
|
|
|
device.isDefault = false;
|
|
|
|
|
device.name = QString::fromLatin1("Manual");
|
|
|
|
|
device.id = QString::fromLatin1("Manual");
|
|
|
|
|
}
|
2009-08-04 10:11:11 +02:00
|
|
|
}
|
2010-02-12 11:56:42 +01:00
|
|
|
// override any Qt version that might be still autodetected
|
|
|
|
|
device.qt = QFileInfo(QFileInfo(version->qmakeCommand()).path()).path();
|
2009-08-04 10:11:11 +02:00
|
|
|
} else {
|
|
|
|
|
device = m_devices->deviceForId(deviceId);
|
|
|
|
|
}
|
|
|
|
|
return device;
|
2009-06-05 16:10:26 +02:00
|
|
|
}
|
2009-09-28 17:17:11 +02:00
|
|
|
|
2009-10-29 12:19:56 +01:00
|
|
|
} // namespace internal
|
|
|
|
|
} // namespace qt4projectmanager
|