Commit 00477182 authored by Daniel Teske's avatar Daniel Teske

CMakeProject: Add option to override the make command

Task-number: QTCREATORBUG-11788
Change-Id: If6a908ced927051b8ae131f4876c24a04b0ccaf7
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent c0b3dd7a
......@@ -48,6 +48,7 @@
#include <coreplugin/find/itemviewfind.h>
#include <utils/qtcprocess.h>
#include <utils/pathchooser.h>
#include <QFormLayout>
#include <QGroupBox>
......@@ -64,6 +65,7 @@ const char MS_ID[] = "CMakeProjectManager.MakeStep";
const char CLEAN_KEY[] = "CMakeProjectManager.MakeStep.Clean";
const char BUILD_TARGETS_KEY[] = "CMakeProjectManager.MakeStep.BuildTargets";
const char ADDITIONAL_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.AdditionalArguments";
const char MAKE_COMMAND_KEY[] = "CMakeProjectManager.MakeStep.MakeCommand";
}
MakeStep::MakeStep(BuildStepList *bsl) :
......@@ -82,7 +84,8 @@ MakeStep::MakeStep(BuildStepList *bsl, MakeStep *bs) :
AbstractProcessStep(bsl, bs),
m_clean(bs->m_clean),
m_buildTargets(bs->m_buildTargets),
m_additionalArguments(bs->m_additionalArguments)
m_additionalArguments(bs->m_additionalArguments),
m_makeCmd(bs->m_makeCmd)
{
ctor();
}
......@@ -159,6 +162,7 @@ QVariantMap MakeStep::toMap() const
map.insert(QLatin1String(CLEAN_KEY), m_clean);
map.insert(QLatin1String(BUILD_TARGETS_KEY), m_buildTargets);
map.insert(QLatin1String(ADDITIONAL_ARGUMENTS_KEY), m_additionalArguments);
map.insert(QLatin1String(MAKE_COMMAND_KEY), m_makeCmd);
return map;
}
......@@ -167,6 +171,7 @@ bool MakeStep::fromMap(const QVariantMap &map)
m_clean = map.value(QLatin1String(CLEAN_KEY)).toBool();
m_buildTargets = map.value(QLatin1String(BUILD_TARGETS_KEY)).toStringList();
m_additionalArguments = map.value(QLatin1String(ADDITIONAL_ARGUMENTS_KEY)).toString();
m_makeCmd = map.value(QLatin1String(MAKE_COMMAND_KEY)).toString();
return BuildStep::fromMap(map);
}
......@@ -304,6 +309,8 @@ void MakeStep::setAdditionalArguments(const QString &list)
QString MakeStep::makeCommand(ProjectExplorer::ToolChain *tc, const Utils::Environment &env) const
{
if (!m_makeCmd.isEmpty())
return m_makeCmd;
CMakeBuildConfiguration *bc = cmakeBuildConfiguration();
if (!bc)
bc = targetsActiveBuildConfiguration();
......@@ -316,6 +323,16 @@ QString MakeStep::makeCommand(ProjectExplorer::ToolChain *tc, const Utils::Envir
return QLatin1String("make");
}
void MakeStep::setUserMakeCommand(const QString &make)
{
m_makeCmd = make;
}
QString MakeStep::userMakeCommand() const
{
return m_makeCmd;
}
//
// MakeStepConfigWidget
//
......@@ -328,6 +345,14 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
setLayout(fl);
m_makePathChooser = new Utils::PathChooser(this);
m_makePathChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
m_makePathChooser->setBaseDirectory(Utils::PathChooser::homePath());
m_makePathChooser->setHistoryCompleter(QLatin1String("PE.MakeCommand.History"));
m_makePathChooser->setPath(m_makeStep->userMakeCommand());
fl->addRow(tr("Override command:"), m_makePathChooser);
m_additionalArguments = new QLineEdit(this);
fl->addRow(tr("Additional arguments:"), m_additionalArguments);
m_additionalArguments->setText(m_makeStep->additionalArguments());
......@@ -356,6 +381,7 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
updateDetails();
connect(m_makePathChooser, &Utils::PathChooser::changed, this, &MakeStepConfigWidget::makeEdited);
connect(m_additionalArguments, &QLineEdit::textEdited, this, &MakeStepConfigWidget::additionalArgumentsEdited);
connect(m_buildTargetsList, &QListWidget::itemChanged, this, &MakeStepConfigWidget::itemChanged);
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::settingsChanged,
......@@ -367,6 +393,12 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
connect(m_makeStep, &MakeStep::makeCommandChanged, this, &MakeStepConfigWidget::updateDetails);
}
void MakeStepConfigWidget::makeEdited()
{
m_makeStep->setUserMakeCommand(m_makePathChooser->rawPath());
updateDetails();
}
void MakeStepConfigWidget::additionalArgumentsEdited()
{
m_makeStep->setAdditionalArguments(m_additionalArguments->text());
......
......@@ -38,6 +38,8 @@ class QListWidget;
class QListWidgetItem;
QT_END_NAMESPACE
namespace Utils { class PathChooser; }
namespace ProjectExplorer { class ToolChain; }
namespace CMakeProjectManager {
......@@ -79,6 +81,8 @@ public:
QVariantMap toMap() const;
void setUserMakeCommand(const QString &make);
QString userMakeCommand() const;
private:
void activeBuildConfigurationChanged();
void buildTargetsChanged();
......@@ -111,6 +115,7 @@ private:
QString m_additionalArguments;
bool m_useNinja;
CMakeBuildConfiguration *m_activeConfiguration;
QString m_makeCmd;
};
class MakeStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget
......@@ -123,6 +128,7 @@ public:
private:
void itemChanged(QListWidgetItem*);
void makeEdited();
void additionalArgumentsEdited();
void updateDetails();
void buildTargetsChanged();
......@@ -130,6 +136,7 @@ private:
private:
MakeStep *m_makeStep;
Utils::PathChooser *m_makePathChooser;
QListWidget *m_buildTargetsList;
QLineEdit *m_additionalArguments;
QString m_summaryText;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment