Commit a793217c authored by ck's avatar ck
Browse files

Maemo: Prepare unpackaged deployment.

Reviewed-by: kh1
parent 13bb14dd
......@@ -61,8 +61,9 @@ static const QLatin1String MAEMO_RC_ID_PREFIX(PREFIX ".");
static const QLatin1String ArgumentsKey(PREFIX ".Arguments");
static const QLatin1String SimulatorPathKey(PREFIX ".Simulator");
static const QLatin1String DeviceIdKey(PREFIX ".DeviceId");
static const QLatin1String LastDeployedKey(PREFIX ".LastDeployed");
static const QLatin1String DebuggingHelpersLastDeployedKey(PREFIX ".DebuggingHelpersLastDeployed");
static const QLatin1String LastDeployedHostsKey(PREFIX ".LastDeployedHosts");
static const QLatin1String LastDeployedFilesKey(PREFIX ".LastDeployedFiles");
static const QLatin1String LastDeployedTimesKey(PREFIX ".LastDeployedTimes");
static const QLatin1String ProFileKey(".ProFile");
} // namespace Internal
......
......@@ -68,7 +68,6 @@ MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent,
, m_devConfig(source->m_devConfig)
, m_arguments(source->m_arguments)
, m_lastDeployed(source->m_lastDeployed)
, m_debuggingHelpersLastDeployed(source->m_debuggingHelpersLastDeployed)
{
init();
}
......@@ -124,25 +123,27 @@ QVariantMap MaemoRunConfiguration::toMap() const
QVariantMap map(RunConfiguration::toMap());
map.insert(DeviceIdKey, m_devConfig.internalId);
map.insert(ArgumentsKey, m_arguments);
addDeployTimesToMap(LastDeployedKey, m_lastDeployed, map);
addDeployTimesToMap(DebuggingHelpersLastDeployedKey,
m_debuggingHelpersLastDeployed, map);
addDeployTimesToMap(map);
const QDir dir = QDir(target()->project()->projectDirectory());
map.insert(ProFileKey, dir.relativeFilePath(m_proFilePath));
return map;
}
void MaemoRunConfiguration::addDeployTimesToMap(const QString &key,
const QMap<QString, QDateTime> &deployTimes, QVariantMap &map) const
void MaemoRunConfiguration::addDeployTimesToMap(QVariantMap &map) const
{
QMap<QString, QVariant> variantMap;
QMap<QString, QDateTime>::ConstIterator it = deployTimes.begin();
for (; it != deployTimes.end(); ++it)
variantMap.insert(it.key(), it.value());
map.insert(key, variantMap);
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);
}
bool MaemoRunConfiguration::fromMap(const QVariantMap &map)
......@@ -153,62 +154,40 @@ bool MaemoRunConfiguration::fromMap(const QVariantMap &map)
setDeviceConfig(MaemoDeviceConfigurations::instance().
find(map.value(DeviceIdKey, 0).toInt()));
m_arguments = map.value(ArgumentsKey).toStringList();
getDeployTimesFromMap(LastDeployedKey, m_lastDeployed, map);
getDeployTimesFromMap(DebuggingHelpersLastDeployedKey,
m_debuggingHelpersLastDeployed, map);
getDeployTimesFromMap(map);
const QDir dir = QDir(target()->project()->projectDirectory());
m_proFilePath = dir.filePath(map.value(ProFileKey).toString());
return true;
}
void MaemoRunConfiguration::getDeployTimesFromMap(const QString &key,
QMap<QString, QDateTime> &deployTimes, const QVariantMap &map)
void MaemoRunConfiguration::getDeployTimesFromMap(const QVariantMap &map)
{
const QVariantMap &variantMap = map.value(key).toMap();
for (QVariantMap::ConstIterator it = variantMap.begin();
it != variantMap.end(); ++it)
deployTimes.insert(it.key(), it.value().toDateTime());
}
bool MaemoRunConfiguration::currentlyNeedsDeployment(const QString &host) const
{
return fileNeedsDeployment(packageStep()->packageFilePath(),
m_lastDeployed.value(host));
}
void MaemoRunConfiguration::wasDeployed(const QString &host)
{
m_lastDeployed.insert(host, QDateTime::currentDateTime());
}
bool MaemoRunConfiguration::hasDebuggingHelpers() const
{
Qt4BuildConfiguration *qt4bc = activeQt4BuildConfiguration();
return qt4bc->qtVersion()->hasDebuggingHelper();
}
bool MaemoRunConfiguration::debuggingHelpersNeedDeployment(const QString &host) const
{
if (hasDebuggingHelpers()) {
return fileNeedsDeployment(dumperLib(),
m_debuggingHelpersLastDeployed.value(host));
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());
}
return false;
}
void MaemoRunConfiguration::debuggingHelpersDeployed(const QString &host)
bool MaemoRunConfiguration::currentlyNeedsDeployment(const QString &host,
const QString &file) const
{
m_debuggingHelpersLastDeployed.insert(host, QDateTime::currentDateTime());
const QDateTime &lastDeployed
= m_lastDeployed.value(DeployablePerHost(host, file));
return !lastDeployed.isValid()
|| QFileInfo(file).lastModified() > lastDeployed;
}
bool MaemoRunConfiguration::fileNeedsDeployment(const QString &path,
const QDateTime &lastDeployed) const
void MaemoRunConfiguration::setDeployed(const QString &host,
const QString &file)
{
return !lastDeployed.isValid()
|| QFileInfo(path).lastModified() > lastDeployed;
m_lastDeployed.insert(DeployablePerHost(host, file),
QDateTime::currentDateTime());
}
void MaemoRunConfiguration::setDeviceConfig(const MaemoDeviceConfig &devConf)
......
......@@ -69,12 +69,9 @@ public:
Qt4Target *qt4Target() const;
Qt4BuildConfiguration *activeQt4BuildConfiguration() const;
bool currentlyNeedsDeployment(const QString &host) const;
void wasDeployed(const QString &host);
bool hasDebuggingHelpers() const;
bool debuggingHelpersNeedDeployment(const QString &host) const;
void debuggingHelpersDeployed(const QString &host);
bool currentlyNeedsDeployment(const QString &host,
const QString &file) const;
void setDeployed(const QString &host, const QString &file);
const MaemoPackageCreationStep *packageStep() const;
......@@ -112,13 +109,8 @@ private:
void init();
const QString cmd(const QString &cmdName) const;
const MaemoToolChain *toolchain() const;
bool fileNeedsDeployment(const QString &path, const QDateTime &lastDeployed) const;
void addDeployTimesToMap(const QString &key,
const QMap<QString, QDateTime> &deployTimes,
QVariantMap &map) const;
void getDeployTimesFromMap(const QString &key,
QMap<QString, QDateTime> &deployTimes,
const QVariantMap &map);
void addDeployTimesToMap(QVariantMap &map) const;
void getDeployTimesFromMap(const QVariantMap &map);
QString m_proFilePath;
mutable QString m_gdbPath;
......@@ -126,9 +118,8 @@ private:
MaemoDeviceConfig m_devConfig;
QStringList m_arguments;
// These map host names to deploy times.
QMap<QString, QDateTime> m_lastDeployed;
QMap<QString, QDateTime> m_debuggingHelpersLastDeployed;
typedef QPair<QString, QString> DeployablePerHost;
QMap<DeployablePerHost, QDateTime> m_lastDeployed;
};
} // namespace Internal
......
......@@ -124,21 +124,22 @@ void AbstractMaemoRunControl::startDeployment(bool forDebugging)
emit finished();
} else {
m_deployables.clear();
if (m_runConfig->currentlyNeedsDeployment(m_devConfig.server.host)) {
if (m_runConfig->currentlyNeedsDeployment(m_devConfig.server.host,
packageFilePath())) {
m_deployables.append(Deployable(packageFileName(),
QFileInfo(executableOnHost()).canonicalPath(),
&MaemoRunConfiguration::wasDeployed));
QFileInfo(executableOnHost()).canonicalPath()));
m_needsInstall = true;
} else {
m_needsInstall = false;
}
if (forDebugging
&& m_runConfig->debuggingHelpersNeedDeployment(m_devConfig.server.host)) {
const QFileInfo &info(m_runConfig->dumperLib());
m_deployables.append(Deployable(info.fileName(), info.canonicalPath(),
&MaemoRunConfiguration::debuggingHelpersDeployed));
if (forDebugging) {
const QFileInfo info(m_runConfig->dumperLib());
if (info.exists()
&& m_runConfig->currentlyNeedsDeployment(m_devConfig.server.host,
info.filePath())) {
m_deployables.append(Deployable(info.fileName(), info.canonicalPath()));
}
}
deploy();
}
}
......@@ -179,7 +180,8 @@ void AbstractMaemoRunControl::deploy()
void AbstractMaemoRunControl::handleFileCopied()
{
Deployable deployable = m_deployables.takeFirst();
(m_runConfig->*deployable.updateTimestamp)(m_devConfig.server.host);
m_runConfig->setDeployed(m_devConfig.server.host,
deployable.dir + QLatin1Char('/') + deployable.fileName);
m_progress.setProgressValue(m_progress.progressValue() + 1);
}
......
......@@ -117,12 +117,10 @@ private:
struct Deployable
{
typedef void (MaemoRunConfiguration::*updateFunc)(const QString&);
Deployable(const QString &f, const QString &d, updateFunc u)
: fileName(f), dir(d), updateTimestamp(u) {}
Deployable(const QString &f, const QString &d)
: fileName(f), dir(d) {}
QString fileName;
QString dir;
updateFunc updateTimestamp;
};
QList<Deployable> m_deployables;
bool m_needsInstall;
......
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