Incredibuild: Introduce a CommandBuilderAspect

Covering the remaining bits in the buildsteps.

Change-Id: Ia1c51eb14c92bd377b7b5d6ddbd4658e9adc1b89
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2020-08-05 16:21:52 +02:00
parent 5327b91e99
commit 1a50b685ff
7 changed files with 314 additions and 345 deletions

View File

@@ -8,6 +8,8 @@ add_qtc_plugin(IncrediBuild
cmakecommandbuilder.h
commandbuilder.cpp
commandbuilder.h
commandbuilderaspect.cpp
commandbuilderaspect.h
ibconsolebuildstep.cpp
ibconsolebuildstep.h
incredibuild_global.h

View File

@@ -25,9 +25,9 @@
#include "buildconsolebuildstep.h"
#include "cmakecommandbuilder.h"
#include "commandbuilder.h"
#include "commandbuilderaspect.h"
#include "incredibuildconstants.h"
#include "makecommandbuilder.h"
#include <coreplugin/variablechooser.h>
@@ -86,26 +86,15 @@ public:
BuildConsoleBuildStep(BuildStepList *buildStepList, Id id);
bool init() final;
BuildStepConfigWidget *createConfigWidget() final;
bool fromMap(const QVariantMap &map) final;
QVariantMap toMap() const final;
const QStringList &supportedWindowsVersions() const;
const QStringList &supportedCommandBuilders();
CommandBuilder *commandBuilder() const { return m_activeCommandBuilder; }
void commandBuilder(const QString &commandBuilder);
void tryToMigrate();
void setupOutputFormatter(OutputFormatter *formatter) final;
const QStringList &supportedWindowsVersions() const;
QString normalizeWinVerArgument(QString winVer);
bool m_loadedFromMap{false};
CommandBuilderAspect *m_commandBuilder;
BaseBoolAspect *m_avoidLocal{nullptr};
BaseStringAspect *m_profileXml{nullptr};
BaseIntegerAspect *m_maxCpu{nullptr};
@@ -125,45 +114,20 @@ public:
BaseStringAspect *m_additionalArguments{nullptr};
BaseBoolAspect *m_openMonitor{nullptr};
BaseBoolAspect *m_keepJobNum{nullptr};
CommandBuilder m_customCommandBuilder{this};
MakeCommandBuilder m_makeCommandBuilder{this};
CMakeCommandBuilder m_cmakeCommandBuilder{this};
CommandBuilder *m_commandBuilders[3] {
&m_customCommandBuilder,
&m_makeCommandBuilder,
&m_cmakeCommandBuilder
};
CommandBuilder *m_activeCommandBuilder{m_commandBuilders[0]};
};
class BuildConsoleStepConfigWidget : public BuildStepConfigWidget
{
Q_DECLARE_TR_FUNCTIONS(IncrediBuild::Internal::BuildConsoleBuildStep)
public:
explicit BuildConsoleStepConfigWidget(BuildConsoleBuildStep *buildConsoleStep);
private:
void commandBuilderChanged();
void commandArgsChanged();
void makePathEdited();
BuildConsoleBuildStep *m_buildStep;
QLineEdit *makeArgumentsLineEdit;
QComboBox *commandBuilder;
PathChooser *makePathChooser;
};
// BuildConsoleStepConfigWidget
BuildConsoleStepConfigWidget::BuildConsoleStepConfigWidget(BuildConsoleBuildStep *buildConsoleStep)
: BuildStepConfigWidget(buildConsoleStep)
, m_buildStep(buildConsoleStep)
{
setDisplayName(tr("IncrediBuild for Windows"));
@@ -183,8 +147,6 @@ BuildConsoleStepConfigWidget::BuildConsoleStepConfigWidget(BuildConsoleBuildStep
auto sectionLogging = new QLabel(tr("Output and Logging"), this);
sectionLogging->setFont(font);
commandBuilder = new QComboBox(this);
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);
@@ -192,45 +154,9 @@ BuildConsoleStepConfigWidget::BuildConsoleStepConfigWidget(BuildConsoleBuildStep
"multi-job parameter value is large enough (such as "
"-j200 for the JOM or Make build tools)")), this);
auto label = new QLabel(tr("Command Helper:"), this);
label->setToolTip(tr("Select an helper to establish the build command."));
commandBuilder->addItems(m_buildStep->supportedCommandBuilders());
commandBuilder->setCurrentText(m_buildStep->commandBuilder()->displayName());
connect(commandBuilder, &QComboBox::currentTextChanged, this, &BuildConsoleStepConfigWidget::commandBuilderChanged);
makePathChooser = new PathChooser;
makeArgumentsLineEdit = new QLineEdit(this);
const QString defaultCommand = m_buildStep->commandBuilder()->defaultCommand();
makePathChooser->lineEdit()->setPlaceholderText(defaultCommand);
const QString command = m_buildStep->commandBuilder()->command();
if (command != defaultCommand)
makePathChooser->setPath(command);
makePathChooser->setExpectedKind(PathChooser::Kind::ExistingCommand);
makePathChooser->setBaseDirectory(FilePath::fromString(PathChooser::homePath()));
makePathChooser->setHistoryCompleter("IncrediBuild.BuildConsole.MakeCommand.History");
connect(makePathChooser, &PathChooser::rawPathChanged, this, &BuildConsoleStepConfigWidget::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 + "\" ";
makeArgumentsLineEdit->setPlaceholderText(defaultArgs);
if (args != defaultArgs)
makeArgumentsLineEdit->setText(args);
connect(makeArgumentsLineEdit, &QLineEdit::textEdited, this, &BuildConsoleStepConfigWidget::commandArgsChanged);
LayoutBuilder builder(this);
builder.addRow(sectionTarget);
builder.startNewRow().addItems(label, commandBuilder);
builder.startNewRow().addItems(tr("Make command:"), makePathChooser);
builder.startNewRow().addItems(tr("Make arguments:"), makeArgumentsLineEdit);
builder.addRow(buildConsoleStep->m_commandBuilder);
builder.addRow(infoLabel1);
builder.addRow(infoLabel2);
builder.addRow(buildConsoleStep->m_keepJobNum);
@@ -262,40 +188,6 @@ BuildConsoleStepConfigWidget::BuildConsoleStepConfigWidget(BuildConsoleBuildStep
Core::VariableChooser::addSupportForChildWidgets(this, buildConsoleStep->macroExpander());
}
void BuildConsoleStepConfigWidget::commandBuilderChanged()
{
m_buildStep->commandBuilder(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)
makeArgumentsLineEdit->clear();
makeArgumentsLineEdit->setText(args);
const QString defaultCommand = m_buildStep->commandBuilder()->defaultCommand();
makePathChooser->lineEdit()->setPlaceholderText(defaultCommand);
QString command = m_buildStep->commandBuilder()->command();
if (command == defaultCommand)
command.clear();
makePathChooser->setPath(command);
}
void BuildConsoleStepConfigWidget::commandArgsChanged()
{
m_buildStep->commandBuilder()->arguments(makeArgumentsLineEdit->text());
}
void BuildConsoleStepConfigWidget::makePathEdited()
{
m_buildStep->commandBuilder()->command(makePathChooser->rawPath());
}
// BuildConsoleBuilStep
BuildConsoleBuildStep::BuildConsoleBuildStep(BuildStepList *buildStepList, Id id)
@@ -303,6 +195,9 @@ BuildConsoleBuildStep::BuildConsoleBuildStep(BuildStepList *buildStepList, Id id
{
setDisplayName("IncrediBuild for Windows");
m_commandBuilder = addAspect<CommandBuilderAspect>(this);
m_commandBuilder->setSettingsKey(Constants::BUILDCONSOLE_COMMANDBUILDER);
m_maxCpu = addAspect<BaseIntegerAspect>();
m_maxCpu->setSettingsKey(Constants::BUILDCONSOLE_MAXCPU);
m_maxCpu->setToolTip(tr("Determines the maximum number of CPU cores that can be used in a "
@@ -468,18 +363,6 @@ BuildConsoleBuildStep::BuildConsoleBuildStep(BuildStepList *buildStepList, Id id
"IncrediBuild behavior will set this value to 200)"));
}
void BuildConsoleBuildStep::tryToMigrate()
{
// This constructor is called when creating a fresh build step.
// Attempt to detect build system from pre-existing steps.
for (CommandBuilder *p : m_commandBuilders) {
if (p->canMigrate(stepList())) {
m_activeCommandBuilder = p;
break;
}
}
}
void BuildConsoleBuildStep::setupOutputFormatter(OutputFormatter *formatter)
{
formatter->addLineParser(new GnuMakeParser());
@@ -488,32 +371,6 @@ void BuildConsoleBuildStep::setupOutputFormatter(OutputFormatter *formatter)
AbstractProcessStep::setupOutputFormatter(formatter);
}
bool BuildConsoleBuildStep::fromMap(const QVariantMap &map)
{
m_loadedFromMap = true;
// Command builder. Default to the first in list, which should be the "Custom Command"
commandBuilder(map.value(Constants::BUILDCONSOLE_COMMANDBUILDER,
QVariant(m_commandBuilders[0]->displayName()))
.toString());
bool result = m_activeCommandBuilder->fromMap(map);
return result && AbstractProcessStep::fromMap(map);
}
QVariantMap BuildConsoleBuildStep::toMap() const
{
QVariantMap map = AbstractProcessStep::toMap();
map[IncrediBuild::Constants::INCREDIBUILD_BUILDSTEP_TYPE] = QVariant(
IncrediBuild::Constants::BUILDCONSOLE_BUILDSTEP_ID);
map[Constants::BUILDCONSOLE_COMMANDBUILDER] = QVariant(m_activeCommandBuilder->displayName());
m_activeCommandBuilder->toMap(&map);
return map;
}
const QStringList& BuildConsoleBuildStep::supportedWindowsVersions() const
{
static QStringList list({QString(),
@@ -539,9 +396,10 @@ bool BuildConsoleBuildStep::init()
{
QStringList args;
m_activeCommandBuilder->keepJobNum(m_keepJobNum->value());
CommandBuilder *activeCommandBuilder = m_commandBuilder->commandBuilder();
activeCommandBuilder->keepJobNum(m_keepJobNum->value());
QString cmd("/Command= %0");
cmd = cmd.arg(m_activeCommandBuilder->fullCommandFlag());
cmd = cmd.arg(activeCommandBuilder->fullCommandFlag());
args.append(cmd);
if (!m_profileXml->value().isEmpty())
@@ -614,35 +472,9 @@ bool BuildConsoleBuildStep::init()
BuildStepConfigWidget* BuildConsoleBuildStep::createConfigWidget()
{
// On first creation of the step, attempt to detect and migrate from preceding steps
if (!m_loadedFromMap)
tryToMigrate();
return new BuildConsoleStepConfigWidget(this);
}
const QStringList& BuildConsoleBuildStep::supportedCommandBuilders()
{
static QStringList list;
if (list.empty()) {
for (CommandBuilder *p : m_commandBuilders)
list.push_back(p->displayName());
}
return list;
}
void BuildConsoleBuildStep::commandBuilder(const QString& commandBuilder)
{
for (CommandBuilder *p : m_commandBuilders) {
if (p->displayName().compare(commandBuilder) == 0) {
m_activeCommandBuilder = p;
break;
}
}
}
// BuildConsoleStepFactory
BuildConsoleStepFactory::BuildConsoleStepFactory()

View File

@@ -0,0 +1,234 @@
/****************************************************************************
**
** 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 "commandbuilderaspect.h"
#include "cmakecommandbuilder.h"
#include "incredibuildconstants.h"
#include "makecommandbuilder.h"
#include <projectexplorer/abstractprocessstep.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 {
class CommandBuilderAspectPrivate
{
public:
CommandBuilderAspectPrivate(BuildStep *step)
: m_buildStep{step},
m_customCommandBuilder{step},
m_makeCommandBuilder{step},
m_cmakeCommandBuilder{step}
{}
void commandBuilderChanged();
const QStringList &supportedCommandBuilders();
void setCommandBuilder(const QString &commandBuilder);
void tryToMigrate();
BuildStep *m_buildStep;
CommandBuilder m_customCommandBuilder;
MakeCommandBuilder m_makeCommandBuilder;
CMakeCommandBuilder m_cmakeCommandBuilder;
CommandBuilder *m_commandBuilders[3] {
&m_customCommandBuilder,
&m_makeCommandBuilder,
&m_cmakeCommandBuilder
};
CommandBuilder *m_activeCommandBuilder = m_commandBuilders[0];
bool m_loadedFromMap = false;
QPointer<QLabel> label;
QPointer<QLineEdit> makeArgumentsLineEdit;
QPointer<QComboBox> commandBuilder;
QPointer<PathChooser> makePathChooser;
};
CommandBuilderAspect::CommandBuilderAspect(BuildStep *step)
: d(new CommandBuilderAspectPrivate(step))
{
}
CommandBuilderAspect::~CommandBuilderAspect()
{
delete d;
}
CommandBuilder *CommandBuilderAspect::commandBuilder() const
{
return d->m_activeCommandBuilder;
}
const QStringList& CommandBuilderAspectPrivate::supportedCommandBuilders()
{
static QStringList list;
if (list.empty()) {
for (CommandBuilder *p : m_commandBuilders)
list.push_back(p->displayName());
}
return list;
}
void CommandBuilderAspectPrivate::setCommandBuilder(const QString &commandBuilder)
{
for (CommandBuilder *p : m_commandBuilders) {
if (p->displayName().compare(commandBuilder) == 0) {
m_activeCommandBuilder = p;
break;
}
}
}
void CommandBuilderAspectPrivate::commandBuilderChanged()
{
setCommandBuilder(commandBuilder->currentText());
QString defaultArgs;
for (const QString &a : m_activeCommandBuilder->defaultArguments())
defaultArgs += "\"" + a + "\" ";
QString args;
for (const QString &a : m_activeCommandBuilder->arguments())
args += "\"" + a + "\" ";
if (args == defaultArgs)
makeArgumentsLineEdit->clear();
makeArgumentsLineEdit->setText(args);
const QString defaultCommand = m_activeCommandBuilder->defaultCommand();
makePathChooser->lineEdit()->setPlaceholderText(defaultCommand);
QString command = m_activeCommandBuilder->command();
if (command == defaultCommand)
command.clear();
makePathChooser->setPath(command);
}
void CommandBuilderAspectPrivate::tryToMigrate()
{
// This constructor is called when creating a fresh build step.
// Attempt to detect build system from pre-existing steps.
for (CommandBuilder *p : m_commandBuilders) {
if (p->canMigrate(m_buildStep->stepList())) {
m_activeCommandBuilder = p;
break;
}
}
}
void CommandBuilderAspect::addToLayout(LayoutBuilder &builder)
{
if (!d->commandBuilder) {
d->commandBuilder = new QComboBox;
d->commandBuilder->addItems(d->supportedCommandBuilders());
d->commandBuilder->setCurrentText(d->m_activeCommandBuilder->displayName());
connect(d->commandBuilder, &QComboBox::currentTextChanged, this,
[this] { d->commandBuilderChanged(); });
}
if (!d->makePathChooser) {
d->makePathChooser = new PathChooser;
d->makeArgumentsLineEdit = new QLineEdit;
const QString defaultCommand = d->m_activeCommandBuilder->defaultCommand();
d->makePathChooser->lineEdit()->setPlaceholderText(defaultCommand);
const QString command = d->m_activeCommandBuilder->command();
if (command != defaultCommand)
d->makePathChooser->setPath(command);
d->makePathChooser->setExpectedKind(PathChooser::Kind::ExistingCommand);
d->makePathChooser->setBaseDirectory(FilePath::fromString(PathChooser::homePath()));
d->makePathChooser->setHistoryCompleter("IncrediBuild.BuildConsole.MakeCommand.History");
connect(d->makePathChooser, &PathChooser::rawPathChanged, this, [this] {
d->m_activeCommandBuilder->command(d->makePathChooser->rawPath());
});
QString defaultArgs;
for (const QString &a : d->m_activeCommandBuilder->defaultArguments())
defaultArgs += "\"" + a + "\" ";
QString args;
for (const QString &a : d->m_activeCommandBuilder->arguments())
args += "\"" + a + "\" ";
d->makeArgumentsLineEdit->setPlaceholderText(defaultArgs);
if (args != defaultArgs)
d->makeArgumentsLineEdit->setText(args);
connect(d->makeArgumentsLineEdit, &QLineEdit::textEdited, this, [this] {
d->m_activeCommandBuilder->arguments(d->makeArgumentsLineEdit->text());
});
}
if (!d->label) {
d->label = new QLabel(tr("Command Helper:"));
d->label->setToolTip(tr("Select an helper to establish the build command."));
}
// On first creation of the step, attempt to detect and migrate from preceding steps
if (!d->m_loadedFromMap)
d->tryToMigrate();
builder.startNewRow().addItems(d->label.data(), d->commandBuilder.data());
builder.startNewRow().addItems(tr("Make command:"), d->makePathChooser.data());
builder.startNewRow().addItems(tr("Make arguments:"), d->makeArgumentsLineEdit.data());
}
void CommandBuilderAspect::fromMap(const QVariantMap &map)
{
d->m_loadedFromMap = true;
// Command builder. Default to the first in list, which should be the "Custom Command"
d->setCommandBuilder(map.value(settingsKey(), d->m_commandBuilders[0]->displayName()).toString());
d->m_activeCommandBuilder->fromMap(map);
}
void CommandBuilderAspect::toMap(QVariantMap &map) const
{
map[IncrediBuild::Constants::INCREDIBUILD_BUILDSTEP_TYPE]
= QVariant(IncrediBuild::Constants::BUILDCONSOLE_BUILDSTEP_ID);
map[settingsKey()] = QVariant(d->m_activeCommandBuilder->displayName());
d->m_activeCommandBuilder->toMap(&map);
}
} // namespace Internal
} // namespace IncrediBuild

View File

@@ -0,0 +1,53 @@
/****************************************************************************
**
** 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/buildstep.h>
#include <projectexplorer/projectconfigurationaspects.h>
namespace IncrediBuild {
namespace Internal {
class CommandBuilder;
class CommandBuilderAspect final : public ProjectExplorer::ProjectConfigurationAspect
{
public:
explicit CommandBuilderAspect(ProjectExplorer::BuildStep *step);
~CommandBuilderAspect() final;
CommandBuilder *commandBuilder() const;
private:
void addToLayout(ProjectExplorer::LayoutBuilder &builder) final;
void fromMap(const QVariantMap &map) final;
void toMap(QVariantMap &map) const final;
class CommandBuilderAspectPrivate *d = nullptr;
};
} // namespace Internal
} // namespace IncrediBuild

View File

@@ -25,9 +25,9 @@
#include "ibconsolebuildstep.h"
#include "cmakecommandbuilder.h"
#include "commandbuilder.h"
#include "commandbuilderaspect.h"
#include "incredibuildconstants.h"
#include "makecommandbuilder.h"
#include <coreplugin/variablechooser.h>
@@ -40,13 +40,7 @@
#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;
@@ -70,17 +64,6 @@ class IBConsoleStepConfigWidget : public BuildStepConfigWidget
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
@@ -91,42 +74,21 @@ 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:
CommandBuilderAspect *m_commandBuilder;
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>");
@@ -138,45 +100,10 @@ IBConsoleStepConfigWidget::IBConsoleStepConfigWidget(IBConsoleBuildStep *ibConso
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);
@@ -186,9 +113,7 @@ IBConsoleStepConfigWidget::IBConsoleStepConfigWidget(IBConsoleBuildStep *ibConso
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(ibConsoleStep->m_commandBuilder);
builder.addRow(infoLabel1);
builder.addRow(infoLabel2);
builder.addRow(ibConsoleStep->m_keepJobNum);
@@ -201,41 +126,6 @@ IBConsoleStepConfigWidget::IBConsoleStepConfigWidget(IBConsoleBuildStep *ibConso
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)
@@ -244,6 +134,9 @@ IBConsoleBuildStep::IBConsoleBuildStep(BuildStepList *buildStepList, Id id)
{
setDisplayName("IncrediBuild for Linux");
m_commandBuilder = addAspect<CommandBuilderAspect>(this);
m_commandBuilder->setSettingsKey(Constants::IBCONSOLE_COMMANDBUILDER);
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"));
@@ -269,18 +162,6 @@ IBConsoleBuildStep::IBConsoleBuildStep(BuildStepList *buildStepList, Id id)
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_commandBuilders) {
if (p->canMigrate(m_earlierSteps)) {
m_activeCommandBuilder = p;
break;
}
}
}
void IBConsoleBuildStep::setupOutputFormatter(OutputFormatter *formatter)
{
formatter->addLineParser(new GnuMakeParser());
@@ -289,28 +170,6 @@ void IBConsoleBuildStep::setupOutputFormatter(OutputFormatter *formatter)
AbstractProcessStep::setupOutputFormatter(formatter);
}
bool IBConsoleBuildStep::fromMap(const QVariantMap &map)
{
m_loadedFromMap = true;
// Command builder. Default to the first in list, which should be the "Custom Command"
setCommandBuilder(map.value(Constants::IBCONSOLE_COMMANDBUILDER, QVariant(m_commandBuilders[0]->displayName())).toString());
bool result = m_activeCommandBuilder->fromMap(map);
return result && AbstractProcessStep::fromMap(map);
}
QVariantMap IBConsoleBuildStep::toMap() const
{
QVariantMap map = AbstractProcessStep::toMap();
map[IncrediBuild::Constants::INCREDIBUILD_BUILDSTEP_TYPE] = QVariant(IncrediBuild::Constants::IBCONSOLE_BUILDSTEP_ID);
map[Constants::IBCONSOLE_COMMANDBUILDER] = QVariant(m_activeCommandBuilder->displayName());
m_activeCommandBuilder->toMap(&map);
return map;
}
bool IBConsoleBuildStep::init()
{
QStringList args;
@@ -324,8 +183,9 @@ bool IBConsoleBuildStep::init()
if (m_forceRemote->value())
args.append("--force-remote");
m_activeCommandBuilder->keepJobNum(m_keepJobNum->value());
args.append(m_activeCommandBuilder->fullCommandFlag());
CommandBuilder *commandBuilder = m_commandBuilder->commandBuilder();
commandBuilder->keepJobNum(m_keepJobNum->value());
args.append(commandBuilder->fullCommandFlag());
CommandLine cmdLine("ib_console", args);
ProcessParameters *procParams = processParameters();
@@ -344,26 +204,10 @@ bool IBConsoleBuildStep::init()
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::setCommandBuilder(const QString &commandBuilder)
{
for (CommandBuilder *p : m_commandBuilders) {
if (p->displayName().compare(commandBuilder) == 0) {
m_activeCommandBuilder = p;
break;
}
}
}
// IBConsoleStepFactory
IBConsoleStepFactory::IBConsoleStepFactory()

View File

@@ -10,6 +10,7 @@ DEFINES += INCREDIBUILD_LIBRARY
SOURCES += incredibuildplugin.cpp \
buildconsolebuildstep.cpp \
commandbuilder.cpp \
commandbuilderaspect.cpp \
makecommandbuilder.cpp \
cmakecommandbuilder.cpp \
ibconsolebuildstep.cpp
@@ -17,6 +18,7 @@ SOURCES += incredibuildplugin.cpp \
HEADERS += incredibuildplugin.h \
cmakecommandbuilder.h \
commandbuilder.h \
commandbuilderaspect.h \
incredibuild_global.h \
incredibuildconstants.h \
buildconsolebuildstep.h \

View File

@@ -15,6 +15,8 @@ QtcPlugin {
"cmakecommandbuilder.h",
"commandbuilder.cpp",
"commandbuilder.h",
"commandbuilderaspect.cpp",
"commandbuilderaspect.h",
"ibconsolebuildstep.cpp",
"ibconsolebuildstep.h",
"incredibuild_global.h",