2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2011-07-07 10:43:59 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2012-07-25 17:41:01 +02:00
|
|
|
|
2011-07-07 10:43:59 +02:00
|
|
|
#include "abstractremotelinuxdeploystep.h"
|
|
|
|
|
|
|
|
|
|
#include "abstractremotelinuxdeployservice.h"
|
2022-07-15 12:20:23 +02:00
|
|
|
#include "remotelinuxtr.h"
|
2011-07-07 10:43:59 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2011-07-07 10:43:59 +02:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace RemoteLinux {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class AbstractRemoteLinuxDeployStepPrivate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
bool hasError;
|
2019-06-07 16:43:06 +02:00
|
|
|
std::function<CheckResult()> internalInit;
|
2019-06-13 17:03:56 +02:00
|
|
|
std::function<void()> runPreparer;
|
|
|
|
|
AbstractRemoteLinuxDeployService *deployService = nullptr;
|
2011-07-07 10:43:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
|
2020-06-26 13:59:38 +02:00
|
|
|
AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl, Utils::Id id)
|
2011-09-16 11:33:48 +02:00
|
|
|
: BuildStep(bsl, id), d(new Internal::AbstractRemoteLinuxDeployStepPrivate)
|
2011-07-07 10:43:59 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-07 16:43:06 +02:00
|
|
|
void AbstractRemoteLinuxDeployStep::setInternalInitializer(const std::function<CheckResult ()> &init)
|
|
|
|
|
{
|
|
|
|
|
d->internalInit = init;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-13 17:03:56 +02:00
|
|
|
void AbstractRemoteLinuxDeployStep::setRunPreparer(const std::function<void ()> &prep)
|
|
|
|
|
{
|
|
|
|
|
d->runPreparer = prep;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::setDeployService(AbstractRemoteLinuxDeployService *service)
|
|
|
|
|
{
|
|
|
|
|
d->deployService = service;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-13 12:44:01 +02:00
|
|
|
AbstractRemoteLinuxDeployStep::~AbstractRemoteLinuxDeployStep()
|
|
|
|
|
{
|
2019-06-13 17:03:56 +02:00
|
|
|
delete d->deployService;
|
2012-07-13 12:44:01 +02:00
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-07 10:43:59 +02:00
|
|
|
bool AbstractRemoteLinuxDeployStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!BuildStep::fromMap(map))
|
|
|
|
|
return false;
|
2019-06-13 17:03:56 +02:00
|
|
|
d->deployService->importDeployTimes(map);
|
2011-07-07 10:43:59 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AbstractRemoteLinuxDeployStep::toMap() const
|
|
|
|
|
{
|
2020-08-20 11:25:35 +02:00
|
|
|
QVariantMap map = BuildStep::toMap();
|
|
|
|
|
map.insert(d->deployService->exportDeployTimes());
|
|
|
|
|
return map;
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool AbstractRemoteLinuxDeployStep::init()
|
2011-07-07 10:43:59 +02:00
|
|
|
{
|
2019-06-13 17:03:56 +02:00
|
|
|
d->deployService->setTarget(target());
|
2019-06-07 16:43:06 +02:00
|
|
|
|
|
|
|
|
QTC_ASSERT(d->internalInit, return false);
|
|
|
|
|
const CheckResult canDeploy = d->internalInit();
|
2019-04-24 14:38:01 +02:00
|
|
|
if (!canDeploy) {
|
2022-07-15 12:20:23 +02:00
|
|
|
emit addOutput(Tr::tr("Cannot deploy: %1").arg(canDeploy.errorMessage()),
|
2019-04-24 14:38:01 +02:00
|
|
|
OutputFormat::ErrorMessage);
|
|
|
|
|
}
|
2011-09-22 17:37:05 +02:00
|
|
|
return canDeploy;
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void AbstractRemoteLinuxDeployStep::doRun()
|
2011-07-07 10:43:59 +02:00
|
|
|
{
|
2019-06-13 17:03:56 +02:00
|
|
|
if (d->runPreparer)
|
|
|
|
|
d->runPreparer();
|
|
|
|
|
|
|
|
|
|
connect(d->deployService, &AbstractRemoteLinuxDeployService::errorMessage,
|
2016-06-30 23:04:57 +03:00
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleErrorMessage);
|
2019-06-13 17:03:56 +02:00
|
|
|
connect(d->deployService, &AbstractRemoteLinuxDeployService::progressMessage,
|
2016-06-30 23:04:57 +03:00
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleProgressMessage);
|
2019-06-13 17:03:56 +02:00
|
|
|
connect(d->deployService, &AbstractRemoteLinuxDeployService::warningMessage,
|
2016-06-30 23:04:57 +03:00
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleWarningMessage);
|
2019-06-13 17:03:56 +02:00
|
|
|
connect(d->deployService, &AbstractRemoteLinuxDeployService::stdOutData,
|
2016-06-30 23:04:57 +03:00
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleStdOutData);
|
2019-06-13 17:03:56 +02:00
|
|
|
connect(d->deployService, &AbstractRemoteLinuxDeployService::stdErrData,
|
2016-06-30 23:04:57 +03:00
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleStdErrData);
|
2019-06-13 17:03:56 +02:00
|
|
|
connect(d->deployService, &AbstractRemoteLinuxDeployService::finished,
|
2016-06-30 23:04:57 +03:00
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleFinished);
|
2011-07-07 10:43:59 +02:00
|
|
|
|
2011-09-16 11:33:48 +02:00
|
|
|
d->hasError = false;
|
2019-06-13 17:03:56 +02:00
|
|
|
d->deployService->start();
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
void AbstractRemoteLinuxDeployStep::doCancel()
|
2011-07-07 10:43:59 +02:00
|
|
|
{
|
2011-09-16 11:33:48 +02:00
|
|
|
if (d->hasError)
|
2011-07-07 10:43:59 +02:00
|
|
|
return;
|
|
|
|
|
|
2022-07-15 12:20:23 +02:00
|
|
|
emit addOutput(Tr::tr("User requests deployment to stop; cleaning up."),
|
2017-01-12 10:59:12 +01:00
|
|
|
OutputFormat::NormalMessage);
|
2011-09-16 11:33:48 +02:00
|
|
|
d->hasError = true;
|
2019-06-13 17:03:56 +02:00
|
|
|
d->deployService->stop();
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::handleProgressMessage(const QString &message)
|
|
|
|
|
{
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(message, OutputFormat::NormalMessage);
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::handleErrorMessage(const QString &message)
|
|
|
|
|
{
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(message, OutputFormat::ErrorMessage);
|
2020-04-16 13:53:05 +02:00
|
|
|
emit addTask(DeploymentTask(Task::Error, message), 1); // TODO correct?
|
2011-09-16 11:33:48 +02:00
|
|
|
d->hasError = true;
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-29 15:00:15 +02:00
|
|
|
void AbstractRemoteLinuxDeployStep::handleWarningMessage(const QString &message)
|
|
|
|
|
{
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(message, OutputFormat::ErrorMessage);
|
2020-04-16 13:53:05 +02:00
|
|
|
emit addTask(DeploymentTask(Task::Warning, message), 1); // TODO correct?
|
2011-09-29 15:00:15 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-07 10:43:59 +02:00
|
|
|
void AbstractRemoteLinuxDeployStep::handleFinished()
|
|
|
|
|
{
|
2011-09-16 11:33:48 +02:00
|
|
|
if (d->hasError)
|
2022-07-15 12:20:23 +02:00
|
|
|
emit addOutput(Tr::tr("Deploy step failed."), OutputFormat::ErrorMessage);
|
2011-07-07 10:43:59 +02:00
|
|
|
else
|
2022-07-15 12:20:23 +02:00
|
|
|
emit addOutput(Tr::tr("Deploy step finished."), OutputFormat::NormalMessage);
|
2019-06-13 17:03:56 +02:00
|
|
|
disconnect(d->deployService, nullptr, this, nullptr);
|
ProjectExplorer: Rework the build step run interface
Originally, the build manager used to run all build steps in a dedicated
thread. Communication between the step and the manager happened via a
QFutureInterface that was passed into the step's run() function.
Later, new steps were added that operated asynchronously, so the build
manager had to differentiate between the different kinds of steps for
starting and stopping.
These days, almost all build and deploy steps work asynchronously, which
made the QFuture-based interface look increasingly odd.
With this patch, all build steps are expected to work asynchronously, so
the build manager no longer needs to differentiate. Steps are started
and requested to stop via the run() and cancel() functions,
respectively, and emit the finished() signal when they are done. Build
step implementors no longer have to deal with a QFutureInterface. For
steps whose implementation is inherently synchronous, the BuildStep base
class offers a runInThread() function.
Change-Id: If905c68b234c5a669f6e19f43142eaa57d594803
Reviewed-by: hjk <hjk@qt.io>
2019-01-25 14:26:34 +01:00
|
|
|
emit finished(!d->hasError);
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::handleStdOutData(const QString &data)
|
|
|
|
|
{
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(data, OutputFormat::Stdout, DontAppendNewline);
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::handleStdErrData(const QString &data)
|
|
|
|
|
{
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(data, OutputFormat::Stderr, DontAppendNewline);
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace RemoteLinux
|