forked from qt-creator/qt-creator
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user