forked from qt-creator/qt-creator
RemoteLinux: Add "make install" step to pre-4.10 deploy configurations
... if applicable. Fixes: QTCREATORBUG-22689 Change-Id: If3cec90bed4d84f8bf82eb0cc1d831143ee2e298 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -223,7 +223,10 @@ DeployConfiguration *DeployConfigurationFactory::restore(Target *parent, const Q
|
||||
if (!dc->fromMap(map)) {
|
||||
delete dc;
|
||||
dc = nullptr;
|
||||
} else if (factory->postRestore()) {
|
||||
factory->postRestore()(dc, map);
|
||||
}
|
||||
|
||||
return dc;
|
||||
}
|
||||
|
||||
|
@@ -97,6 +97,10 @@ public:
|
||||
void setConfigWidgetCreator(const std::function<NamedWidget *(Target *)> &configWidgetCreator);
|
||||
void setUseDeploymentDataView();
|
||||
|
||||
using PostRestore = std::function<void(DeployConfiguration *dc, const QVariantMap &)>;
|
||||
void setPostRestore(const PostRestore &postRestore) { m_postRestore = postRestore; }
|
||||
PostRestore postRestore() const { return m_postRestore; }
|
||||
|
||||
protected:
|
||||
using DeployConfigurationCreator = std::function<DeployConfiguration *(Target *)>;
|
||||
void setConfigBaseId(Core::Id deployConfigBaseId);
|
||||
@@ -109,6 +113,7 @@ private:
|
||||
QList<BuildStepList::StepCreationInfo> m_initialSteps;
|
||||
QString m_defaultDisplayName;
|
||||
std::function<NamedWidget *(Target *)> m_configWidgetCreator;
|
||||
PostRestore m_postRestore;
|
||||
};
|
||||
|
||||
class DefaultDeployConfigurationFactory : public DeployConfigurationFactory
|
||||
|
@@ -155,6 +155,18 @@ public:
|
||||
static QVariant process(const QVariant &entry);
|
||||
};
|
||||
|
||||
// Version 21 adds a "make install" step to an existing RemoteLinux deploy configuration
|
||||
// if and only if such a step would be added when creating a new one.
|
||||
// See QTCREATORBUG-22689.
|
||||
class UserFileVersion21Upgrader : public VersionUpgrader
|
||||
{
|
||||
public:
|
||||
UserFileVersion21Upgrader() : VersionUpgrader(21, "4.10-pre1") { }
|
||||
QVariantMap upgrade(const QVariantMap &map) final;
|
||||
|
||||
static QVariant process(const QVariant &entry);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
//
|
||||
@@ -315,6 +327,7 @@ UserFileAccessor::UserFileAccessor(Project *project) :
|
||||
addVersionUpgrader(std::make_unique<UserFileVersion18Upgrader>());
|
||||
addVersionUpgrader(std::make_unique<UserFileVersion19Upgrader>());
|
||||
addVersionUpgrader(std::make_unique<UserFileVersion20Upgrader>());
|
||||
addVersionUpgrader(std::make_unique<UserFileVersion21Upgrader>());
|
||||
}
|
||||
|
||||
Project *UserFileAccessor::project() const
|
||||
@@ -855,6 +868,33 @@ QVariant UserFileVersion20Upgrader::process(const QVariant &entry)
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap UserFileVersion21Upgrader::upgrade(const QVariantMap &map)
|
||||
{
|
||||
return process(map).toMap();
|
||||
}
|
||||
|
||||
QVariant UserFileVersion21Upgrader::process(const QVariant &entry)
|
||||
{
|
||||
switch (entry.type()) {
|
||||
case QVariant::List:
|
||||
return Utils::transform(entry.toList(), &UserFileVersion21Upgrader::process);
|
||||
case QVariant::Map: {
|
||||
QVariantMap entryMap = entry.toMap();
|
||||
if (entryMap.value("ProjectExplorer.ProjectConfiguration.Id").toString()
|
||||
== "DeployToGenericLinux") {
|
||||
entryMap.insert("_checkMakeInstall", true);
|
||||
return entryMap;
|
||||
}
|
||||
return Utils::transform<QVariantMap>(
|
||||
entryMap.toStdMap(), [](const std::pair<const QString, QVariant> &item) {
|
||||
return qMakePair(item.first, UserFileVersion21Upgrader::process(item.second));
|
||||
});
|
||||
}
|
||||
default:
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(WITH_TESTS)
|
||||
|
||||
#include <QTest>
|
||||
|
@@ -61,11 +61,19 @@ RemoteLinuxDeployConfigurationFactory::RemoteLinuxDeployConfigurationFactory()
|
||||
"Deploy to Remote Linux Host"));
|
||||
setUseDeploymentDataView();
|
||||
|
||||
addInitialStep(MakeInstallStep::stepId(), [](Target *target) {
|
||||
const auto needsMakeInstall = [](Target *target)
|
||||
{
|
||||
const Project * const prj = target->project();
|
||||
return prj->deploymentKnowledge() == DeploymentKnowledge::Bad
|
||||
&& prj->hasMakeInstallEquivalent();
|
||||
};
|
||||
setPostRestore([needsMakeInstall](DeployConfiguration *dc, const QVariantMap &map) {
|
||||
// 4.9 -> 4.10. See QTCREATORBUG-22689.
|
||||
if (map.value("_checkMakeInstall").toBool() && needsMakeInstall(dc->target()))
|
||||
dc->stepList()->insertStep(0, new MakeInstallStep(dc->stepList()));
|
||||
});
|
||||
|
||||
addInitialStep(MakeInstallStep::stepId(), needsMakeInstall);
|
||||
addInitialStep(RemoteLinuxCheckForFreeDiskSpaceStep::stepId());
|
||||
addInitialStep(RemoteLinuxKillAppStep::stepId());
|
||||
addInitialStep(RsyncDeployStep::stepId(), [](Target *target) {
|
||||
|
Reference in New Issue
Block a user