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"
|
2011-07-15 16:57:25 +02:00
|
|
|
#include "remotelinuxdeployconfiguration.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;
|
|
|
|
|
QFutureInterface<bool> future;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
|
2014-07-01 11:08:26 +02:00
|
|
|
AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl, Core::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
|
|
|
{
|
2018-10-22 19:11:59 +02:00
|
|
|
setRunInGuiThread(true);
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
2012-07-13 12:44:01 +02:00
|
|
|
AbstractRemoteLinuxDeployStep::~AbstractRemoteLinuxDeployStep()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-07 10:43:59 +02:00
|
|
|
bool AbstractRemoteLinuxDeployStep::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
if (!BuildStep::fromMap(map))
|
|
|
|
|
return false;
|
|
|
|
|
deployService()->importDeployTimes(map);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AbstractRemoteLinuxDeployStep::toMap() const
|
|
|
|
|
{
|
|
|
|
|
return BuildStep::toMap().unite(deployService()->exportDeployTimes());
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-10 15:31:44 +01:00
|
|
|
bool AbstractRemoteLinuxDeployStep::init()
|
2011-07-07 10:43:59 +02:00
|
|
|
{
|
2011-09-22 17:37:05 +02:00
|
|
|
QString error;
|
2012-12-06 19:21:19 +01:00
|
|
|
deployService()->setTarget(target());
|
2011-11-23 11:55:38 +01:00
|
|
|
const bool canDeploy = initInternal(&error);
|
2011-09-22 17:37:05 +02:00
|
|
|
if (!canDeploy)
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Cannot deploy: %1").arg(error), OutputFormat::ErrorMessage);
|
2011-09-22 17:37:05 +02:00
|
|
|
return canDeploy;
|
2011-07-07 10:43:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::run(QFutureInterface<bool> &fi)
|
|
|
|
|
{
|
2016-06-30 23:04:57 +03:00
|
|
|
connect(deployService(), &AbstractRemoteLinuxDeployService::errorMessage,
|
|
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleErrorMessage);
|
|
|
|
|
connect(deployService(), &AbstractRemoteLinuxDeployService::progressMessage,
|
|
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleProgressMessage);
|
|
|
|
|
connect(deployService(), &AbstractRemoteLinuxDeployService::warningMessage,
|
|
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleWarningMessage);
|
|
|
|
|
connect(deployService(), &AbstractRemoteLinuxDeployService::stdOutData,
|
|
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleStdOutData);
|
|
|
|
|
connect(deployService(), &AbstractRemoteLinuxDeployService::stdErrData,
|
|
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleStdErrData);
|
|
|
|
|
connect(deployService(), &AbstractRemoteLinuxDeployService::finished,
|
|
|
|
|
this, &AbstractRemoteLinuxDeployStep::handleFinished);
|
2011-07-07 10:43:59 +02:00
|
|
|
|
2011-09-16 11:33:48 +02:00
|
|
|
d->hasError = false;
|
|
|
|
|
d->future = fi;
|
2011-07-07 10:43:59 +02:00
|
|
|
deployService()->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AbstractRemoteLinuxDeployStep::cancel()
|
|
|
|
|
{
|
2011-09-16 11:33:48 +02:00
|
|
|
if (d->hasError)
|
2011-07-07 10:43:59 +02:00
|
|
|
return;
|
|
|
|
|
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("User requests deployment to stop; cleaning up."),
|
|
|
|
|
OutputFormat::NormalMessage);
|
2011-09-16 11:33:48 +02:00
|
|
|
d->hasError = true;
|
2011-07-07 10:43:59 +02:00
|
|
|
deployService()->stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2015-04-20 17:13:45 +02:00
|
|
|
ProjectExplorer::Task task = Task(Task::Error, message, Utils::FileName(), -1,
|
|
|
|
|
Constants::TASK_CATEGORY_DEPLOYMENT);
|
|
|
|
|
emit addTask(task, 1); // TODO correct?
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(message, OutputFormat::ErrorMessage);
|
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)
|
|
|
|
|
{
|
2015-04-20 17:13:45 +02:00
|
|
|
ProjectExplorer::Task task = Task(Task::Warning, message, Utils::FileName(), -1,
|
|
|
|
|
Constants::TASK_CATEGORY_DEPLOYMENT);
|
|
|
|
|
emit addTask(task, 1); // TODO correct?
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(message, OutputFormat::ErrorMessage);
|
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)
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Deploy step failed."), OutputFormat::ErrorMessage);
|
2011-07-07 10:43:59 +02:00
|
|
|
else
|
2017-01-12 10:59:12 +01:00
|
|
|
emit addOutput(tr("Deploy step finished."), OutputFormat::NormalMessage);
|
2018-11-24 17:06:01 +01:00
|
|
|
disconnect(deployService(), nullptr, this, nullptr);
|
2016-04-20 12:49:25 +02:00
|
|
|
reportRunResult(d->future, !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
|