forked from qt-creator/qt-creator
Nim: Simplify NimbleBuildStep implementation a bit
Change-Id: Ifc5a2bee0ac2fc2e9e7d5a474c0453ec49ae733f Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -26,19 +26,13 @@
|
|||||||
#include "nimblebuildstep.h"
|
#include "nimblebuildstep.h"
|
||||||
|
|
||||||
#include "nimconstants.h"
|
#include "nimconstants.h"
|
||||||
#include "nimbleproject.h"
|
|
||||||
#include "nimbuildsystem.h"
|
#include "nimbuildsystem.h"
|
||||||
#include "nimoutputtaskparser.h"
|
#include "nimoutputtaskparser.h"
|
||||||
#include "nimtoolchain.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/ioutputparser.h>
|
|
||||||
#include <projectexplorer/processparameters.h>
|
#include <projectexplorer/processparameters.h>
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/runconfigurationaspects.h>
|
#include <projectexplorer/runconfigurationaspects.h>
|
||||||
#include <projectexplorer/target.h>
|
|
||||||
|
|
||||||
#include <QRegularExpression>
|
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -48,6 +42,7 @@ namespace Nim {
|
|||||||
class NimbleBuildStep : public AbstractProcessStep
|
class NimbleBuildStep : public AbstractProcessStep
|
||||||
{
|
{
|
||||||
Q_DECLARE_TR_FUNCTIONS(Nim::NimbleBuilStep)
|
Q_DECLARE_TR_FUNCTIONS(Nim::NimbleBuilStep)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NimbleBuildStep(BuildStepList *parentList, Id id);
|
NimbleBuildStep(BuildStepList *parentList, Id id);
|
||||||
|
|
||||||
@@ -55,22 +50,19 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString defaultArguments() const;
|
QString defaultArguments() const;
|
||||||
void onArgumentsChanged();
|
|
||||||
|
|
||||||
ArgumentsAspect *m_arguments;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NimbleBuildStep::NimbleBuildStep(BuildStepList *parentList, Id id)
|
NimbleBuildStep::NimbleBuildStep(BuildStepList *parentList, Id id)
|
||||||
: AbstractProcessStep(parentList, id)
|
: AbstractProcessStep(parentList, id)
|
||||||
{
|
{
|
||||||
m_arguments = addAspect<ArgumentsAspect>();
|
auto arguments = addAspect<ArgumentsAspect>();
|
||||||
m_arguments->setSettingsKey(Constants::C_NIMBLEBUILDSTEP_ARGUMENTS);
|
arguments->setSettingsKey(Constants::C_NIMBLEBUILDSTEP_ARGUMENTS);
|
||||||
m_arguments->setResetter([this] { return defaultArguments(); });
|
arguments->setResetter([this] { return defaultArguments(); });
|
||||||
m_arguments->setArguments(defaultArguments());
|
arguments->setArguments(defaultArguments());
|
||||||
|
|
||||||
setCommandLineProvider([this] {
|
setCommandLineProvider([this, arguments] {
|
||||||
return CommandLine(Nim::nimblePathFromKit(kit()),
|
return CommandLine(Nim::nimblePathFromKit(kit()),
|
||||||
{"build", m_arguments->arguments(macroExpander())});
|
{"build", arguments->arguments(macroExpander())});
|
||||||
});
|
});
|
||||||
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });
|
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });
|
||||||
setEnvironmentModifier([this](Environment &env) {
|
setEnvironmentModifier([this](Environment &env) {
|
||||||
@@ -85,9 +77,9 @@ NimbleBuildStep::NimbleBuildStep(BuildStepList *parentList, Id id)
|
|||||||
|
|
||||||
QTC_ASSERT(buildConfiguration(), return);
|
QTC_ASSERT(buildConfiguration(), return);
|
||||||
QObject::connect(buildConfiguration(), &BuildConfiguration::buildTypeChanged,
|
QObject::connect(buildConfiguration(), &BuildConfiguration::buildTypeChanged,
|
||||||
m_arguments, &ArgumentsAspect::resetArguments);
|
arguments, &ArgumentsAspect::resetArguments);
|
||||||
QObject::connect(m_arguments, &ArgumentsAspect::changed,
|
QObject::connect(arguments, &ArgumentsAspect::changed,
|
||||||
this, &NimbleBuildStep::onArgumentsChanged);
|
this, &AbstractProcessStep::updateSummary);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NimbleBuildStep::setupOutputFormatter(OutputFormatter *formatter)
|
void NimbleBuildStep::setupOutputFormatter(OutputFormatter *formatter)
|
||||||
@@ -100,22 +92,9 @@ void NimbleBuildStep::setupOutputFormatter(OutputFormatter *formatter)
|
|||||||
|
|
||||||
QString NimbleBuildStep::defaultArguments() const
|
QString NimbleBuildStep::defaultArguments() const
|
||||||
{
|
{
|
||||||
switch (buildType()) {
|
if (buildType() == BuildConfiguration::Debug)
|
||||||
case BuildConfiguration::Debug:
|
|
||||||
return {"--debugger:native"};
|
return {"--debugger:native"};
|
||||||
case BuildConfiguration::Unknown:
|
return {};
|
||||||
case BuildConfiguration::Profile:
|
|
||||||
case BuildConfiguration::Release:
|
|
||||||
default:
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NimbleBuildStep::onArgumentsChanged()
|
|
||||||
{
|
|
||||||
ProcessParameters *params = processParameters();
|
|
||||||
params->setCommandLine({Nim::nimblePathFromKit(kit()),
|
|
||||||
{"build", m_arguments->arguments(macroExpander())}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NimbleBuildStepFactory::NimbleBuildStepFactory()
|
NimbleBuildStepFactory::NimbleBuildStepFactory()
|
||||||
|
Reference in New Issue
Block a user