forked from qt-creator/qt-creator
QbsInstallStep: Employ task tree for running
Task-number: QTCREATORBUG-29168 Change-Id: I0fa0face3bcc567b8e29db2b23b2a48364252fed Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -3,16 +3,12 @@
|
|||||||
|
|
||||||
#include "qbsinstallstep.h"
|
#include "qbsinstallstep.h"
|
||||||
|
|
||||||
#include "qbsbuildconfiguration.h"
|
|
||||||
#include "qbsbuildstep.h"
|
#include "qbsbuildstep.h"
|
||||||
#include "qbsproject.h"
|
|
||||||
#include "qbsprojectmanagerconstants.h"
|
#include "qbsprojectmanagerconstants.h"
|
||||||
#include "qbsprojectmanagertr.h"
|
#include "qbsprojectmanagertr.h"
|
||||||
|
#include "qbsrequest.h"
|
||||||
#include "qbssession.h"
|
#include "qbssession.h"
|
||||||
|
|
||||||
#include <projectexplorer/buildsteplist.h>
|
|
||||||
#include <projectexplorer/deployconfiguration.h>
|
|
||||||
#include <projectexplorer/kit.h>
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
@@ -24,10 +20,10 @@
|
|||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Tasking;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace QbsProjectManager {
|
namespace QbsProjectManager::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// QbsInstallStep:
|
// QbsInstallStep:
|
||||||
@@ -50,44 +46,44 @@ QbsInstallStep::QbsInstallStep(BuildStepList *bsl, Id id)
|
|||||||
cleanInstallRoot.setLabel(Tr::tr("Remove first"), labelPlacement);
|
cleanInstallRoot.setLabel(Tr::tr("Remove first"), labelPlacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
QbsInstallStep::~QbsInstallStep()
|
|
||||||
{
|
|
||||||
doCancel();
|
|
||||||
if (m_session)
|
|
||||||
m_session->disconnect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool QbsInstallStep::init()
|
bool QbsInstallStep::init()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!target()->buildSystem()->isParsing() && !m_session, return false);
|
if (!BuildStep::init())
|
||||||
|
return false;
|
||||||
|
QTC_ASSERT(!target()->buildSystem()->isParsing(), return false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsInstallStep::doRun()
|
GroupItem QbsInstallStep::runRecipe()
|
||||||
{
|
{
|
||||||
m_session = static_cast<QbsBuildSystem *>(target()->buildSystem())->session();
|
const auto onSetup = [this](QbsRequest &request) {
|
||||||
|
QbsSession *session = static_cast<QbsBuildSystem*>(buildSystem())->session();
|
||||||
|
if (!session) {
|
||||||
|
emit addOutput(Tr::tr("No qbs session exists for this target."),
|
||||||
|
OutputFormat::ErrorMessage);
|
||||||
|
return SetupResult::StopWithError;
|
||||||
|
}
|
||||||
|
QJsonObject requestData;
|
||||||
|
requestData.insert("type", "install-project");
|
||||||
|
requestData.insert("install-root", installRoot().path());
|
||||||
|
requestData.insert("clean-install-root", cleanInstallRoot());
|
||||||
|
requestData.insert("keep-going", keepGoing());
|
||||||
|
requestData.insert("dry-run", dryRun());
|
||||||
|
|
||||||
QJsonObject request;
|
request.setSession(session);
|
||||||
request.insert("type", "install-project");
|
request.setRequestData(requestData);
|
||||||
request.insert("install-root", installRoot().path());
|
connect(&request, &QbsRequest::progressChanged, this, &BuildStep::progress);
|
||||||
request.insert("clean-install-root", cleanInstallRoot());
|
connect(&request, &QbsRequest::outputAdded, this,
|
||||||
request.insert("keep-going", keepGoing());
|
[this](const QString &output, OutputFormat format) {
|
||||||
request.insert("dry-run", dryRun());
|
emit addOutput(output, format);
|
||||||
m_session->sendRequest(request);
|
|
||||||
|
|
||||||
m_maxProgress = 0;
|
|
||||||
connect(m_session, &QbsSession::projectInstalled, this, &QbsInstallStep::installDone);
|
|
||||||
connect(m_session, &QbsSession::taskStarted, this, &QbsInstallStep::handleTaskStarted);
|
|
||||||
connect(m_session, &QbsSession::taskProgress, this, &QbsInstallStep::handleProgress);
|
|
||||||
connect(m_session, &QbsSession::errorOccurred, this, [this] {
|
|
||||||
installDone(ErrorInfo(Tr::tr("Installing canceled: Qbs session failed.")));
|
|
||||||
});
|
});
|
||||||
}
|
connect(&request, &QbsRequest::taskAdded, this, [this](const Task &task) {
|
||||||
|
emit addTask(task, 1);
|
||||||
|
});
|
||||||
|
return SetupResult::Continue;
|
||||||
|
};
|
||||||
|
|
||||||
void QbsInstallStep::doCancel()
|
return QbsRequestTask(onSetup);
|
||||||
{
|
|
||||||
if (m_session)
|
|
||||||
m_session->cancelCurrentJob();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath QbsInstallStep::installRoot() const
|
FilePath QbsInstallStep::installRoot() const
|
||||||
@@ -101,36 +97,6 @@ const QbsBuildConfiguration *QbsInstallStep::buildConfig() const
|
|||||||
return static_cast<QbsBuildConfiguration *>(target()->activeBuildConfiguration());
|
return static_cast<QbsBuildConfiguration *>(target()->activeBuildConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
void QbsInstallStep::installDone(const ErrorInfo &error)
|
|
||||||
{
|
|
||||||
m_session->disconnect(this);
|
|
||||||
m_session = nullptr;
|
|
||||||
|
|
||||||
for (const ErrorInfoItem &item : error.items)
|
|
||||||
createTaskAndOutput(Task::Error, item.description, item.filePath, item.line);
|
|
||||||
|
|
||||||
emit finished(!error.hasError());
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsInstallStep::handleTaskStarted(const QString &desciption, int max)
|
|
||||||
{
|
|
||||||
m_description = desciption;
|
|
||||||
m_maxProgress = max;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsInstallStep::handleProgress(int value)
|
|
||||||
{
|
|
||||||
if (m_maxProgress > 0)
|
|
||||||
emit progress(value * 100 / m_maxProgress, m_description);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QbsInstallStep::createTaskAndOutput(Task::TaskType type, const QString &message,
|
|
||||||
const FilePath &file, int line)
|
|
||||||
{
|
|
||||||
emit addOutput(message, OutputFormat::Stdout);
|
|
||||||
emit addTask(CompileTask(type, message, file, line), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QbsBuildStepData QbsInstallStep::stepData() const
|
QbsBuildStepData QbsInstallStep::stepData() const
|
||||||
{
|
{
|
||||||
QbsBuildStepData data;
|
QbsBuildStepData data;
|
||||||
@@ -202,5 +168,4 @@ QbsInstallStepFactory::QbsInstallStepFactory()
|
|||||||
setDisplayName(Tr::tr("Qbs Install"));
|
setDisplayName(Tr::tr("Qbs Install"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace QbsProjectManager::Internal
|
||||||
} // namespace QbsProjectManager
|
|
||||||
|
@@ -3,19 +3,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "qbsbuildconfiguration.h"
|
|
||||||
#include "qbssession.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/buildstep.h>
|
#include <projectexplorer/buildstep.h>
|
||||||
#include <projectexplorer/task.h>
|
|
||||||
|
|
||||||
#include <utils/aspects.h>
|
namespace QbsProjectManager::Internal {
|
||||||
|
|
||||||
namespace QbsProjectManager {
|
class QbsBuildConfiguration;
|
||||||
namespace Internal {
|
class QbsBuildStepData;
|
||||||
|
|
||||||
class ErrorInfo;
|
|
||||||
class QbsSession;
|
|
||||||
|
|
||||||
class QbsInstallStep final : public ProjectExplorer::BuildStep
|
class QbsInstallStep final : public ProjectExplorer::BuildStep
|
||||||
{
|
{
|
||||||
@@ -23,33 +16,21 @@ class QbsInstallStep final : public ProjectExplorer::BuildStep
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
QbsInstallStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id);
|
QbsInstallStep(ProjectExplorer::BuildStepList *bsl, Utils::Id id);
|
||||||
~QbsInstallStep() override;
|
|
||||||
|
|
||||||
Utils::FilePath installRoot() const;
|
Utils::FilePath installRoot() const;
|
||||||
QbsBuildStepData stepData() const;
|
QbsBuildStepData stepData() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool init() override;
|
bool init() override;
|
||||||
void doRun() override;
|
Tasking::GroupItem runRecipe() final;
|
||||||
void doCancel() override;
|
|
||||||
QWidget *createConfigWidget() override;
|
QWidget *createConfigWidget() override;
|
||||||
|
|
||||||
const QbsBuildConfiguration *buildConfig() const;
|
const QbsBuildConfiguration *buildConfig() const;
|
||||||
void installDone(const ErrorInfo &error);
|
|
||||||
void handleTaskStarted(const QString &desciption, int max);
|
|
||||||
void handleProgress(int value);
|
|
||||||
|
|
||||||
void createTaskAndOutput(ProjectExplorer::Task::TaskType type,
|
|
||||||
const QString &message, const Utils::FilePath &file, int line);
|
|
||||||
|
|
||||||
Utils::BoolAspect cleanInstallRoot{this};
|
Utils::BoolAspect cleanInstallRoot{this};
|
||||||
Utils::BoolAspect dryRun{this};
|
Utils::BoolAspect dryRun{this};
|
||||||
Utils::BoolAspect keepGoing{this};
|
Utils::BoolAspect keepGoing{this};
|
||||||
|
|
||||||
QbsSession *m_session = nullptr;
|
|
||||||
QString m_description;
|
|
||||||
int m_maxProgress;
|
|
||||||
|
|
||||||
friend class QbsInstallStepConfigWidget;
|
friend class QbsInstallStepConfigWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,5 +40,4 @@ public:
|
|||||||
QbsInstallStepFactory();
|
QbsInstallStepFactory();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace QbsProjectManager::Internal
|
||||||
} // namespace QbsProjectManager
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include "qbsproject.h"
|
#include "qbsproject.h"
|
||||||
#include "qbsprojectmanagerconstants.h"
|
#include "qbsprojectmanagerconstants.h"
|
||||||
#include "qbsprojectmanagertr.h"
|
#include "qbsprojectmanagertr.h"
|
||||||
|
#include "qbssession.h"
|
||||||
#include "qbssettings.h"
|
#include "qbssettings.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
|
Reference in New Issue
Block a user