Commit daaf652f authored by dt's avatar dt
Browse files

Add a way to configure what cleaning does.

Task-Nr: 235965
parent 4b6130fe
......@@ -63,14 +63,18 @@ bool MakeStep::init(const QString &buildConfiguration)
setCommand(buildConfiguration, "make"); // TODO give full path here?
#endif // Q_OS_WIN
if (value("clean").isValid() && value("clean").toBool()) {
setArguments(buildConfiguration, QStringList() << "clean");
} else {
QStringList arguments = value(buildConfiguration, "buildTargets").toStringList();
arguments << additionalArguments(buildConfiguration);
setArguments(buildConfiguration, arguments); // TODO
setEnvironment(buildConfiguration, m_pro->environment(buildConfiguration));
if (!value(buildConfiguration, "cleanConfig").isValid() &&value("clean").isValid() && value("clean").toBool()) {
// Import old settings
setValue(buildConfiguration, "cleanConfig", true);
setAdditionalArguments(buildConfiguration, QStringList() << "clean");
}
QStringList arguments = value(buildConfiguration, "buildTargets").toStringList();
arguments << additionalArguments(buildConfiguration);
setArguments(buildConfiguration, arguments); // TODO
setEnvironment(buildConfiguration, m_pro->environment(buildConfiguration));
setIgnoreReturnValue(buildConfiguration, value(buildConfiguration, "cleanConfig").isValid());
return AbstractMakeStep::init(buildConfiguration);
}
......@@ -190,6 +194,12 @@ QString MakeStepConfigWidget::displayName() const
void MakeStepConfigWidget::init(const QString &buildConfiguration)
{
if (!m_makeStep->value(buildConfiguration, "cleanConfig").isValid() && m_makeStep->value("clean").isValid() && m_makeStep->value("clean").toBool()) {
// Import old settings
m_makeStep->setValue(buildConfiguration, "cleanConfig", true);
m_makeStep->setAdditionalArguments(buildConfiguration, QStringList() << "clean");
}
// disconnect to make the changes to the items
disconnect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
m_buildConfiguration = buildConfiguration;
......
......@@ -44,6 +44,7 @@ static const char * const PROCESS_WORKINGDIRECTORY = "abstractProcess.workingDir
static const char * const PROCESS_ARGUMENTS = "abstractProcess.arguments";
static const char * const PROCESS_ENABLED = "abstractProcess.enabled";
static const char * const PROCESS_ENVIRONMENT = "abstractProcess.Environment";
static const char * const PROCESS_IGNORE_RETURN_VALUE = "abstractProcess.IgnoreReturnValue";
AbstractProcessStep::AbstractProcessStep(Project *pro)
: BuildStep(pro)
......@@ -90,6 +91,16 @@ bool AbstractProcessStep::enabled(const QString &buildConfiguration) const
return value(buildConfiguration, PROCESS_ENABLED).toBool();
}
void AbstractProcessStep::setIgnoreReturnValue(const QString &buildConfiguration, bool b)
{
setValue(buildConfiguration, PROCESS_IGNORE_RETURN_VALUE, b);
}
bool AbstractProcessStep::ignoreReturnValue(const QString &buildConfiguration) const
{
return value(buildConfiguration, PROCESS_IGNORE_RETURN_VALUE).toBool();
}
void AbstractProcessStep::setEnvironment(const QString &buildConfiguration, Environment env)
{
setValue(buildConfiguration, PROCESS_ENVIRONMENT, env.toStringList());
......@@ -107,6 +118,7 @@ bool AbstractProcessStep::init(const QString &name)
m_enabled = enabled(name);
m_workingDirectory = workingDirectory(name);
m_environment = environment(name);
m_ignoreReturnValue = ignoreReturnValue(name);
return true;
}
......@@ -172,7 +184,7 @@ void AbstractProcessStep::processStarted()
bool AbstractProcessStep::processFinished(int exitCode, QProcess::ExitStatus status)
{
const bool ok = (status == QProcess::NormalExit && exitCode == 0);
const bool ok = status == QProcess::NormalExit && (exitCode == 0 || m_ignoreReturnValue);
if (ok) {
emit addToOutputWindow(tr("<font color=\"#0000ff\">Exited with code %1.</font>").arg(m_process->exitCode()));
} else {
......
......@@ -66,11 +66,11 @@ class PROJECTEXPLORER_EXPORT AbstractProcessStep : public BuildStep
Q_OBJECT
public:
AbstractProcessStep(Project *pro);
// reimplemented from BuildStep::init()
// You need to call this from YourBuildStep::init()
/// reimplemented from BuildStep::init()
/// You need to call this from YourBuildStep::init()
virtual bool init(const QString & name);
// reimplemented from BuildStep::init()
// You need to call this from YourBuildStep::run()
/// reimplemented from BuildStep::init()
/// You need to call this from YourBuildStep::run()
virtual void run(QFutureInterface<bool> &);
// pure virtual functions inheritated from BuildStep
......@@ -79,40 +79,48 @@ public:
virtual BuildStepConfigWidget *createConfigWidget() = 0;
virtual bool immutable() const = 0;
// setCommand() sets the executable to run in the \p buildConfiguration
/// setCommand() sets the executable to run in the \p buildConfiguration
void setCommand(const QString &buildConfiguration, const QString &cmd);
// returns the executable that is run for the \p buildConfiguration
/// returns the executable that is run for the \p buildConfiguration
QString command(const QString &buildConfiguration) const;
// sets the workingDirectory for the process for a buildConfiguration
// if no workingDirectory is set, it falls back to the projects workingDirectory TODO remove that magic, thats bad
/// sets the workingDirectory for the process for a buildConfiguration
/// if no workingDirectory is set, it falls back to the projects workingDirectory TODO remove that magic, thats bad
void setWorkingDirectory(const QString &buildConfiguration, const QString &workingDirectory);
//returns the workingDirectory for a \p buildConfiguration
/// returns the workingDirectory for a \p buildConfiguration
QString workingDirectory(const QString &buildConfiguration) const;
// sets the command line arguments used by the process for a \p buildConfiguration
/// sets the command line arguments used by the process for a \p buildConfiguration
void setArguments(const QString &buildConfiguration, const QStringList &arguments);
// returns the arguments used in the \p buildCOnfiguration
/// returns the arguments used in the \p buildCOnfiguration
QStringList arguments(const QString &buildConfiguration) const;
// enables or disables a BuildStep
// Disabled BuildSteps immediately return true from their run method
/// enables or disables a BuildStep
/// Disabled BuildSteps immediately return true from their run method
void setEnabled(const QString &buildConfiguration, bool b);
// returns wheter the BuildStep is disabled
/// returns wheter the BuildStep is disabled
bool enabled(const QString &buildConfiguration) const;
/*! If ignoreReturnValue is set to true, then the abstractprocess step will
return sucess even if the return value indicates otherwise
*/
void setIgnoreReturnValue(const QString &buildConfiguration,bool b);
/*! returns ignoreReturnValue
*/
bool ignoreReturnValue(const QString &buildConfiguration) const;
void setEnvironment(const QString &buildConfiguration, Environment env);
Environment environment(const QString &buildConfiguration) const;
protected:
// Called after the process is started
// the default implementation adds a process started message to the output message
/// Called after the process is started
/// the default implementation adds a process started message to the output message
virtual void processStarted();
// Called after the process Finished
// the default implementation adds a line to the output window
/// Called after the process Finished
/// the default implementation adds a line to the output window
virtual bool processFinished(int exitCode, QProcess::ExitStatus status);
// Called if the process could not be started,
// by default adds a message to the output window
/// Called if the process could not be started,
/// by default adds a message to the output window
virtual void processStartupFailed();
virtual void stdOut(const QString &line);
virtual void stdError(const QString &line);
......@@ -129,6 +137,7 @@ private:
QString m_command;
QStringList m_arguments;
bool m_enabled;
bool m_ignoreReturnValue;
QProcess *m_process;
QEventLoop *m_eventLoop;
ProjectExplorer::Environment m_environment;
......
......@@ -187,11 +187,13 @@ void BuildSettingsWidget::updateBuildSettings()
// Add pages
QWidget *dummyWidget = new QWidget(this);
QWidget *buildStepsWidget = new BuildStepsPage(m_project);
QWidget *cleanStepsWidget = new BuildStepsPage(m_project, true);
BuildStepConfigWidget *generalConfigWidget = m_project->createConfigWidget();
QList<BuildStepConfigWidget *> subConfigWidgets = m_project->subConfigWidgets();
m_ui.buildSettingsWidgets->addWidget(dummyWidget);
m_ui.buildSettingsWidgets->addWidget(buildStepsWidget);
m_ui.buildSettingsWidgets->addWidget(cleanStepsWidget);
m_ui.buildSettingsWidgets->addWidget(generalConfigWidget);
foreach (BuildStepConfigWidget *subConfigWidget, subConfigWidgets)
m_ui.buildSettingsWidgets->addWidget(subConfigWidget);
......@@ -232,6 +234,11 @@ void BuildSettingsWidget::updateBuildSettings()
m_itemToWidget.insert(buildStepsItem, buildStepsWidget);
buildStepsItem->setText(0, tr("Build Steps"));
buildConfigItem->addChild(buildStepsItem);
QTreeWidgetItem *cleanStepsItem = new QTreeWidgetItem();
m_itemToWidget.insert(cleanStepsItem, cleanStepsWidget);
cleanStepsItem->setText(0, tr("Clean Steps"));
buildConfigItem->addChild(cleanStepsItem);
}
m_ui.buildSettingsList->expandAll();
......
......@@ -39,10 +39,11 @@
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
BuildStepsPage::BuildStepsPage(Project *project) :
BuildStepsPage::BuildStepsPage(Project *project, bool clean) :
BuildStepConfigWidget(),
m_ui(new Ui::BuildStepsPage),
m_pro(project)
m_pro(project),
m_clean(clean)
{
m_ui->setupUi(this);
......@@ -74,8 +75,8 @@ BuildStepsPage::BuildStepsPage(Project *project) :
}
// Add buildsteps
foreach (BuildStep *bs, m_pro->buildSteps()) {
const QList<BuildStep *> &steps = m_clean ? m_pro->cleanSteps() : m_pro->buildSteps();
foreach (BuildStep *bs, steps) {
connect(bs, SIGNAL(displayNameChanged(BuildStep *, QString)),
this, SLOT(displayNameChanged(BuildStep *,QString)));
......@@ -94,13 +95,13 @@ BuildStepsPage::~BuildStepsPage()
void BuildStepsPage::displayNameChanged(BuildStep *bs, const QString & /* displayName */)
{
int index = m_pro->buildSteps().indexOf(bs);
int index = m_clean ? m_pro->cleanSteps().indexOf(bs) : m_pro->buildSteps().indexOf(bs);
m_ui->buildSettingsList->invisibleRootItem()->child(index)->setText(0, bs->displayName());
}
QString BuildStepsPage::displayName() const
{
return tr("Build Steps");
return m_clean ? tr("Clean Steps") : tr("Build Steps");
}
void BuildStepsPage::init(const QString &buildConfiguration)
......@@ -168,19 +169,23 @@ void BuildStepsPage::addBuildStep()
if (QAction *action = qobject_cast<QAction *>(sender())) {
QPair<QString, IBuildStepFactory *> pair = m_addBuildStepHash.value(action);
BuildStep *newStep = pair.second->create(m_pro, pair.first);
m_pro->insertBuildStep(0, newStep);
m_clean ? m_pro->insertCleanStep(0, newStep) : m_pro->insertBuildStep(0, newStep);
QTreeWidgetItem *buildStepItem = new QTreeWidgetItem();
buildStepItem->setText(0, newStep->displayName());
m_ui->buildSettingsList->invisibleRootItem()->insertChild(0, buildStepItem);
m_ui->buildSettingsWidget->insertWidget(0, newStep->createConfigWidget());
m_ui->buildSettingsList->setCurrentItem(buildStepItem);
connect(newStep, SIGNAL(displayNameChanged(BuildStep *, QString)),
this, SLOT(displayNameChanged(BuildStep *,QString)));
}
}
void BuildStepsPage::removeBuildStep()
{
int pos = m_ui->buildSettingsList->currentIndex().row();
if (m_pro->buildSteps().at(pos)->immutable())
const QList<BuildStep *> &steps = m_clean ? m_pro->cleanSteps() : m_pro->buildSteps();
if (steps.at(pos)->immutable())
return;
bool blockSignals = m_ui->buildSettingsList->blockSignals(true);
delete m_ui->buildSettingsList->invisibleRootItem()->takeChild(pos);
......@@ -192,7 +197,7 @@ void BuildStepsPage::removeBuildStep()
m_ui->buildSettingsList->setCurrentItem(m_ui->buildSettingsList->invisibleRootItem()->child(pos));
else
m_ui->buildSettingsList->setCurrentItem(m_ui->buildSettingsList->invisibleRootItem()->child(pos - 1));
m_pro->removeBuildStep(pos);
m_clean ? m_pro->removeCleanStep(pos) : m_pro->removeBuildStep(pos);
updateBuildStepButtonsState();
}
......@@ -203,12 +208,13 @@ void BuildStepsPage::upBuildStep()
return;
if (pos > m_ui->buildSettingsList->invisibleRootItem()->childCount()-1)
return;
if (m_pro->buildSteps().at(pos)->immutable() && m_pro->buildSteps().at(pos-1)->immutable())
const QList<BuildStep *> &steps = m_clean ? m_pro->cleanSteps() : m_pro->buildSteps();
if (steps.at(pos)->immutable() && steps.at(pos-1)->immutable())
return;
bool blockSignals = m_ui->buildSettingsList->blockSignals(true);
m_pro->moveBuildStepUp(pos);
buildStepMoveUp(pos);
m_clean ? m_pro->moveCleanStepUp(pos) : m_pro->moveBuildStepUp(pos);
stepMoveUp(pos);
QTreeWidgetItem *item = m_ui->buildSettingsList->invisibleRootItem()->child(pos - 1);
m_ui->buildSettingsList->blockSignals(blockSignals);
m_ui->buildSettingsList->setCurrentItem(item);
......@@ -222,12 +228,13 @@ void BuildStepsPage::downBuildStep()
return;
if (pos > m_ui->buildSettingsList->invisibleRootItem()->childCount() - 1)
return;
if (m_pro->buildSteps().at(pos)->immutable() && m_pro->buildSteps().at(pos - 1)->immutable())
const QList<BuildStep *> &steps = m_clean ? m_pro->cleanSteps() : m_pro->buildSteps();
if (steps.at(pos)->immutable() && steps.at(pos - 1)->immutable())
return;
bool blockSignals = m_ui->buildSettingsList->blockSignals(true);
m_pro->moveBuildStepUp(pos);
buildStepMoveUp(pos);
m_clean ? m_pro->moveCleanStepUp(pos) : m_pro->moveBuildStepUp(pos);
stepMoveUp(pos);
QTreeWidgetItem *item = m_ui->buildSettingsList->invisibleRootItem()->child(pos);
m_ui->buildSettingsList->blockSignals(blockSignals);
m_ui->buildSettingsList->setCurrentItem(item);
......@@ -246,7 +253,7 @@ void BuildStepsPage::changeEvent(QEvent *e)
}
}
void BuildStepsPage::buildStepMoveUp(int pos)
void BuildStepsPage::stepMoveUp(int pos)
{
QWidget *widget = m_ui->buildSettingsWidget->widget(pos);
m_ui->buildSettingsWidget->removeWidget(widget);
......@@ -259,10 +266,11 @@ void BuildStepsPage::updateBuildStepButtonsState()
{
int pos = m_ui->buildSettingsList->currentIndex().row();
m_ui->buildStepRemoveToolButton->setEnabled(!m_pro->buildSteps().at(pos)->immutable());
bool enableUp = pos>0 && !(m_pro->buildSteps().at(pos)->immutable() && m_pro->buildSteps().at(pos-1)->immutable());
const QList<BuildStep *> &steps = m_clean ? m_pro->cleanSteps() : m_pro->buildSteps();
m_ui->buildStepRemoveToolButton->setEnabled(!steps.at(pos)->immutable());
bool enableUp = pos>0 && !(steps.at(pos)->immutable() && steps.at(pos-1)->immutable());
m_ui->buildStepUpToolButton->setEnabled(enableUp);
bool enableDown = pos < (m_ui->buildSettingsList->invisibleRootItem()->childCount() - 1) &&
!(m_pro->buildSteps().at(pos)->immutable() && m_pro->buildSteps().at(pos+1)->immutable());
!(steps.at(pos)->immutable() && steps.at(pos+1)->immutable());
m_ui->buildStepDownToolButton->setEnabled(enableDown);
}
......@@ -50,7 +50,7 @@ class BuildStepsPage : public BuildStepConfigWidget {
Q_OBJECT
Q_DISABLE_COPY(BuildStepsPage)
public:
explicit BuildStepsPage(Project *project);
explicit BuildStepsPage(Project *project, bool clean = false);
virtual ~BuildStepsPage();
QString displayName() const;
......@@ -69,13 +69,14 @@ private slots:
void downBuildStep();
private:
void buildStepMoveUp(int pos);
void stepMoveUp(int pos);
void updateBuildStepButtonsState();
Ui::BuildStepsPage *m_ui;
Project *m_pro;
QString m_configuration;
QHash<QAction *, QPair<QString, ProjectExplorer::IBuildStepFactory *> > m_addBuildStepHash;
bool m_clean;
};
} // Internal
......
......@@ -94,6 +94,12 @@ void Project::removeCleanStep(int position)
m_cleanSteps.removeAt(position);
}
void Project::moveCleanStepUp(int position)
{
BuildStep *bs = m_cleanSteps.takeAt(position);
m_cleanSteps.insert(position - 1, bs);
}
void Project::addBuildConfiguration(const QString &name)
{
if (buildConfigurations().contains(name) )
......@@ -166,8 +172,6 @@ QList<BuildStep *> Project::cleanSteps() const
return m_cleanSteps;
}
void Project::saveSettings()
{
PersistentSettingsWriter writer;
......
......@@ -91,6 +91,7 @@ public:
QList<BuildStep *> cleanSteps() const;
void insertCleanStep(int position, BuildStep *step);
void removeCleanStep(int position);
void moveCleanStepUp(int position);
// Build configuration
void addBuildConfiguration(const QString &name);
......
......@@ -83,17 +83,18 @@ bool MakeStep::init(const QString &name)
}
setCommand(name, makeCmd);
bool skipMakeClean = false;
QStringList args;
if (value("clean").isValid() && value("clean").toBool()) {
args = QStringList() << "clean";
if (!QDir(workingDirectory).exists(QLatin1String("Makefile"))) {
skipMakeClean = true;
}
} else {
args = value(name, "makeargs").toStringList();
if (!value(name, "cleanConfig").isValid() && value("clean").isValid() && value("clean").toBool()) {
// Import old settings
setValue(name, "cleanConfig", true);
setValue(name, "makeargs", QStringList() << "clean");
}
// If we are cleaning, then make can fail with a error code, but that doesn't mean
// we should stop the clean queue
// That is mostly so that rebuild works on a alrady clean project
setIgnoreReturnValue(name, value(name, "cleanConfig").isValid());
QStringList args = value(name, "makeargs").toStringList();
// -w option enables "Enter"/"Leaving directory" messages, which we need for detecting the
// absolute file path
// FIXME doing this without the user having a way to override this is rather bad
......@@ -105,7 +106,7 @@ bool MakeStep::init(const QString &name)
args << "-w";
}
setEnabled(name, !skipMakeClean);
setEnabled(name, true);
setArguments(name, args);
ProjectExplorer::ToolChain::ToolChainType type = qobject_cast<Qt4Project *>(project())->qtVersion(name)->toolchainType();
......@@ -171,21 +172,26 @@ QString MakeStepConfigWidget::displayName() const
void MakeStepConfigWidget::init(const QString &buildConfiguration)
{
m_buildConfiguration = buildConfiguration;
bool showPage0 = buildConfiguration.isNull();
m_ui.stackedWidget->setCurrentIndex(showPage0 ? 0 : 1);
if (!showPage0) {
Qt4Project *pro = qobject_cast<Qt4Project *>(m_makeStep->project());
Q_ASSERT(pro);
m_ui.makeLabel->setText(tr("Override %1:").arg(pro->makeCommand(buildConfiguration)));
Qt4Project *pro = qobject_cast<Qt4Project *>(m_makeStep->project());
Q_ASSERT(pro);
if (!m_makeStep->value(buildConfiguration, "cleanConfig").isValid() && m_makeStep->value("clean").isValid() && m_makeStep->value("clean").toBool()) {
// Import old settings
m_makeStep->setValue(buildConfiguration, "cleanConfig", true);
m_makeStep->setValue(buildConfiguration, "makeargs", QStringList() << "clean");
}
const QString &makeCmd = m_makeStep->value(buildConfiguration, "makeCmd").toString();
m_ui.makeLineEdit->setText(makeCmd);
m_ui.stackedWidget->setCurrentIndex(1);
const QStringList &makeArguments =
m_ui.makeLabel->setText(tr("Override %1:").arg(pro->makeCommand(buildConfiguration)));
const QString &makeCmd = m_makeStep->value(buildConfiguration, "makeCmd").toString();
m_ui.makeLineEdit->setText(makeCmd);
const QStringList &makeArguments =
m_makeStep->value(buildConfiguration, "makeargs").toStringList();
m_ui.makeArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(makeArguments));
}
m_ui.makeArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(makeArguments));
}
void MakeStepConfigWidget::makeLineEditTextEdited()
......
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