IncrediBuild: Rework IBConsoleBuildStep

- partially move towards using ProjectConfigurationAspect infrastructure
- fix display of default make arguments
- code cosmetics

Change-Id: I5ce3eb531c65b53d66411e959bcf79408418d5a1
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2020-07-28 18:49:06 +02:00
parent 7f2b062045
commit 632f102424
11 changed files with 252 additions and 611 deletions

View File

@@ -15,11 +15,6 @@ add_qtc_plugin(IncrediBuild
commandbuilder.h
ibconsolebuildstep.cpp
ibconsolebuildstep.h
ibconsolebuildstep.ui
ibconsolestepconfigwidget.cpp
ibconsolestepconfigwidget.h
ibconsolestepfactory.cpp
ibconsolestepfactory.h
incredibuild_global.h
incredibuildconstants.h
incredibuildplugin.cpp

View File

@@ -26,20 +26,30 @@
#include "ibconsolebuildstep.h"
#include "cmakecommandbuilder.h"
#include "ibconsolestepconfigwidget.h"
#include "incredibuildconstants.h"
#include "incredibuildconstants.h"
#include "makecommandbuilder.h"
#include "ui_ibconsolebuildstep.h"
#include <coreplugin/variablechooser.h>
#include <projectexplorer/abstractprocessstep.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/gnumakeparser.h>
#include <projectexplorer/kit.h>
#include <projectexplorer/processparameters.h>
#include <projectexplorer/projectconfigurationaspects.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <utils/environment.h>
#include <utils/pathchooser.h>
#include <QComboBox>
#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
using namespace ProjectExplorer;
using namespace Utils;
namespace IncrediBuild {
namespace Internal {
@@ -52,27 +62,218 @@ const QLatin1String IBCONSOLE_FORCEREMOTE("IncrediBuild.IBConsole.ForceRemote");
const QLatin1String IBCONSOLE_ALTERNATE("IncrediBuild.IBConsole.Alternate");
}
IBConsoleBuildStep::IBConsoleBuildStep(ProjectExplorer::BuildStepList *buildStepList, Utils::Id id)
: ProjectExplorer::AbstractProcessStep(buildStepList, id)
class IBConsoleBuildStep;
class IBConsoleStepConfigWidget : public BuildStepConfigWidget
{
Q_DECLARE_TR_FUNCTIONS(IncrediBuild::Internal::IBConsoleBuildStep)
public:
explicit IBConsoleStepConfigWidget(IBConsoleBuildStep *ibConsoleStep);
private:
void commandBuilderChanged();
void commandArgsChanged();
void makePathEdited();
IBConsoleBuildStep *m_buildStep;
QLineEdit *makeArgumentsLineEdit;
QComboBox *commandBuilder;
PathChooser *makePathChooser;
};
class IBConsoleBuildStep final : public AbstractProcessStep
{
Q_DECLARE_TR_FUNCTIONS(IncrediBuild::Internal::IBConsoleBuildStep)
public:
IBConsoleBuildStep(BuildStepList *buildStepList, Id id);
bool init() final;
BuildStepConfigWidget *createConfigWidget() final;
bool fromMap(const QVariantMap &map) final;
QVariantMap toMap() const final;
void setCommandBuilder(const QString &commandBuilder);
void tryToMigrate();
void setupOutputFormatter(OutputFormatter *formatter) final;
public:
BaseIntegerAspect *m_nice{nullptr};
BaseBoolAspect *m_keepJobNum{nullptr};
BaseBoolAspect *m_forceRemote{nullptr};
BaseBoolAspect *m_alternate{nullptr};
BuildStepList *m_earlierSteps{};
bool m_loadedFromMap{false};
CommandBuilder m_customCommandBuilder{this}; // "Custom Command"- needs to be first in the list.
MakeCommandBuilder m_makeCommandBuilder{this};
CMakeCommandBuilder m_cmakeCommandBuilder{this};
CommandBuilder *m_commandBuilders[3] {
&m_customCommandBuilder,
&m_makeCommandBuilder,
&m_cmakeCommandBuilder
};
CommandBuilder *m_activeCommandBuilder{m_commandBuilders[0]};
};
IBConsoleStepConfigWidget::IBConsoleStepConfigWidget(IBConsoleBuildStep *ibConsoleStep)
: BuildStepConfigWidget(ibConsoleStep)
, m_buildStep(ibConsoleStep)
{
setDisplayName(tr("IncrediBuild for Linux"));
setSummaryText("<b>" + displayName() + "</b>");
QFont font;
font.setBold(true);
font.setWeight(75);
auto section1 = new QLabel("Target and configuration", this);
section1->setFont(font);
auto commandHelperLabel = new QLabel(tr("Command Helper:"), this);
commandHelperLabel->setToolTip(tr("Select an helper to establish the build command."));
makePathChooser = new PathChooser(this);
makeArgumentsLineEdit = new QLineEdit(this);
const QString defaultCommand = m_buildStep->m_activeCommandBuilder->defaultCommand();
makePathChooser->lineEdit()->setPlaceholderText(defaultCommand);
const QString command = m_buildStep->m_activeCommandBuilder->command();
if (command != defaultCommand)
makePathChooser->setPath(command);
makePathChooser->setExpectedKind(PathChooser::Kind::ExistingCommand);
makePathChooser->setBaseDirectory(FilePath::fromString(PathChooser::homePath()));
makePathChooser->setHistoryCompleter(QLatin1String("IncrediBuild.IBConsole.MakeCommand.History"));
connect(makePathChooser, &PathChooser::rawPathChanged, this, &IBConsoleStepConfigWidget::makePathEdited);
QString defaultArgs;
for (const QString &a : m_buildStep->m_activeCommandBuilder->defaultArguments())
defaultArgs += "\"" + a + "\" ";
QString args;
for (const QString &a : m_buildStep->m_activeCommandBuilder->arguments())
args += "\"" + a + "\" ";
makeArgumentsLineEdit->setPlaceholderText(defaultArgs);
if (args != defaultArgs)
makeArgumentsLineEdit->setText(args);
connect(makeArgumentsLineEdit, &QLineEdit::textEdited, this, &IBConsoleStepConfigWidget::commandArgsChanged);
auto section2 = new QLabel(this);
section2->setText(tr("IncrediBuild Distribution control"));
section2->setFont(font);
commandBuilder = new QComboBox(this);
for (CommandBuilder *p : m_buildStep->m_commandBuilders)
commandBuilder->addItem(p->displayName());
commandBuilder->setCurrentText(m_buildStep->m_activeCommandBuilder->displayName());
connect(commandBuilder, &QComboBox::currentTextChanged, this, &IBConsoleStepConfigWidget::commandBuilderChanged);
const auto emphasize = [](const QString &msg) { return QString("<i>" + msg); };
auto infoLabel1 = new QLabel(emphasize(tr("Enter the appropriate arguments to your build "
"command.")), this);
auto infoLabel2 = new QLabel(emphasize(tr("Make sure the build command's "
"multi-job parameter value is large enough (such as "
"-j200 for the JOM or Make build tools)")), this);
LayoutBuilder builder(this);
builder.addRow(section1);
builder.startNewRow().addItems(commandHelperLabel, commandBuilder);
builder.startNewRow().addItems(tr("Make command:"), makePathChooser);
builder.startNewRow().addItems(tr("Make arguments:"), makeArgumentsLineEdit);
builder.addRow(infoLabel1);
builder.addRow(infoLabel2);
builder.addRow(ibConsoleStep->m_keepJobNum);
builder.addRow(section2);
builder.addRow(ibConsoleStep->m_nice);
builder.addRow(ibConsoleStep->m_forceRemote);
builder.addRow(ibConsoleStep->m_alternate);
Core::VariableChooser::addSupportForChildWidgets(this, ibConsoleStep->macroExpander());
}
void IBConsoleStepConfigWidget::commandBuilderChanged()
{
m_buildStep->setCommandBuilder(commandBuilder->currentText());
QString defaultArgs;
for (const QString &a : m_buildStep->m_activeCommandBuilder->defaultArguments())
defaultArgs += "\"" + a + "\" ";
QString args;
for (const QString &a : m_buildStep->m_activeCommandBuilder->arguments())
args += "\"" + a + "\" ";
if (args == defaultArgs)
args.clear();
makeArgumentsLineEdit->setPlaceholderText(defaultArgs);
makeArgumentsLineEdit->setText(args);
const QString defaultCommand = m_buildStep->m_activeCommandBuilder->defaultCommand();
QString command = m_buildStep->m_activeCommandBuilder->command();
if (command != defaultCommand)
command.clear();
makePathChooser->lineEdit()->setPlaceholderText(defaultCommand);
makePathChooser->setPath(command);
}
void IBConsoleStepConfigWidget::commandArgsChanged()
{
m_buildStep->m_activeCommandBuilder->arguments(makeArgumentsLineEdit->text());
}
void IBConsoleStepConfigWidget::makePathEdited()
{
m_buildStep->m_activeCommandBuilder->command(makePathChooser->rawPath());
}
// IBConsoleBuildStep
IBConsoleBuildStep::IBConsoleBuildStep(BuildStepList *buildStepList, Id id)
: AbstractProcessStep(buildStepList, id)
, m_earlierSteps(buildStepList)
{
setDisplayName("IncrediBuild for Linux");
initCommandBuilders();
}
IBConsoleBuildStep::~IBConsoleBuildStep()
{
for (CommandBuilder* p : m_commandBuildersList) {
delete p;
p = nullptr;
}
m_nice = addAspect<BaseIntegerAspect>();
m_nice->setSettingsKey(Constants::IBCONSOLE_NICE);
m_nice->setToolTip(tr("Specify nice value. Nice Value should be numeric and between -20 and 19"));
m_nice->setLabel(tr("Nice value:"));
m_nice->setRange(-20, 19);
m_keepJobNum = addAspect<BaseBoolAspect>();
m_keepJobNum->setSettingsKey(Constants::IBCONSOLE_KEEPJOBNUM);
m_keepJobNum->setLabel(tr("Keep Original Jobs Num:"));
m_keepJobNum->setToolTip(tr("Setting this option to true, forces IncrediBuild to not override "
"the -j command line switch. The default IncrediBuild behavior is "
"to set a high value to the -j command line switch which controls "
"the number of processes that the build tools executed by Qt will "
"execute in parallel (the default IncrediBuild behavior will set "
"this value to 200)."));
m_forceRemote = addAspect<BaseBoolAspect>();
m_forceRemote->setSettingsKey(Constants::IBCONSOLE_ALTERNATE);
m_forceRemote->setLabel(tr("Force remote:"));
m_alternate = addAspect<BaseBoolAspect>();
m_alternate->setSettingsKey(Constants::IBCONSOLE_FORCEREMOTE);
m_alternate->setLabel(tr("Alternate tasks preference:"));
}
void IBConsoleBuildStep::tryToMigrate()
{
// This is called when creating a fresh build step.
// Attempt to detect build system from pre-existing steps.
for (CommandBuilder* p : m_commandBuildersList) {
for (CommandBuilder *p : m_commandBuilders) {
if (p->canMigrate(m_earlierSteps)) {
m_activeCommandBuilder = p;
break;
@@ -80,7 +281,7 @@ void IBConsoleBuildStep::tryToMigrate()
}
}
void IBConsoleBuildStep::setupOutputFormatter(Utils::OutputFormatter *formatter)
void IBConsoleBuildStep::setupOutputFormatter(OutputFormatter *formatter)
{
formatter->addLineParser(new GnuMakeParser());
formatter->addLineParsers(target()->kit()->createOutputParsers());
@@ -91,13 +292,9 @@ void IBConsoleBuildStep::setupOutputFormatter(Utils::OutputFormatter *formatter)
bool IBConsoleBuildStep::fromMap(const QVariantMap &map)
{
m_loadedFromMap = true;
m_nice = map.value(Constants::IBCONSOLE_NICE, QVariant(0)).toInt();
m_keepJobNum = map.value(Constants::IBCONSOLE_KEEPJOBNUM, QVariant(false)).toBool();
m_forceRemote = map.value(Constants::IBCONSOLE_FORCEREMOTE, QVariant(false)).toBool();
m_forceRemote = map.value(Constants::IBCONSOLE_ALTERNATE, QVariant(false)).toBool();
// Command builder. Default to the first in list, which should be the "Custom Command"
commandBuilder(map.value(Constants::IBCONSOLE_COMMANDBUILDER, QVariant(m_commandBuildersList.front()->displayName())).toString());
setCommandBuilder(map.value(Constants::IBCONSOLE_COMMANDBUILDER, QVariant(m_commandBuilders[0]->displayName())).toString());
bool result = m_activeCommandBuilder->fromMap(map);
return result && AbstractProcessStep::fromMap(map);
@@ -108,11 +305,7 @@ QVariantMap IBConsoleBuildStep::toMap() const
QVariantMap map = AbstractProcessStep::toMap();
map[IncrediBuild::Constants::INCREDIBUILD_BUILDSTEP_TYPE] = QVariant(IncrediBuild::Constants::IBCONSOLE_BUILDSTEP_ID);
map[Constants::IBCONSOLE_NICE] = QVariant(m_nice);
map[Constants::IBCONSOLE_KEEPJOBNUM] = QVariant(m_keepJobNum);
map[Constants::IBCONSOLE_ALTERNATE] = QVariant(m_forceRemote);
map[Constants::IBCONSOLE_FORCEREMOTE] = QVariant(m_forceRemote);
map[Constants::IBCONSOLE_COMMANDBUILDER] = QVariant(commandBuilder()->displayName());
map[Constants::IBCONSOLE_COMMANDBUILDER] = QVariant(m_activeCommandBuilder->displayName());
m_activeCommandBuilder->toMap(&map);
return map;
@@ -122,69 +315,47 @@ bool IBConsoleBuildStep::init()
{
QStringList args;
if (m_nice != 0)
args.append(QString("--nice %0 ").arg(m_nice));
if (m_nice->value() != 0)
args.append(QString("--nice %0 ").arg(m_nice->value()));
if (m_alternate)
if (m_alternate->value())
args.append("--alternate");
if (m_forceRemote)
if (m_forceRemote->value())
args.append("--force-remote");
m_activeCommandBuilder->keepJobNum(m_keepJobNum);
m_activeCommandBuilder->keepJobNum(m_keepJobNum->value());
args.append(m_activeCommandBuilder->fullCommandFlag());
Utils::CommandLine cmdLine("ib_console", args);
CommandLine cmdLine("ib_console", args);
ProcessParameters *procParams = processParameters();
procParams->setCommandLine(cmdLine);
procParams->setEnvironment(Utils::Environment::systemEnvironment());
procParams->setEnvironment(Environment::systemEnvironment());
BuildConfiguration *buildConfig = buildConfiguration();
if (buildConfig) {
procParams->setWorkingDirectory(buildConfig->buildDirectory());
procParams->setEnvironment(buildConfig->environment());
Utils::MacroExpander *macroExpander = buildConfig->macroExpander();
if (macroExpander)
procParams->setMacroExpander(macroExpander);
procParams->setMacroExpander(buildConfig->macroExpander());
}
return AbstractProcessStep::init();
}
BuildStepConfigWidget* IBConsoleBuildStep::createConfigWidget()
BuildStepConfigWidget *IBConsoleBuildStep::createConfigWidget()
{
// On first creation of the step, attempt to detect and migrate from preceding steps
if (!m_loadedFromMap)
tryToMigrate();
return new IBConsoleStepConfigWidget(this);
}
void IBConsoleBuildStep::initCommandBuilders()
void IBConsoleBuildStep::setCommandBuilder(const QString &commandBuilder)
{
if (m_commandBuildersList.empty()) {
m_commandBuildersList.push_back(new CommandBuilder(this)); // "Custom Command"- needs to be first in the list.
m_commandBuildersList.push_back(new MakeCommandBuilder(this));
m_commandBuildersList.push_back(new CMakeCommandBuilder(this));
}
// Default to "Custom Command".
if (!m_activeCommandBuilder)
m_activeCommandBuilder = m_commandBuildersList.front();
}
const QStringList& IBConsoleBuildStep::supportedCommandBuilders()
{
static QStringList list;
if (list.empty()) {
initCommandBuilders();
for (CommandBuilder* p : m_commandBuildersList)
list.push_back(p->displayName());
}
return list;
}
void IBConsoleBuildStep::commandBuilder(const QString &commandBuilder)
{
for (CommandBuilder* p : m_commandBuildersList) {
for (CommandBuilder *p : m_commandBuilders) {
if (p->displayName().compare(commandBuilder) == 0) {
m_activeCommandBuilder = p;
break;
@@ -192,5 +363,16 @@ void IBConsoleBuildStep::commandBuilder(const QString &commandBuilder)
}
}
// IBConsoleStepFactory
IBConsoleStepFactory::IBConsoleStepFactory()
{
registerStep<IBConsoleBuildStep>(IncrediBuild::Constants::IBCONSOLE_BUILDSTEP_ID);
setDisplayName(QObject::tr("IncrediBuild for Linux"));
setSupportedStepLists({ProjectExplorer::Constants::BUILDSTEPS_BUILD,
ProjectExplorer::Constants::BUILDSTEPS_CLEAN});
}
} // namespace Internal
} // namespace IncrediBuild

View File

@@ -25,62 +25,15 @@
#pragma once
#include "commandbuilder.h"
#include <projectexplorer/abstractprocessstep.h>
#include <projectexplorer/buildsteplist.h>
#include <QList>
#include <projectexplorer/buildstep.h>
namespace IncrediBuild {
namespace Internal {
class IBConsoleBuildStep : public ProjectExplorer::AbstractProcessStep
class IBConsoleStepFactory : public ProjectExplorer::BuildStepFactory
{
Q_OBJECT
public:
explicit IBConsoleBuildStep(ProjectExplorer::BuildStepList *buildStepList, Utils::Id id);
~IBConsoleBuildStep() override;
bool init() override;
ProjectExplorer::BuildStepConfigWidget *createConfigWidget() override;
bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override;
int nice() const { return m_nice; }
void nice(int nice) { m_nice = nice; }
bool keepJobNum() const { return m_keepJobNum; }
void keepJobNum(bool keepJobNum) { m_keepJobNum = keepJobNum; }
bool forceRemote() const { return m_forceRemote; }
void forceRemote(bool forceRemote) { m_forceRemote = forceRemote; }
bool alternate() const { return m_alternate; }
void alternate(bool alternate) { m_alternate = alternate; }
const QStringList& supportedCommandBuilders();
CommandBuilder* commandBuilder() const { return m_activeCommandBuilder; }
void commandBuilder(const QString &commandBuilder);
bool loadedFromMap() const { return m_loadedFromMap; }
void tryToMigrate();
void setupOutputFormatter(Utils::OutputFormatter *formatter) override;
private:
void initCommandBuilders();
int m_nice{0};
bool m_keepJobNum{false};
bool m_forceRemote{false};
bool m_alternate{false};
ProjectExplorer::BuildStepList *m_earlierSteps{};
bool m_loadedFromMap{false};
CommandBuilder* m_activeCommandBuilder{};
QList<CommandBuilder*> m_commandBuildersList{};
IBConsoleStepFactory();
};
} // namespace Internal

View File

@@ -1,156 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>IncrediBuild::Internal::IBConsoleBuildStep</class>
<widget class="QWidget" name="IncrediBuild::Internal::IBConsoleBuildStep">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>355</width>
<height>273</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Enter the appropriate arguments to your build command</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="keepJobsNum">
<property name="toolTip">
<string>Setting this option to true, forces IncrediBuild to not override the -j command line switch. The default IncrediBuild behavior is to set a high value to the -j command line switch which controls the number of processes that the build tools executed by QT will execute in parallel (the default IncrediBuild behavior will set this value to 200).</string>
</property>
<property name="text">
<string>Keep Original Jobs Num</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Target and configuration</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="makeLabel">
<property name="text">
<string>Make command:</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QSpinBox" name="niceSpin">
<property name="minimum">
<number>-20</number>
</property>
<property name="maximum">
<number>19</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QCheckBox" name="forceRemote">
<property name="toolTip">
<string extracomment="Force allow_remote tasks to remote helpers."/>
</property>
<property name="text">
<string>Force remote</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="makeArgumentsLineEdit"/>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>IncrediBuild Distribution control</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="maxCpuLabel">
<property name="toolTip">
<string>Specify nice value. Nice Value should be numeric and between -20 and 19</string>
</property>
<property name="text">
<string>Nice value:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="commandBuilder"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="makeArgumentsLabel">
<property name="text">
<string>Make arguments:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>Select an helper to establish the build command.</string>
</property>
<property name="text">
<string>Command Helper:</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QCheckBox" name="alternate">
<property name="text">
<string>Alternate tasks preference</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Utils::PathChooser" name="makePathChooser" native="true"/>
</item>
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Make sure the build command's multi-job parameter value is large enough (such as -J200 for the JOM or Make build tools).</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
<slots>
<signal>editingFinished()</signal>
<signal>browsingFinished()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -1,163 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://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 "ibconsolestepconfigwidget.h"
#include "ui_ibconsolebuildstep.h"
#include <coreplugin/variablechooser.h>
namespace IncrediBuild {
namespace Internal {
IBConsoleStepConfigWidget::IBConsoleStepConfigWidget(IBConsoleBuildStep *ibConsoleStep)
: ProjectExplorer::BuildStepConfigWidget(ibConsoleStep)
, m_buildStepUI(nullptr)
, m_buildStep(ibConsoleStep)
{
// On first creation of the step, attempt to detect and migrate from preceding steps
if (!ibConsoleStep->loadedFromMap())
ibConsoleStep->tryToMigrate();
m_buildStepUI = new Ui_IBConsoleBuildStep();
m_buildStepUI->setupUi(this);
Core::VariableChooser::addSupportForChildWidgets(this, ibConsoleStep->macroExpander());
m_buildStepUI->commandBuilder->addItems(m_buildStep->supportedCommandBuilders());
m_buildStepUI->commandBuilder->setCurrentText(m_buildStep->commandBuilder()->displayName());
connect(m_buildStepUI->commandBuilder, &QComboBox::currentTextChanged, this, &IBConsoleStepConfigWidget::commandBuilderChanged);
QString command, defaultCommand;
defaultCommand = m_buildStep->commandBuilder()->defaultCommand();
m_buildStepUI->makePathChooser->lineEdit()->setPlaceholderText(defaultCommand);
command = m_buildStep->commandBuilder()->command();
if (command != defaultCommand)
m_buildStepUI->makePathChooser->setPath(command);
m_buildStepUI->makePathChooser->setExpectedKind(Utils::PathChooser::Kind::ExistingCommand);
m_buildStepUI->makePathChooser->setBaseDirectory(Utils::FilePath::fromString(Utils::PathChooser::homePath()));
m_buildStepUI->makePathChooser->setHistoryCompleter(QLatin1String("IncrediBuild.IBConsole.MakeCommand.History"));
connect(m_buildStepUI->makePathChooser, &Utils::PathChooser::rawPathChanged, this, &IBConsoleStepConfigWidget::makePathEdited);
QString defaultArgs;
for (const QString &a : m_buildStep->commandBuilder()->defaultArguments())
defaultArgs += "\"" + a + "\" ";
QString args;
for (const QString &a : m_buildStep->commandBuilder()->arguments())
args += "\"" + a + "\" ";
m_buildStepUI->makeArgumentsLineEdit->setPlaceholderText(defaultArgs);
if (args != defaultArgs)
m_buildStepUI->makeArgumentsLineEdit->setText(args);
connect(m_buildStepUI->makeArgumentsLineEdit, &QLineEdit::textEdited, this, &IBConsoleStepConfigWidget::commandArgsChanged);
m_buildStepUI->niceSpin->setValue(m_buildStep->nice());
connect(m_buildStepUI->niceSpin, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &IBConsoleStepConfigWidget::niceChanged);
m_buildStepUI->keepJobsNum->setChecked(m_buildStep->keepJobNum());
connect(m_buildStepUI->keepJobsNum, &QCheckBox::stateChanged, this, &IBConsoleStepConfigWidget::keepJobNumChanged);
m_buildStepUI->alternate->setChecked(m_buildStep->alternate());
connect(m_buildStepUI->alternate, &QCheckBox::stateChanged, this, &IBConsoleStepConfigWidget::alternateChanged);
m_buildStepUI->forceRemote->setChecked(m_buildStep->forceRemote());
connect(m_buildStepUI->forceRemote, &QCheckBox::stateChanged, this, &IBConsoleStepConfigWidget::forceRemoteChanged);
}
IBConsoleStepConfigWidget::~IBConsoleStepConfigWidget()
{
delete m_buildStepUI;
m_buildStepUI = nullptr;
}
QString IBConsoleStepConfigWidget::displayName() const
{
return tr("IncrediBuild for Linux");
}
QString IBConsoleStepConfigWidget::summaryText() const
{
return "<b>" + displayName() + "</b>";
}
void IBConsoleStepConfigWidget::niceChanged(int)
{
m_buildStep->nice(m_buildStepUI->niceSpin->value());
}
void IBConsoleStepConfigWidget::commandBuilderChanged(const QString&)
{
m_buildStep->commandBuilder(m_buildStepUI->commandBuilder->currentText());
QString defaultArgs;
for (const QString &a : m_buildStep->commandBuilder()->defaultArguments())
defaultArgs += "\"" + a + "\" ";
QString args;
for (const QString &a : m_buildStep->commandBuilder()->arguments())
args += "\"" + a + "\" ";
if (args != defaultArgs)
m_buildStepUI->makeArgumentsLineEdit->setText(args);
else
m_buildStepUI->makeArgumentsLineEdit->setText("");
QString command, defaultCommand;
defaultCommand = m_buildStep->commandBuilder()->defaultCommand();
m_buildStepUI->makePathChooser->lineEdit()->setPlaceholderText(defaultCommand);
command = m_buildStep->commandBuilder()->command();
if (command != defaultCommand)
m_buildStepUI->makePathChooser->setPath(command);
else
m_buildStepUI->makePathChooser->setPath("");
}
void IBConsoleStepConfigWidget::commandArgsChanged(const QString&)
{
m_buildStep->commandBuilder()->arguments(m_buildStepUI->makeArgumentsLineEdit->text());
}
void IBConsoleStepConfigWidget::makePathEdited()
{
m_buildStep->commandBuilder()->command(m_buildStepUI->makePathChooser->rawPath());
}
void IBConsoleStepConfigWidget::keepJobNumChanged()
{
m_buildStep->keepJobNum(m_buildStepUI->keepJobsNum->checkState() == Qt::CheckState::Checked);
}
void IBConsoleStepConfigWidget::alternateChanged()
{
m_buildStep->alternate(m_buildStepUI->alternate->checkState() == Qt::CheckState::Checked);
}
void IBConsoleStepConfigWidget::forceRemoteChanged()
{
m_buildStep->forceRemote(m_buildStepUI->forceRemote->checkState() == Qt::CheckState::Checked);
}
} // namespace Internal
} // namespace IncrediBuild

View File

@@ -1,61 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://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 "ibconsolebuildstep.h"
#include <projectexplorer/buildstep.h>
namespace IncrediBuild {
namespace Internal {
class Ui_IBConsoleBuildStep;
class IBConsoleStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
{
Q_OBJECT
public:
explicit IBConsoleStepConfigWidget(IBConsoleBuildStep *ibConsoleStep);
virtual ~IBConsoleStepConfigWidget();
QString displayName() const;
QString summaryText() const;
private:
void niceChanged(int);
void keepJobNumChanged();
void forceRemoteChanged();
void alternateChanged();
void commandBuilderChanged(const QString&);
void commandArgsChanged(const QString&);
void makePathEdited();
Internal::Ui_IBConsoleBuildStep *m_buildStepUI;
IBConsoleBuildStep *m_buildStep;
};
} // namespace Internal
} // namespace IncrediBuild

View File

@@ -1,55 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://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 "ibconsolestepfactory.h"
#include "ibconsolebuildstep.h"
#include "incredibuildconstants.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/toolchainmanager.h>
#include <QMessageBox>
using namespace ProjectExplorer;
namespace IncrediBuild {
namespace Internal {
IBConsoleStepFactory::IBConsoleStepFactory()
{
registerStep<IBConsoleBuildStep>(Constants::IBCONSOLE_BUILDSTEP_ID);
setDisplayName(QObject::tr("IncrediBuild for Linux"));
setSupportedStepLists({ProjectExplorer::Constants::BUILDSTEPS_BUILD,
ProjectExplorer::Constants::BUILDSTEPS_CLEAN});
}
} // namespace Internal
} // namespace IncrediBuild

View File

@@ -1,44 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://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/abi.h>
#include <projectexplorer/abstractprocessstep.h>
#include <projectexplorer/buildstep.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/target.h>
namespace IncrediBuild {
namespace Internal {
class IBConsoleStepFactory : public ProjectExplorer::BuildStepFactory
{
public:
IBConsoleStepFactory();
};
} // namespace Internal
} // namespace IncrediBuild

View File

@@ -14,23 +14,18 @@ SOURCES += incredibuildplugin.cpp \
commandbuilder.cpp \
makecommandbuilder.cpp \
cmakecommandbuilder.cpp \
ibconsolebuildstep.cpp \
ibconsolestepconfigwidget.cpp \
ibconsolestepfactory.cpp
ibconsolebuildstep.cpp
HEADERS += incredibuildplugin.h \
buildconsolestepconfigwidget.h \
buildconsolestepfactory.h \
cmakecommandbuilder.h \
commandbuilder.h \
ibconsolestepconfigwidget.h \
incredibuild_global.h \
incredibuildconstants.h \
buildconsolebuildstep.h \
makecommandbuilder.h \
ibconsolebuildstep.h \
ibconsolestepfactory.h
FORMS += \
buildconsolebuildstep.ui \
ibconsolebuildstep.ui
buildconsolebuildstep.ui

View File

@@ -22,11 +22,6 @@ QtcPlugin {
"commandbuilder.h",
"ibconsolebuildstep.cpp",
"ibconsolebuildstep.h",
"ibconsolebuildstep.ui",
"ibconsolestepconfigwidget.cpp",
"ibconsolestepconfigwidget.h",
"ibconsolestepfactory.cpp",
"ibconsolestepfactory.h",
"incredibuild_global.h",
"incredibuildconstants.h",
"incredibuildplugin.cpp",

View File

@@ -27,7 +27,7 @@
#include "incredibuild_global.h"
#include "buildconsolestepfactory.h"
#include "ibconsolestepfactory.h"
#include "ibconsolebuildstep.h"
#include <extensionsystem/iplugin.h>