2009-10-16 17:33:12 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2009-10-16 17:33:12 +02:00
|
|
|
**
|
|
|
|
|
** 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 http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
2010-05-20 15:47:42 +02:00
|
|
|
|
2009-10-16 17:33:12 +02:00
|
|
|
#include "maemorunconfiguration.h"
|
|
|
|
|
|
2010-04-15 12:47:02 +02:00
|
|
|
#include "maemopackagecreationstep.h"
|
2010-01-07 11:21:11 +01:00
|
|
|
#include "maemorunconfigurationwidget.h"
|
2009-10-16 17:33:12 +02:00
|
|
|
#include "maemotoolchain.h"
|
2010-05-20 15:47:42 +02:00
|
|
|
#include "qemuruntimemanager.h"
|
2009-10-16 17:33:12 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/messagemanager.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2010-03-01 17:03:42 +01:00
|
|
|
#include <projectexplorer/session.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
|
2010-04-15 12:47:02 +02:00
|
|
|
#include <qt4projectmanager/qt4buildconfiguration.h>
|
2010-02-23 16:17:04 +01:00
|
|
|
#include <qt4projectmanager/qt4project.h>
|
2010-03-18 10:59:06 +01:00
|
|
|
|
2009-10-16 17:33:12 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2010-02-03 11:00:45 +01:00
|
|
|
#include <QtCore/QStringBuilder>
|
2009-10-16 17:33:12 +02:00
|
|
|
|
2010-01-07 11:21:11 +01:00
|
|
|
namespace Qt4ProjectManager {
|
2010-02-23 16:17:04 +01:00
|
|
|
namespace Internal {
|
2009-10-16 17:33:12 +02:00
|
|
|
|
2010-01-07 11:21:11 +01:00
|
|
|
using namespace ProjectExplorer;
|
2009-10-16 17:33:12 +02:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent,
|
2009-10-16 17:33:12 +02:00
|
|
|
const QString &proFilePath)
|
2010-02-08 15:50:06 +01:00
|
|
|
: RunConfiguration(parent, QLatin1String(MAEMO_RC_ID))
|
2009-10-16 17:33:12 +02:00
|
|
|
, m_proFilePath(proFilePath)
|
2010-01-19 13:41:02 +01:00
|
|
|
{
|
2010-02-03 15:20:12 +01:00
|
|
|
init();
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent,
|
2010-02-22 15:56:08 +01:00
|
|
|
MaemoRunConfiguration *source)
|
2010-02-08 15:50:06 +01:00
|
|
|
: RunConfiguration(parent, source)
|
2010-01-19 13:41:02 +01:00
|
|
|
, m_proFilePath(source->m_proFilePath)
|
|
|
|
|
, m_gdbPath(source->m_gdbPath)
|
|
|
|
|
, m_devConfig(source->m_devConfig)
|
|
|
|
|
, m_arguments(source->m_arguments)
|
|
|
|
|
, m_lastDeployed(source->m_lastDeployed)
|
|
|
|
|
{
|
2010-02-03 15:20:12 +01:00
|
|
|
init();
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-03 15:20:12 +01:00
|
|
|
void MaemoRunConfiguration::init()
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
2010-04-19 15:02:40 +02:00
|
|
|
setDisplayName(tr("New Maemo Run Configuration"));
|
2009-10-16 17:33:12 +02:00
|
|
|
|
2010-04-01 15:45:44 +02:00
|
|
|
updateDeviceConfigurations();
|
2010-02-22 15:56:08 +01:00
|
|
|
connect(&MaemoDeviceConfigurations::instance(), SIGNAL(updated()), this,
|
|
|
|
|
SLOT(updateDeviceConfigurations()));
|
2009-12-01 14:04:25 +01:00
|
|
|
|
2010-02-22 15:56:08 +01:00
|
|
|
connect(qt4Target()->qt4Project(),
|
|
|
|
|
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
|
|
|
|
|
this, SLOT(proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode*)));
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaemoRunConfiguration::~MaemoRunConfiguration()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Qt4Target *MaemoRunConfiguration::qt4Target() const
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
return static_cast<Qt4Target *>(target());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt4BuildConfiguration *MaemoRunConfiguration::activeQt4BuildConfiguration() const
|
|
|
|
|
{
|
|
|
|
|
return static_cast<Qt4BuildConfiguration *>(activeBuildConfiguration());
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
2009-12-15 17:48:11 +01:00
|
|
|
bool MaemoRunConfiguration::isEnabled(ProjectExplorer::BuildConfiguration *config) const
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
2009-12-15 17:48:11 +01:00
|
|
|
Qt4BuildConfiguration *qt4bc = qobject_cast<Qt4BuildConfiguration*>(config);
|
2009-11-25 18:50:20 +01:00
|
|
|
QTC_ASSERT(qt4bc, return false);
|
|
|
|
|
ToolChain::ToolChainType type = qt4bc->toolChainType();
|
2009-10-16 17:33:12 +02:00
|
|
|
return type == ToolChain::GCC_MAEMO;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
QWidget *MaemoRunConfiguration::createConfigurationWidget()
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
|
|
|
|
return new MaemoRunConfigurationWidget(this);
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-03 18:37:27 +01:00
|
|
|
void MaemoRunConfiguration::proFileUpdate(Qt4ProjectManager::Internal::Qt4ProFileNode *pro)
|
|
|
|
|
{
|
|
|
|
|
if (m_proFilePath == pro->path())
|
2010-03-10 16:55:37 +01:00
|
|
|
emit targetInformationChanged();
|
2009-12-03 18:37:27 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
QVariantMap MaemoRunConfiguration::toMap() const
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
2010-01-19 13:41:02 +01:00
|
|
|
QVariantMap map(RunConfiguration::toMap());
|
|
|
|
|
map.insert(DeviceIdKey, m_devConfig.internalId);
|
|
|
|
|
map.insert(ArgumentsKey, m_arguments);
|
2010-06-21 11:25:06 +02:00
|
|
|
addDeployTimesToMap(map);
|
2010-03-25 13:19:27 +01:00
|
|
|
const QDir dir = QDir(target()->project()->projectDirectory());
|
2010-01-19 13:41:02 +01:00
|
|
|
map.insert(ProFileKey, dir.relativeFilePath(m_proFilePath));
|
2009-10-16 17:33:12 +02:00
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
return map;
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-21 11:25:06 +02:00
|
|
|
void MaemoRunConfiguration::addDeployTimesToMap(QVariantMap &map) const
|
2010-03-05 16:06:47 +01:00
|
|
|
{
|
2010-06-21 11:25:06 +02:00
|
|
|
QVariantList hostList;
|
|
|
|
|
QVariantList fileList;
|
|
|
|
|
QVariantList timeList;
|
|
|
|
|
typedef QMap<DeployablePerHost, QDateTime>::ConstIterator DepIt;
|
|
|
|
|
for (DepIt it = m_lastDeployed.begin(); it != m_lastDeployed.end(); ++it) {
|
|
|
|
|
hostList << it.key().first;
|
|
|
|
|
fileList << it.key().second;
|
|
|
|
|
timeList << it.value();
|
|
|
|
|
}
|
|
|
|
|
map.insert(LastDeployedHostsKey, hostList);
|
|
|
|
|
map.insert(LastDeployedFilesKey, fileList);
|
|
|
|
|
map.insert(LastDeployedTimesKey, timeList);
|
2010-03-05 16:06:47 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
bool MaemoRunConfiguration::fromMap(const QVariantMap &map)
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
2010-02-02 18:30:58 +01:00
|
|
|
if (!RunConfiguration::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
|
2009-12-01 14:04:25 +01:00
|
|
|
setDeviceConfig(MaemoDeviceConfigurations::instance().
|
2010-01-19 13:41:02 +01:00
|
|
|
find(map.value(DeviceIdKey, 0).toInt()));
|
|
|
|
|
m_arguments = map.value(ArgumentsKey).toStringList();
|
2010-06-21 11:25:06 +02:00
|
|
|
getDeployTimesFromMap(map);
|
2010-03-25 13:19:27 +01:00
|
|
|
const QDir dir = QDir(target()->project()->projectDirectory());
|
2010-01-19 13:41:02 +01:00
|
|
|
m_proFilePath = dir.filePath(map.value(ProFileKey).toString());
|
2009-10-29 17:26:14 +01:00
|
|
|
|
2010-02-02 18:30:58 +01:00
|
|
|
return true;
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-21 11:25:06 +02:00
|
|
|
void MaemoRunConfiguration::getDeployTimesFromMap(const QVariantMap &map)
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
2010-06-21 11:25:06 +02:00
|
|
|
const QVariantList &hostList = map.value(LastDeployedHostsKey).toList();
|
|
|
|
|
const QVariantList &fileList = map.value(LastDeployedFilesKey).toList();
|
|
|
|
|
const QVariantList &timeList = map.value(LastDeployedTimesKey).toList();
|
|
|
|
|
const int elemCount
|
|
|
|
|
= qMin(qMin(hostList.size(), fileList.size()), timeList.size());
|
|
|
|
|
for (int i = 0; i < elemCount; ++i) {
|
|
|
|
|
m_lastDeployed.insert(DeployablePerHost(hostList.at(i).toString(),
|
|
|
|
|
fileList.at(i).toString()), timeList.at(i).toDateTime());
|
2010-03-05 16:06:47 +01:00
|
|
|
}
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-21 11:25:06 +02:00
|
|
|
bool MaemoRunConfiguration::currentlyNeedsDeployment(const QString &host,
|
|
|
|
|
const QString &file) const
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
2010-06-21 11:25:06 +02:00
|
|
|
const QDateTime &lastDeployed
|
|
|
|
|
= m_lastDeployed.value(DeployablePerHost(host, file));
|
|
|
|
|
return !lastDeployed.isValid()
|
|
|
|
|
|| QFileInfo(file).lastModified() > lastDeployed;
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-21 11:25:06 +02:00
|
|
|
void MaemoRunConfiguration::setDeployed(const QString &host,
|
|
|
|
|
const QString &file)
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
2010-06-21 11:25:06 +02:00
|
|
|
m_lastDeployed.insert(DeployablePerHost(host, file),
|
|
|
|
|
QDateTime::currentDateTime());
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
void MaemoRunConfiguration::setDeviceConfig(const MaemoDeviceConfig &devConf)
|
2009-10-27 14:15:24 +01:00
|
|
|
{
|
2009-12-01 14:04:25 +01:00
|
|
|
m_devConfig = devConf;
|
2010-03-01 16:47:32 +01:00
|
|
|
emit deviceConfigurationChanged(target());
|
2009-10-27 14:15:24 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
MaemoDeviceConfig MaemoRunConfiguration::deviceConfig() const
|
2009-10-27 14:15:24 +01:00
|
|
|
{
|
2009-12-01 14:04:25 +01:00
|
|
|
return m_devConfig;
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString MaemoRunConfiguration::sshCmd() const
|
|
|
|
|
{
|
|
|
|
|
return cmd(QString::fromLocal8Bit("ssh"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString MaemoRunConfiguration::scpCmd() const
|
|
|
|
|
{
|
|
|
|
|
return cmd(QString::fromLocal8Bit("scp"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString MaemoRunConfiguration::cmd(const QString &cmdName) const
|
|
|
|
|
{
|
|
|
|
|
QString command(cmdName);
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
command = maddeRoot() + QLatin1String("/bin/") + command
|
|
|
|
|
+ QLatin1String(".exe");
|
|
|
|
|
#endif
|
|
|
|
|
return command;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MaemoToolChain *MaemoRunConfiguration::toolchain() const
|
|
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Qt4BuildConfiguration *qt4bc(activeQt4BuildConfiguration());
|
2009-11-25 18:50:20 +01:00
|
|
|
QTC_ASSERT(qt4bc, return 0);
|
2010-02-09 13:16:10 +01:00
|
|
|
MaemoToolChain *tc = dynamic_cast<MaemoToolChain *>(qt4bc->toolChain());
|
2009-10-16 17:33:12 +02:00
|
|
|
QTC_ASSERT(tc != 0, return 0);
|
|
|
|
|
return tc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString MaemoRunConfiguration::gdbCmd() const
|
|
|
|
|
{
|
2009-11-30 10:55:48 +01:00
|
|
|
if (const MaemoToolChain *tc = toolchain())
|
2010-04-09 16:52:15 +02:00
|
|
|
return QDir::toNativeSeparators(tc->targetRoot() + QLatin1String("/bin/gdb"));
|
|
|
|
|
return QString();
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-04-15 12:47:02 +02:00
|
|
|
const MaemoPackageCreationStep *MaemoRunConfiguration::packageStep() const
|
|
|
|
|
{
|
|
|
|
|
const QList<ProjectExplorer::BuildStep *> &buildSteps
|
|
|
|
|
= activeQt4BuildConfiguration()->steps(ProjectExplorer::Build);
|
|
|
|
|
for (int i = buildSteps.count() - 1; i >= 0; --i) {
|
|
|
|
|
const MaemoPackageCreationStep * const pStep
|
|
|
|
|
= qobject_cast<MaemoPackageCreationStep *>(buildSteps.at(i));
|
|
|
|
|
if (pStep)
|
|
|
|
|
return pStep;
|
|
|
|
|
}
|
|
|
|
|
Q_ASSERT(!"Impossible: Maemo run configuration without packaging step.");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-16 17:33:12 +02:00
|
|
|
QString MaemoRunConfiguration::maddeRoot() const
|
|
|
|
|
{
|
2009-11-30 10:55:48 +01:00
|
|
|
if (const MaemoToolChain *tc = toolchain())
|
2009-11-30 14:53:16 +01:00
|
|
|
return tc->maddeRoot();
|
2009-11-30 10:55:48 +01:00
|
|
|
return QString();
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString MaemoRunConfiguration::sysRoot() const
|
|
|
|
|
{
|
2009-11-30 10:55:48 +01:00
|
|
|
if (const MaemoToolChain *tc = toolchain())
|
2009-12-01 14:04:25 +01:00
|
|
|
return tc->sysrootRoot();
|
2009-11-30 10:55:48 +01:00
|
|
|
return QString();
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-03-09 14:01:59 +01:00
|
|
|
const QString MaemoRunConfiguration::targetRoot() const
|
|
|
|
|
{
|
|
|
|
|
if (const MaemoToolChain *tc = toolchain())
|
|
|
|
|
return tc->targetRoot();
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-27 14:15:24 +01:00
|
|
|
const QStringList MaemoRunConfiguration::arguments() const
|
|
|
|
|
{
|
2009-12-01 14:04:25 +01:00
|
|
|
return m_arguments;
|
2009-10-27 14:15:24 +01:00
|
|
|
}
|
|
|
|
|
|
2009-10-16 17:33:12 +02:00
|
|
|
const QString MaemoRunConfiguration::dumperLib() const
|
|
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Qt4BuildConfiguration *qt4bc(activeQt4BuildConfiguration());
|
2009-11-25 18:50:20 +01:00
|
|
|
return qt4bc->qtVersion()->debuggingHelperLibrary();
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MaemoRunConfiguration::executable() const
|
|
|
|
|
{
|
2010-03-31 18:28:04 +02:00
|
|
|
TargetInformation ti = qt4Target()->qt4Project()->rootProjectNode()
|
|
|
|
|
->targetInformation(m_proFilePath);
|
2010-03-10 16:55:37 +01:00
|
|
|
if (!ti.valid)
|
|
|
|
|
return QString();
|
|
|
|
|
|
2010-03-31 18:28:04 +02:00
|
|
|
return QDir::toNativeSeparators(QDir::cleanPath(ti.workingDir
|
|
|
|
|
+ QLatin1Char('/') + ti.target));
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
2010-05-20 15:47:42 +02:00
|
|
|
QString MaemoRunConfiguration::runtimeGdbServerPort() const
|
2009-10-16 17:33:12 +02:00
|
|
|
{
|
2010-05-20 15:47:42 +02:00
|
|
|
if (Qt4BuildConfiguration *qt4bc = activeQt4BuildConfiguration()) {
|
|
|
|
|
Runtime rt;
|
|
|
|
|
const int id = qt4bc->qtVersion()->uniqueId();
|
|
|
|
|
if (QemuRuntimeManager::instance().runtimeForQtVersion(id, &rt))
|
|
|
|
|
return rt.m_gdbServerPort;
|
|
|
|
|
}
|
|
|
|
|
return QLatin1String("13219");
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoRunConfiguration::setArguments(const QStringList &args)
|
|
|
|
|
{
|
2009-12-01 14:04:25 +01:00
|
|
|
m_arguments = args;
|
2009-10-16 17:33:12 +02:00
|
|
|
}
|
|
|
|
|
|
2009-12-01 14:04:25 +01:00
|
|
|
void MaemoRunConfiguration::updateDeviceConfigurations()
|
|
|
|
|
{
|
2010-04-01 15:45:44 +02:00
|
|
|
const MaemoDeviceConfigurations &configManager
|
|
|
|
|
= MaemoDeviceConfigurations::instance();
|
|
|
|
|
if (!m_devConfig.isValid()) {
|
|
|
|
|
const QList<MaemoDeviceConfig> &configList = configManager.devConfigs();
|
|
|
|
|
if (!configList.isEmpty())
|
|
|
|
|
m_devConfig = configList.first();
|
|
|
|
|
} else {
|
|
|
|
|
m_devConfig = configManager.find(m_devConfig.internalId);
|
|
|
|
|
}
|
2010-06-21 13:25:34 +02:00
|
|
|
emit deviceConfigurationsUpdated(target());
|
2009-12-01 14:04:25 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-23 16:17:04 +01:00
|
|
|
} // namespace Internal
|
2010-01-07 11:21:11 +01:00
|
|
|
} // namespace Qt4ProjectManager
|