forked from qt-creator/qt-creator
RemoteLinux: Merge abstractremotelinuxdeploy{step,service} file pairs
Plan is to merge the class hierarchies, this is a mechanical first step. Change-Id: I163578297a4badb5b8c861283f0d6a44c25f124f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <remotelinux/abstractremotelinuxdeployservice.h>
|
||||
#include <remotelinux/abstractremotelinuxdeploystep.h>
|
||||
|
||||
#include <utils/commandline.h>
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <remotelinux/abstractremotelinuxdeployservice.h>
|
||||
#include <remotelinux/abstractremotelinuxdeploystep.h>
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
|
@@ -2,7 +2,6 @@ add_qtc_plugin(RemoteLinux
|
||||
DEPENDS QmlDebug
|
||||
PLUGIN_DEPENDS Core Debugger ProjectExplorer
|
||||
SOURCES
|
||||
abstractremotelinuxdeployservice.cpp abstractremotelinuxdeployservice.h
|
||||
abstractremotelinuxdeploystep.cpp abstractremotelinuxdeploystep.h
|
||||
customcommanddeploystep.cpp customcommanddeploystep.h
|
||||
deploymenttimeinfo.cpp deploymenttimeinfo.h
|
||||
|
@@ -1,146 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "abstractremotelinuxdeployservice.h"
|
||||
|
||||
#include "deploymenttimeinfo.h"
|
||||
#include "remotelinuxtr.h"
|
||||
|
||||
#include <projectexplorer/deployablefile.h>
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/tasktree.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace RemoteLinux {
|
||||
namespace Internal {
|
||||
|
||||
class AbstractRemoteLinuxDeployServicePrivate
|
||||
{
|
||||
public:
|
||||
IDevice::ConstPtr deviceConfiguration;
|
||||
QPointer<Target> target;
|
||||
|
||||
DeploymentTimeInfo deployTimes;
|
||||
std::unique_ptr<TaskTree> m_taskTree;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
using namespace Internal;
|
||||
|
||||
AbstractRemoteLinuxDeployService::AbstractRemoteLinuxDeployService(QObject *parent)
|
||||
: QObject(parent), d(new AbstractRemoteLinuxDeployServicePrivate)
|
||||
{
|
||||
}
|
||||
|
||||
AbstractRemoteLinuxDeployService::~AbstractRemoteLinuxDeployService()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
const Target *AbstractRemoteLinuxDeployService::target() const
|
||||
{
|
||||
return d->target;
|
||||
}
|
||||
|
||||
const Kit *AbstractRemoteLinuxDeployService::kit() const
|
||||
{
|
||||
return d->target ? d->target->kit() : nullptr;
|
||||
}
|
||||
|
||||
IDevice::ConstPtr AbstractRemoteLinuxDeployService::deviceConfiguration() const
|
||||
{
|
||||
return d->deviceConfiguration;
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::saveDeploymentTimeStamp(const DeployableFile &deployableFile,
|
||||
const QDateTime &remoteTimestamp)
|
||||
{
|
||||
d->deployTimes.saveDeploymentTimeStamp(deployableFile, kit(), remoteTimestamp);
|
||||
}
|
||||
|
||||
bool AbstractRemoteLinuxDeployService::hasLocalFileChanged(
|
||||
const DeployableFile &deployableFile) const
|
||||
{
|
||||
return d->deployTimes.hasLocalFileChanged(deployableFile, kit());
|
||||
}
|
||||
|
||||
bool AbstractRemoteLinuxDeployService::hasRemoteFileChanged(
|
||||
const DeployableFile &deployableFile, const QDateTime &remoteTimestamp) const
|
||||
{
|
||||
return d->deployTimes.hasRemoteFileChanged(deployableFile, kit(), remoteTimestamp);
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::setTarget(Target *target)
|
||||
{
|
||||
d->target = target;
|
||||
d->deviceConfiguration = DeviceKitAspect::device(kit());
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::setDevice(const IDevice::ConstPtr &device)
|
||||
{
|
||||
d->deviceConfiguration = device;
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::start()
|
||||
{
|
||||
QTC_ASSERT(!d->m_taskTree, return);
|
||||
|
||||
const CheckResult check = isDeploymentPossible();
|
||||
if (!check) {
|
||||
emit errorMessage(check.errorMessage());
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isDeploymentNecessary()) {
|
||||
emit progressMessage(Tr::tr("No deployment action necessary. Skipping."));
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
d->m_taskTree.reset(new TaskTree(deployRecipe()));
|
||||
const auto endHandler = [this] {
|
||||
d->m_taskTree.release()->deleteLater();
|
||||
emit finished();
|
||||
};
|
||||
connect(d->m_taskTree.get(), &TaskTree::done, this, endHandler);
|
||||
connect(d->m_taskTree.get(), &TaskTree::errorOccurred, this, endHandler);
|
||||
d->m_taskTree->start();
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::stop()
|
||||
{
|
||||
if (!d->m_taskTree)
|
||||
return;
|
||||
d->m_taskTree.reset();
|
||||
emit finished();
|
||||
}
|
||||
|
||||
CheckResult AbstractRemoteLinuxDeployService::isDeploymentPossible() const
|
||||
{
|
||||
if (!deviceConfiguration())
|
||||
return CheckResult::failure(Tr::tr("No device configuration set."));
|
||||
return CheckResult::success();
|
||||
}
|
||||
|
||||
QVariantMap AbstractRemoteLinuxDeployService::exportDeployTimes() const
|
||||
{
|
||||
return d->deployTimes.exportDeployTimes();
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::importDeployTimes(const QVariantMap &map)
|
||||
{
|
||||
d->deployTimes.importDeployTimes(map);
|
||||
}
|
||||
|
||||
} // namespace RemoteLinux
|
@@ -1,85 +0,0 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "remotelinux_export.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/idevicefwd.h>
|
||||
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
#include <QObject>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class DeployableFile;
|
||||
class Kit;
|
||||
class Target;
|
||||
}
|
||||
|
||||
namespace Utils::Tasking { class Group; }
|
||||
|
||||
namespace RemoteLinux {
|
||||
namespace Internal { class AbstractRemoteLinuxDeployServicePrivate; }
|
||||
|
||||
class REMOTELINUX_EXPORT CheckResult
|
||||
{
|
||||
public:
|
||||
static CheckResult success() { return {true, {}}; }
|
||||
static CheckResult failure(const QString &error = {}) { return {false, error}; }
|
||||
|
||||
operator bool() const { return m_ok; }
|
||||
QString errorMessage() const { return m_error; }
|
||||
|
||||
private:
|
||||
CheckResult(bool ok, const QString &error) : m_ok(ok), m_error(error) {}
|
||||
|
||||
bool m_ok = false;
|
||||
QString m_error;
|
||||
};
|
||||
|
||||
class REMOTELINUX_EXPORT AbstractRemoteLinuxDeployService : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(AbstractRemoteLinuxDeployService)
|
||||
public:
|
||||
explicit AbstractRemoteLinuxDeployService(QObject *parent = nullptr);
|
||||
~AbstractRemoteLinuxDeployService() override;
|
||||
|
||||
void setTarget(ProjectExplorer::Target *bc);
|
||||
// Only use setDevice() as fallback if no target is available
|
||||
void setDevice(const ProjectExplorer::IDeviceConstPtr &device);
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
QVariantMap exportDeployTimes() const;
|
||||
void importDeployTimes(const QVariantMap &map);
|
||||
|
||||
virtual CheckResult isDeploymentPossible() const;
|
||||
|
||||
signals:
|
||||
void errorMessage(const QString &message);
|
||||
void progressMessage(const QString &message);
|
||||
void warningMessage(const QString &message);
|
||||
void stdOutData(const QString &data);
|
||||
void stdErrData(const QString &data);
|
||||
void finished(); // Used by Qnx.
|
||||
|
||||
protected:
|
||||
const ProjectExplorer::Target *target() const;
|
||||
const ProjectExplorer::Kit *kit() const;
|
||||
ProjectExplorer::IDeviceConstPtr deviceConfiguration() const;
|
||||
|
||||
void saveDeploymentTimeStamp(const ProjectExplorer::DeployableFile &deployableFile,
|
||||
const QDateTime &remoteTimestamp);
|
||||
bool hasLocalFileChanged(const ProjectExplorer::DeployableFile &deployableFile) const;
|
||||
bool hasRemoteFileChanged(const ProjectExplorer::DeployableFile &deployableFile,
|
||||
const QDateTime &remoteTimestamp) const;
|
||||
|
||||
private:
|
||||
virtual bool isDeploymentNecessary() const = 0;
|
||||
virtual Utils::Tasking::Group deployRecipe() = 0;
|
||||
|
||||
Internal::AbstractRemoteLinuxDeployServicePrivate * const d;
|
||||
};
|
||||
|
||||
} // namespace RemoteLinux
|
@@ -3,17 +3,37 @@
|
||||
|
||||
#include "abstractremotelinuxdeploystep.h"
|
||||
|
||||
#include "abstractremotelinuxdeployservice.h"
|
||||
#include "deploymenttimeinfo.h"
|
||||
#include "remotelinuxtr.h"
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/deployablefile.h>
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/tasktree.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace RemoteLinux {
|
||||
namespace Internal {
|
||||
|
||||
class AbstractRemoteLinuxDeployServicePrivate
|
||||
{
|
||||
public:
|
||||
IDevice::ConstPtr deviceConfiguration;
|
||||
QPointer<Target> target;
|
||||
|
||||
DeploymentTimeInfo deployTimes;
|
||||
std::unique_ptr<TaskTree> m_taskTree;
|
||||
};
|
||||
|
||||
class AbstractRemoteLinuxDeployStepPrivate
|
||||
{
|
||||
public:
|
||||
@@ -23,7 +43,117 @@ public:
|
||||
AbstractRemoteLinuxDeployService *deployService = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // Internal
|
||||
|
||||
using namespace Internal;
|
||||
|
||||
AbstractRemoteLinuxDeployService::AbstractRemoteLinuxDeployService(QObject *parent)
|
||||
: QObject(parent), d(new AbstractRemoteLinuxDeployServicePrivate)
|
||||
{
|
||||
}
|
||||
|
||||
AbstractRemoteLinuxDeployService::~AbstractRemoteLinuxDeployService()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
const Target *AbstractRemoteLinuxDeployService::target() const
|
||||
{
|
||||
return d->target;
|
||||
}
|
||||
|
||||
const Kit *AbstractRemoteLinuxDeployService::kit() const
|
||||
{
|
||||
return d->target ? d->target->kit() : nullptr;
|
||||
}
|
||||
|
||||
IDevice::ConstPtr AbstractRemoteLinuxDeployService::deviceConfiguration() const
|
||||
{
|
||||
return d->deviceConfiguration;
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::saveDeploymentTimeStamp(const DeployableFile &deployableFile,
|
||||
const QDateTime &remoteTimestamp)
|
||||
{
|
||||
d->deployTimes.saveDeploymentTimeStamp(deployableFile, kit(), remoteTimestamp);
|
||||
}
|
||||
|
||||
bool AbstractRemoteLinuxDeployService::hasLocalFileChanged(
|
||||
const DeployableFile &deployableFile) const
|
||||
{
|
||||
return d->deployTimes.hasLocalFileChanged(deployableFile, kit());
|
||||
}
|
||||
|
||||
bool AbstractRemoteLinuxDeployService::hasRemoteFileChanged(
|
||||
const DeployableFile &deployableFile, const QDateTime &remoteTimestamp) const
|
||||
{
|
||||
return d->deployTimes.hasRemoteFileChanged(deployableFile, kit(), remoteTimestamp);
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::setTarget(Target *target)
|
||||
{
|
||||
d->target = target;
|
||||
d->deviceConfiguration = DeviceKitAspect::device(kit());
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::setDevice(const IDevice::ConstPtr &device)
|
||||
{
|
||||
d->deviceConfiguration = device;
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::start()
|
||||
{
|
||||
QTC_ASSERT(!d->m_taskTree, return);
|
||||
|
||||
const CheckResult check = isDeploymentPossible();
|
||||
if (!check) {
|
||||
emit errorMessage(check.errorMessage());
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isDeploymentNecessary()) {
|
||||
emit progressMessage(Tr::tr("No deployment action necessary. Skipping."));
|
||||
emit finished();
|
||||
return;
|
||||
}
|
||||
|
||||
d->m_taskTree.reset(new TaskTree(deployRecipe()));
|
||||
const auto endHandler = [this] {
|
||||
d->m_taskTree.release()->deleteLater();
|
||||
emit finished();
|
||||
};
|
||||
connect(d->m_taskTree.get(), &TaskTree::done, this, endHandler);
|
||||
connect(d->m_taskTree.get(), &TaskTree::errorOccurred, this, endHandler);
|
||||
d->m_taskTree->start();
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::stop()
|
||||
{
|
||||
if (!d->m_taskTree)
|
||||
return;
|
||||
d->m_taskTree.reset();
|
||||
emit finished();
|
||||
}
|
||||
|
||||
CheckResult AbstractRemoteLinuxDeployService::isDeploymentPossible() const
|
||||
{
|
||||
if (!deviceConfiguration())
|
||||
return CheckResult::failure(Tr::tr("No device configuration set."));
|
||||
return CheckResult::success();
|
||||
}
|
||||
|
||||
QVariantMap AbstractRemoteLinuxDeployService::exportDeployTimes() const
|
||||
{
|
||||
return d->deployTimes.exportDeployTimes();
|
||||
}
|
||||
|
||||
void AbstractRemoteLinuxDeployService::importDeployTimes(const QVariantMap &map)
|
||||
{
|
||||
d->deployTimes.importDeployTimes(map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl, Utils::Id id)
|
||||
: BuildStep(bsl, id), d(new Internal::AbstractRemoteLinuxDeployStepPrivate)
|
||||
|
@@ -6,6 +6,18 @@
|
||||
#include "remotelinux_export.h"
|
||||
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/devicesupport/idevicefwd.h>
|
||||
|
||||
#include <QtCore/qcontainerfwd.h>
|
||||
#include <QObject>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class DeployableFile;
|
||||
class Kit;
|
||||
class Target;
|
||||
}
|
||||
|
||||
namespace Utils::Tasking { class Group; }
|
||||
|
||||
namespace RemoteLinux {
|
||||
|
||||
@@ -13,6 +25,7 @@ class AbstractRemoteLinuxDeployService;
|
||||
class CheckResult;
|
||||
|
||||
namespace Internal { class AbstractRemoteLinuxDeployStepPrivate; }
|
||||
namespace Internal { class AbstractRemoteLinuxDeployServicePrivate; }
|
||||
|
||||
class REMOTELINUX_EXPORT AbstractRemoteLinuxDeployStep : public ProjectExplorer::BuildStep
|
||||
{
|
||||
@@ -45,4 +58,65 @@ private:
|
||||
Internal::AbstractRemoteLinuxDeployStepPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace RemoteLinux
|
||||
class REMOTELINUX_EXPORT CheckResult
|
||||
{
|
||||
public:
|
||||
static CheckResult success() { return {true, {}}; }
|
||||
static CheckResult failure(const QString &error = {}) { return {false, error}; }
|
||||
|
||||
operator bool() const { return m_ok; }
|
||||
QString errorMessage() const { return m_error; }
|
||||
|
||||
private:
|
||||
CheckResult(bool ok, const QString &error) : m_ok(ok), m_error(error) {}
|
||||
|
||||
bool m_ok = false;
|
||||
QString m_error;
|
||||
};
|
||||
|
||||
class REMOTELINUX_EXPORT AbstractRemoteLinuxDeployService : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(AbstractRemoteLinuxDeployService)
|
||||
public:
|
||||
explicit AbstractRemoteLinuxDeployService(QObject *parent = nullptr);
|
||||
~AbstractRemoteLinuxDeployService() override;
|
||||
|
||||
void setTarget(ProjectExplorer::Target *bc);
|
||||
// Only use setDevice() as fallback if no target is available
|
||||
void setDevice(const ProjectExplorer::IDeviceConstPtr &device);
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
QVariantMap exportDeployTimes() const;
|
||||
void importDeployTimes(const QVariantMap &map);
|
||||
|
||||
virtual CheckResult isDeploymentPossible() const;
|
||||
|
||||
signals:
|
||||
void errorMessage(const QString &message);
|
||||
void progressMessage(const QString &message);
|
||||
void warningMessage(const QString &message);
|
||||
void stdOutData(const QString &data);
|
||||
void stdErrData(const QString &data);
|
||||
void finished(); // Used by Qnx.
|
||||
|
||||
protected:
|
||||
const ProjectExplorer::Target *target() const;
|
||||
const ProjectExplorer::Kit *kit() const;
|
||||
ProjectExplorer::IDeviceConstPtr deviceConfiguration() const;
|
||||
|
||||
void saveDeploymentTimeStamp(const ProjectExplorer::DeployableFile &deployableFile,
|
||||
const QDateTime &remoteTimestamp);
|
||||
bool hasLocalFileChanged(const ProjectExplorer::DeployableFile &deployableFile) const;
|
||||
bool hasRemoteFileChanged(const ProjectExplorer::DeployableFile &deployableFile,
|
||||
const QDateTime &remoteTimestamp) const;
|
||||
|
||||
private:
|
||||
virtual bool isDeploymentNecessary() const = 0;
|
||||
virtual Utils::Tasking::Group deployRecipe() = 0;
|
||||
|
||||
Internal::AbstractRemoteLinuxDeployServicePrivate * const d;
|
||||
};
|
||||
|
||||
} // RemoteLinux
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "customcommanddeploystep.h"
|
||||
|
||||
#include "abstractremotelinuxdeployservice.h"
|
||||
#include "abstractremotelinuxdeploystep.h"
|
||||
#include "remotelinux_constants.h"
|
||||
#include "remotelinuxtr.h"
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "remotelinux_export.h"
|
||||
|
||||
#include "abstractremotelinuxdeployservice.h"
|
||||
#include "abstractremotelinuxdeploystep.h"
|
||||
|
||||
#include <QList>
|
||||
|
||||
|
@@ -4,7 +4,6 @@
|
||||
#include "killappstep.h"
|
||||
|
||||
#include "abstractremotelinuxdeploystep.h"
|
||||
#include "abstractremotelinuxdeployservice.h"
|
||||
#include "remotelinux_constants.h"
|
||||
#include "remotelinuxtr.h"
|
||||
|
||||
|
@@ -13,8 +13,6 @@ Project {
|
||||
Depends { name: "ProjectExplorer" }
|
||||
|
||||
files: [
|
||||
"abstractremotelinuxdeployservice.cpp",
|
||||
"abstractremotelinuxdeployservice.h",
|
||||
"abstractremotelinuxdeploystep.cpp",
|
||||
"abstractremotelinuxdeploystep.h",
|
||||
"deploymenttimeinfo.cpp",
|
||||
|
@@ -3,8 +3,6 @@
|
||||
|
||||
#include "rsyncdeploystep.h"
|
||||
|
||||
#include "abstractremotelinuxdeploystep.h"
|
||||
#include "abstractremotelinuxdeployservice.h"
|
||||
#include "abstractremotelinuxdeploystep.h"
|
||||
#include "remotelinux_constants.h"
|
||||
#include "remotelinuxtr.h"
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "tarpackagedeploystep.h"
|
||||
|
||||
#include "abstractremotelinuxdeployservice.h"
|
||||
#include "abstractremotelinuxdeploystep.h"
|
||||
#include "remotelinux_constants.h"
|
||||
#include "remotelinuxtr.h"
|
||||
|
Reference in New Issue
Block a user