BuildStep: Some cleanup

Remove unused BuildStep API.
Remove outdated docs.
Cleanup includes.

Don't repeat custom cancel messages from build/deploy steps,
as in case of cancel action the follow-up message:
"Canceled build/deployment." always appears anyway.

Change-Id: I50b31e0cc688ee66d76a3a1dbe58eb72702112ad
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2023-07-17 14:25:34 +02:00
parent 42ed82973c
commit 77cee300f6
12 changed files with 9 additions and 134 deletions

View File

@@ -159,9 +159,6 @@ AndroidDeployQtStep::AndroidDeployQtStep(BuildStepList *parent, Id id)
bool AndroidDeployQtStep::init()
{
if (!BuildStep::init())
return false;
QtSupport::QtVersion *version = QtSupport::QtKitAspect::qtVersion(kit());
if (!version) {
reportWarningOrError(Tr::tr("The Qt version for kit %1 is invalid.").arg(kit()->displayName()),

View File

@@ -148,8 +148,6 @@ void IosDeployStep::updateDisplayNames()
bool IosDeployStep::init()
{
if (!BuildStep::init())
return false;
m_device = DeviceKitAspect::device(kit());
auto runConfig = qobject_cast<const IosRunConfiguration *>(
this->target()->activeRunConfiguration());

View File

@@ -50,8 +50,6 @@ private:
bool NimCompilerCleanStep::init()
{
if (!BuildStep::init())
return false;
const FilePath buildDir = buildDirectory();
const bool exists = buildDir.exists();
if (exists)

View File

@@ -143,9 +143,6 @@ void AbstractProcessStep::setWorkingDirectoryProvider(const std::function<FilePa
bool AbstractProcessStep::init()
{
if (!BuildStep::init())
return false;
if (!setupProcessParameters(processParameters()))
return false;

View File

@@ -10,17 +10,12 @@
#include "kitinformation.h"
#include "project.h"
#include "projectexplorerconstants.h"
#include "projectexplorertr.h"
#include "sanitizerparser.h"
#include "target.h"
#include <solutions/tasking/tasktree.h>
#include <utils/algorithm.h>
#include <utils/fileinprojectfinder.h>
#include <utils/layoutbuilder.h>
#include <utils/outputformatter.h>
#include <utils/qtcassert.h>
#include <utils/variablechooser.h>
/*!
@@ -41,9 +36,6 @@
\c init() is called in the GUI thread and can be used to query the
project for any information you need.
\c run() is run via Utils::asyncRun in a separate thread. If you need an
event loop, you need to create it yourself.
*/
/*!
@@ -53,26 +45,6 @@
that you need in the run() function.
*/
/*!
\fn void ProjectExplorer::BuildStep::run(QFutureInterface<bool> &fi)
Reimplement this function. It is called when the target is built.
By default, this function is NOT run in the GUI thread, but runs in its
own thread. If you need an event loop, you need to create one.
This function should block until the task is done
The absolute minimal implementation is:
\code
fi.reportResult(true);
\endcode
By returning \c true from runInGuiThread(), this function is called in
the GUI thread. Then the function should not block and instead the
finished() signal should be emitted.
\sa runInGuiThread()
*/
/*!
\fn BuildStepConfigWidget *ProjectExplorer::BuildStep::createConfigWidget()
@@ -93,11 +65,6 @@
It should be in plain text, with the format in the parameter.
*/
/*!
\fn void ProjectExplorer::BuildStep::finished()
This signal needs to be emitted if the build step runs in the GUI thread.
*/
/*!
\fn bool ProjectExplorer::BuildStep::isImmutable()
@@ -106,7 +73,6 @@
immutable steps are run. The default implementation returns \c false.
*/
using namespace Tasking;
using namespace Utils;
static const char buildStepEnabledKey[] = "ProjectExplorer.BuildStep.Enabled";
@@ -118,52 +84,8 @@ static QList<BuildStepFactory *> g_buildStepFactories;
BuildStep::BuildStep(BuildStepList *bsl, Id id)
: ProjectConfiguration(bsl, bsl->target(), id)
, m_stepList(bsl)
, m_cancelMessage(Tr::tr("The build step was ended forcefully."))
{
connect(this, &ProjectConfiguration::displayNameChanged,
this, &BuildStep::updateSummary);
// m_displayName = step->displayName();
// m_summaryText = "<b>" + m_displayName + "</b>";
}
BuildStep::~BuildStep()
{
emit finished(false);
}
bool BuildStep::init()
{
return !m_taskTree;
}
void BuildStep::run()
{
QTC_ASSERT(!m_taskTree, return);
m_taskTree.reset(new TaskTree({runRecipe()}));
connect(m_taskTree.get(), &TaskTree::progressValueChanged, this, [this](int value) {
emit progress(qRound(double(value) * 100 / std::max(m_taskTree->progressMaximum(), 1)), {});
});
connect(m_taskTree.get(), &TaskTree::done, this, [this] {
emit finished(true);
m_taskTree.release()->deleteLater();
});
connect(m_taskTree.get(), &TaskTree::errorOccurred, this, [this] {
emit finished(false);
m_taskTree.release()->deleteLater();
});
m_taskTree->start();
}
void BuildStep::cancel()
{
if (!m_taskTree)
return;
m_taskTree.reset();
if (!m_cancelMessage.isEmpty())
emit addOutput(m_cancelMessage, OutputFormat::ErrorMessage);
emit finished(false);
connect(this, &ProjectConfiguration::displayNameChanged, this, &BuildStep::updateSummary);
}
QWidget *BuildStep::doCreateConfigWidget()
@@ -319,11 +241,6 @@ QVariant BuildStep::data(Id id) const
return {};
}
void BuildStep::setCancelMessage(const QString &message)
{
m_cancelMessage = message;
}
void BuildStep::addMacroExpander()
{
m_addMacroExpander = true;

View File

@@ -3,35 +3,25 @@
#pragma once
#include "projectconfiguration.h"
#include "projectexplorer_export.h"
#include "buildconfiguration.h"
#include "projectexplorer_export.h"
#include "projectconfiguration.h"
#include <utils/qtcassert.h>
#include <QWidget>
#include <atomic>
#include <functional>
#include <memory>
#include <optional>
namespace Utils {
class Environment;
class FilePath;
class MacroExpander;
class OutputFormatter;
} // Utils
namespace Tasking {
class GroupItem;
class TaskTree;
}
namespace Tasking { class GroupItem; }
namespace ProjectExplorer {
class BuildConfiguration;
class BuildStepFactory;
class BuildStepList;
class BuildSystem;
@@ -48,10 +38,7 @@ protected:
explicit BuildStep(BuildStepList *bsl, Utils::Id id);
public:
~BuildStep() override;
virtual bool init();
void run();
void cancel();
virtual bool init() = 0;
void fromMap(const QVariantMap &map) override;
void toMap(QVariantMap &map) const override;
@@ -114,20 +101,18 @@ signals:
/// Do note that for linking compile output with tasks, you should first emit the output
/// and then emit the task. \p linkedOutput lines will be linked. And the last \p skipLines will
/// be skipped.
void addTask(const ProjectExplorer::Task &task, int linkedOutputLines = 0, int skipLines = 0);
void addTask(const Task &task, int linkedOutputLines = 0, int skipLines = 0);
/// Adds \p string to the compile output view, formatted in \p format
void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format,
ProjectExplorer::BuildStep::OutputNewlineSetting newlineSetting = DoAppendNewline);
void addOutput(const QString &string, OutputFormat format,
OutputNewlineSetting newlineSetting = DoAppendNewline);
void enabledChanged();
void progress(int percentage, const QString &message);
void finished(bool result);
protected:
virtual QWidget *createConfigWidget();
void setCancelMessage(const QString &message);
private:
friend class BuildManager;
@@ -140,10 +125,8 @@ private:
bool m_addMacroExpander = false;
std::optional<bool> m_wasExpanded;
std::function<QString()> m_summaryUpdater;
std::unique_ptr<Tasking::TaskTree> m_taskTree;
QString m_summaryText;
QString m_cancelMessage;
};
class PROJECTEXPLORER_EXPORT BuildStepFactory

View File

@@ -35,8 +35,6 @@ public:
protected:
bool init() final
{
if (!BuildStep::init())
return false;
m_source = m_sourceAspect();
m_target = m_targetAspect();
return m_source.exists();

View File

@@ -27,9 +27,6 @@ public:
bool init() override
{
if (!BuildStep::init())
return false;
IDevice::ConstPtr device = DeviceKitAspect::device(kit());
if (device)
return true;

View File

@@ -273,9 +273,6 @@ QbsBuildStep::QbsBuildStep(BuildStepList *bsl, Id id) :
bool QbsBuildStep::init()
{
if (!BuildStep::init())
return false;
auto bc = static_cast<QbsBuildConfiguration *>(buildConfiguration());
if (!bc)

View File

@@ -52,8 +52,6 @@ QbsCleanStep::QbsCleanStep(BuildStepList *bsl, Id id)
bool QbsCleanStep::init()
{
if (!BuildStep::init())
return false;
if (buildSystem()->isParsing())
return false;
const auto bc = static_cast<QbsBuildConfiguration *>(buildConfiguration());

View File

@@ -50,8 +50,6 @@ QbsInstallStep::QbsInstallStep(BuildStepList *bsl, Id id)
bool QbsInstallStep::init()
{
if (!BuildStep::init())
return false;
QTC_ASSERT(!target()->buildSystem()->isParsing(), return false);
return true;
}

View File

@@ -38,7 +38,6 @@ using namespace Internal;
AbstractRemoteLinuxDeployStep::AbstractRemoteLinuxDeployStep(BuildStepList *bsl, Id id)
: BuildStep(bsl, id), d(new AbstractRemoteLinuxDeployStepPrivate)
{
setCancelMessage(Tr::tr("User requests deployment to stop; cleaning up."));
}
AbstractRemoteLinuxDeployStep::~AbstractRemoteLinuxDeployStep()
@@ -99,8 +98,6 @@ void AbstractRemoteLinuxDeployStep::toMap(QVariantMap &map) const
bool AbstractRemoteLinuxDeployStep::init()
{
QTC_ASSERT(d->internalInit, return false);
if (!BuildStep::init())
return false;
const auto canDeploy = d->internalInit();
if (!canDeploy) {
emit addOutput(Tr::tr("Cannot deploy: %1").arg(canDeploy.error()),