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:
Christian Kandeler
2019-07-16 13:56:40 +02:00
parent c8e656c506
commit 7b4cde9d65
4 changed files with 57 additions and 1 deletions

View File

@@ -223,7 +223,10 @@ DeployConfiguration *DeployConfigurationFactory::restore(Target *parent, const Q
if (!dc->fromMap(map)) { if (!dc->fromMap(map)) {
delete dc; delete dc;
dc = nullptr; dc = nullptr;
} else if (factory->postRestore()) {
factory->postRestore()(dc, map);
} }
return dc; return dc;
} }

View File

@@ -97,6 +97,10 @@ public:
void setConfigWidgetCreator(const std::function<NamedWidget *(Target *)> &configWidgetCreator); void setConfigWidgetCreator(const std::function<NamedWidget *(Target *)> &configWidgetCreator);
void setUseDeploymentDataView(); 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: protected:
using DeployConfigurationCreator = std::function<DeployConfiguration *(Target *)>; using DeployConfigurationCreator = std::function<DeployConfiguration *(Target *)>;
void setConfigBaseId(Core::Id deployConfigBaseId); void setConfigBaseId(Core::Id deployConfigBaseId);
@@ -109,6 +113,7 @@ private:
QList<BuildStepList::StepCreationInfo> m_initialSteps; QList<BuildStepList::StepCreationInfo> m_initialSteps;
QString m_defaultDisplayName; QString m_defaultDisplayName;
std::function<NamedWidget *(Target *)> m_configWidgetCreator; std::function<NamedWidget *(Target *)> m_configWidgetCreator;
PostRestore m_postRestore;
}; };
class DefaultDeployConfigurationFactory : public DeployConfigurationFactory class DefaultDeployConfigurationFactory : public DeployConfigurationFactory

View File

@@ -155,6 +155,18 @@ public:
static QVariant process(const QVariant &entry); 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 } // namespace
// //
@@ -315,6 +327,7 @@ UserFileAccessor::UserFileAccessor(Project *project) :
addVersionUpgrader(std::make_unique<UserFileVersion18Upgrader>()); addVersionUpgrader(std::make_unique<UserFileVersion18Upgrader>());
addVersionUpgrader(std::make_unique<UserFileVersion19Upgrader>()); addVersionUpgrader(std::make_unique<UserFileVersion19Upgrader>());
addVersionUpgrader(std::make_unique<UserFileVersion20Upgrader>()); addVersionUpgrader(std::make_unique<UserFileVersion20Upgrader>());
addVersionUpgrader(std::make_unique<UserFileVersion21Upgrader>());
} }
Project *UserFileAccessor::project() const 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) #if defined(WITH_TESTS)
#include <QTest> #include <QTest>

View File

@@ -61,11 +61,19 @@ RemoteLinuxDeployConfigurationFactory::RemoteLinuxDeployConfigurationFactory()
"Deploy to Remote Linux Host")); "Deploy to Remote Linux Host"));
setUseDeploymentDataView(); setUseDeploymentDataView();
addInitialStep(MakeInstallStep::stepId(), [](Target *target) { const auto needsMakeInstall = [](Target *target)
{
const Project * const prj = target->project(); const Project * const prj = target->project();
return prj->deploymentKnowledge() == DeploymentKnowledge::Bad return prj->deploymentKnowledge() == DeploymentKnowledge::Bad
&& prj->hasMakeInstallEquivalent(); && 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(RemoteLinuxCheckForFreeDiskSpaceStep::stepId());
addInitialStep(RemoteLinuxKillAppStep::stepId()); addInitialStep(RemoteLinuxKillAppStep::stepId());
addInitialStep(RsyncDeployStep::stepId(), [](Target *target) { addInitialStep(RsyncDeployStep::stepId(), [](Target *target) {