forked from qt-creator/qt-creator
Nim: Aspectify NimbleBuildStep
Change-Id: I0f166e68590901568edfd590606df57e25111b9a Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -10,7 +10,6 @@ add_qtc_plugin(Nim
|
||||
nimconstants.h
|
||||
nimplugin.cpp nimplugin.h
|
||||
project/nimblebuildstep.h project/nimblebuildstep.cpp
|
||||
project/nimblebuildstepwidget.h project/nimblebuildstepwidget.cpp project/nimblebuildstepwidget.ui
|
||||
project/nimbleproject.h project/nimbleproject.cpp
|
||||
project/nimblerunconfiguration.h project/nimblerunconfiguration.cpp
|
||||
project/nimbletaskstep.h project/nimbletaskstep.cpp
|
||||
|
@@ -17,7 +17,6 @@ HEADERS += \
|
||||
editor/nimtexteditorwidget.h \
|
||||
project/nimblebuildconfiguration.h \
|
||||
project/nimblebuildstep.h \
|
||||
project/nimblebuildstepwidget.h \
|
||||
project/nimbleproject.h \
|
||||
project/nimblerunconfiguration.h \
|
||||
project/nimbletaskstep.h \
|
||||
@@ -58,7 +57,6 @@ SOURCES += \
|
||||
project/nimblebuildconfiguration.cpp \
|
||||
project/nimblebuildstep.cpp \
|
||||
project/nimbletaskstep.cpp \
|
||||
project/nimblebuildstepwidget.cpp \
|
||||
project/nimbleproject.cpp \
|
||||
project/nimblerunconfiguration.cpp \
|
||||
project/nimbletaskstepwidget.cpp \
|
||||
@@ -87,7 +85,6 @@ SOURCES += \
|
||||
suggest/server.cpp
|
||||
|
||||
FORMS += \
|
||||
project/nimblebuildstepwidget.ui \
|
||||
project/nimbletaskstepwidget.ui \
|
||||
project/nimcompilerbuildstepconfigwidget.ui \
|
||||
settings/nimcodestylepreferenceswidget.ui \
|
||||
|
@@ -48,7 +48,6 @@ QtcPlugin {
|
||||
"nimtoolchain.h", "nimtoolchain.cpp",
|
||||
"nimtoolchainfactory.h", "nimtoolchainfactory.cpp",
|
||||
"nimblebuildstep.h", "nimblebuildstep.cpp",
|
||||
"nimblebuildstepwidget.h", "nimblebuildstepwidget.cpp", "nimblebuildstepwidget.ui",
|
||||
"nimbleproject.h", "nimbleproject.cpp",
|
||||
"nimblerunconfiguration.h", "nimblerunconfiguration.cpp",
|
||||
"nimbletaskstep.h", "nimbletaskstep.cpp",
|
||||
|
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "nimblebuildstep.h"
|
||||
#include "nimblebuildstepwidget.h"
|
||||
#include "nimbletaskstepwidget.h"
|
||||
#include "nimconstants.h"
|
||||
#include "nimbleproject.h"
|
||||
@@ -33,15 +32,15 @@
|
||||
#include <projectexplorer/ioutputparser.h>
|
||||
#include <projectexplorer/processparameters.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/runconfigurationaspects.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
|
||||
using namespace Nim;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace {
|
||||
namespace Nim {
|
||||
|
||||
class NimParser : public OutputTaskParser
|
||||
{
|
||||
@@ -80,26 +79,47 @@ class NimParser : public OutputTaskParser
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
class NimbleBuildStep : public AbstractProcessStep
|
||||
{
|
||||
public:
|
||||
NimbleBuildStep(BuildStepList *parentList, Id id);
|
||||
|
||||
NimbleBuildStep::NimbleBuildStep(BuildStepList *parentList, Utils::Id id)
|
||||
bool init() final;
|
||||
void setupOutputFormatter(OutputFormatter *formatter) final;
|
||||
|
||||
private:
|
||||
QString defaultArguments() const;
|
||||
void onArgumentsChanged();
|
||||
|
||||
ArgumentsAspect *m_arguments;
|
||||
};
|
||||
|
||||
NimbleBuildStep::NimbleBuildStep(BuildStepList *parentList, Id id)
|
||||
: AbstractProcessStep(parentList, id)
|
||||
{
|
||||
setDefaultDisplayName(tr(Constants::C_NIMBLEBUILDSTEP_DISPLAY));
|
||||
setDisplayName(tr(Constants::C_NIMBLEBUILDSTEP_DISPLAY));
|
||||
|
||||
m_arguments = addAspect<ArgumentsAspect>();
|
||||
m_arguments->setSettingsKey(Constants::C_NIMBLEBUILDSTEP_ARGUMENTS);
|
||||
m_arguments->setResetter([this] { return defaultArguments(); });
|
||||
|
||||
QTC_ASSERT(buildConfiguration(), return);
|
||||
QObject::connect(buildConfiguration(), &BuildConfiguration::buildTypeChanged, this, &NimbleBuildStep::resetArguments);
|
||||
QObject::connect(this, &NimbleBuildStep::argumentsChanged, this, &NimbleBuildStep::onArgumentsChanged);
|
||||
resetArguments();
|
||||
QObject::connect(buildConfiguration(), &BuildConfiguration::buildTypeChanged,
|
||||
m_arguments, &ArgumentsAspect::resetArguments);
|
||||
QObject::connect(m_arguments, &ArgumentsAspect::argumentsChanged,
|
||||
this, &NimbleBuildStep::onArgumentsChanged);
|
||||
}
|
||||
|
||||
bool NimbleBuildStep::init()
|
||||
{
|
||||
ProcessParameters* params = processParameters();
|
||||
m_arguments->setArguments(defaultArguments());
|
||||
ProcessParameters *params = processParameters();
|
||||
params->setEnvironment(buildEnvironment());
|
||||
params->setMacroExpander(macroExpander());
|
||||
params->setWorkingDirectory(project()->projectDirectory());
|
||||
params->setCommandLine({QStandardPaths::findExecutable("nimble"), {"build", m_arguments}});
|
||||
params->setCommandLine({QStandardPaths::findExecutable("nimble"),
|
||||
{"build", m_arguments->arguments(macroExpander())}});
|
||||
return AbstractProcessStep::init();
|
||||
}
|
||||
|
||||
@@ -111,42 +131,6 @@ void NimbleBuildStep::setupOutputFormatter(OutputFormatter *formatter)
|
||||
AbstractProcessStep::setupOutputFormatter(formatter);
|
||||
}
|
||||
|
||||
BuildStepConfigWidget *NimbleBuildStep::createConfigWidget()
|
||||
{
|
||||
return new NimbleBuildStepWidget(this);
|
||||
}
|
||||
|
||||
QString NimbleBuildStep::arguments() const
|
||||
{
|
||||
return m_arguments;
|
||||
}
|
||||
|
||||
void NimbleBuildStep::setArguments(const QString &args)
|
||||
{
|
||||
if (m_arguments == args)
|
||||
return;
|
||||
m_arguments = args;
|
||||
emit argumentsChanged(args);
|
||||
}
|
||||
|
||||
void NimbleBuildStep::resetArguments()
|
||||
{
|
||||
setArguments(defaultArguments());
|
||||
}
|
||||
|
||||
bool NimbleBuildStep::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_arguments = map.value(Constants::C_NIMBLEBUILDSTEP_ARGUMENTS, defaultArguments()).toString();
|
||||
return AbstractProcessStep::fromMap(map);
|
||||
}
|
||||
|
||||
QVariantMap NimbleBuildStep::toMap() const
|
||||
{
|
||||
auto map = AbstractProcessStep::toMap();
|
||||
map[Constants::C_NIMBLEBUILDSTEP_ARGUMENTS] = m_arguments;
|
||||
return map;
|
||||
}
|
||||
|
||||
QString NimbleBuildStep::defaultArguments() const
|
||||
{
|
||||
switch (buildType()) {
|
||||
@@ -162,8 +146,9 @@ QString NimbleBuildStep::defaultArguments() const
|
||||
|
||||
void NimbleBuildStep::onArgumentsChanged()
|
||||
{
|
||||
ProcessParameters* params = processParameters();
|
||||
params->setCommandLine({QStandardPaths::findExecutable("nimble"), {"build", m_arguments}});
|
||||
ProcessParameters *params = processParameters();
|
||||
params->setCommandLine({QStandardPaths::findExecutable("nimble"),
|
||||
{"build", m_arguments->arguments(macroExpander())}});
|
||||
}
|
||||
|
||||
NimbleBuildStepFactory::NimbleBuildStepFactory()
|
||||
@@ -174,3 +159,5 @@ NimbleBuildStepFactory::NimbleBuildStepFactory()
|
||||
setSupportedConfiguration(Constants::C_NIMBLEBUILDCONFIGURATION_ID);
|
||||
setRepeatable(true);
|
||||
}
|
||||
|
||||
} // Nim
|
||||
|
@@ -29,42 +29,10 @@
|
||||
|
||||
namespace Nim {
|
||||
|
||||
class NimbleBuildStep : public ProjectExplorer::AbstractProcessStep
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NimbleBuildStep(ProjectExplorer::BuildStepList *parentList, Utils::Id id);
|
||||
|
||||
bool init() override;
|
||||
void setupOutputFormatter(Utils::OutputFormatter *formatter) override;
|
||||
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
|
||||
|
||||
QString arguments() const;
|
||||
|
||||
void setArguments(const QString &args);
|
||||
|
||||
void resetArguments();
|
||||
|
||||
bool fromMap(const QVariantMap &map) override;
|
||||
|
||||
QVariantMap toMap() const override;
|
||||
|
||||
signals:
|
||||
void argumentsChanged(const QString &args);
|
||||
|
||||
private:
|
||||
QString defaultArguments() const;
|
||||
|
||||
void onArgumentsChanged();
|
||||
|
||||
QString m_arguments;
|
||||
};
|
||||
|
||||
class NimbleBuildStepFactory : public ProjectExplorer::BuildStepFactory
|
||||
class NimbleBuildStepFactory final : public ProjectExplorer::BuildStepFactory
|
||||
{
|
||||
public:
|
||||
NimbleBuildStepFactory();
|
||||
};
|
||||
|
||||
}
|
||||
} // Nim
|
||||
|
@@ -1,58 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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
|
||||
** 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.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "nimblebuildstepwidget.h"
|
||||
#include "ui_nimblebuildstepwidget.h"
|
||||
|
||||
#include "nimblebuildstep.h"
|
||||
#include "nimbleproject.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
|
||||
using namespace Nim;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
NimbleBuildStepWidget::NimbleBuildStepWidget(NimbleBuildStep *bs)
|
||||
: BuildStepConfigWidget(bs)
|
||||
, ui(new Ui::NimbleBuildStepWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->argumentsLineEdit->setText(bs->arguments());
|
||||
QObject::connect(bs, &NimbleBuildStep::argumentsChanged, ui->argumentsLineEdit, &QLineEdit::setText);
|
||||
QObject::connect(ui->argumentsLineEdit, &QLineEdit::textEdited, bs, &NimbleBuildStep::setArguments);
|
||||
|
||||
ui->resetButton->setIcon(Utils::Icons::RESET.icon());
|
||||
QObject::connect(ui->resetButton, &QToolButton::clicked, bs, &NimbleBuildStep::resetArguments);
|
||||
}
|
||||
|
||||
NimbleBuildStepWidget::~NimbleBuildStepWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) Filippo Cucchetto <filippocucchetto@gmail.com>
|
||||
** Contact: http://www.qt.io/licensing
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** 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
|
||||
** 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.
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
|
||||
namespace Nim {
|
||||
|
||||
class NimbleBuildStep;
|
||||
|
||||
namespace Ui { class NimbleBuildStepWidget; }
|
||||
|
||||
class NimbleBuildStepWidget : public ProjectExplorer::BuildStepConfigWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NimbleBuildStepWidget(NimbleBuildStep *bs);
|
||||
|
||||
~NimbleBuildStepWidget();
|
||||
|
||||
private:
|
||||
Ui::NimbleBuildStepWidget *ui;
|
||||
};
|
||||
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Nim::NimbleBuildStepWidget</class>
|
||||
<widget class="QWidget" name="Nim::NimbleBuildStepWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="argumentsLabel">
|
||||
<property name="text">
|
||||
<string>Arguments:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="argumentsLineEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="resetButton">
|
||||
<property name="toolTip">
|
||||
<string>Reset to Default</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Reference in New Issue
Block a user