Commit 72fe54db authored by dt's avatar dt

Remove value(name) and setValue(name, value) from BuildStep

parent 0fa60aa3
......@@ -667,7 +667,7 @@ bool CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
MakeStep *cleanMakeStep = new MakeStep(this);
insertCleanStep(0, cleanMakeStep);
cleanMakeStep->setValue("clean", true);
cleanMakeStep->setClean(true);
setActiveBuildConfiguration(bc);
} else {
// We have a user file, but we could still be missing the cbp file
......
......@@ -42,7 +42,7 @@ using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
MakeStep::MakeStep(CMakeProject *pro)
: AbstractMakeStep(pro), m_pro(pro)
: AbstractMakeStep(pro), m_pro(pro), m_clean(false)
{
m_percentProgress = QRegExp("^\\[\\s*(\\d*)%\\]");
}
......@@ -52,27 +52,70 @@ MakeStep::~MakeStep()
}
void MakeStep::setClean(bool clean)
{
m_clean = clean;
}
void MakeStep::restoreFromMap(const QMap<QString, QVariant> &map)
{
if (map.value("clean").isValid() && map.value("clean").toBool())
m_clean = true;
ProjectExplorer::AbstractMakeStep::restoreFromMap(map);
}
void MakeStep::storeIntoMap(QMap<QString, QVariant> &map)
{
if (m_clean)
map["clean"] = true;
ProjectExplorer::AbstractMakeStep::storeIntoMap(map);
}
void MakeStep::restoreFromMap(const QString &buildConfiguration, const QMap<QString, QVariant> &map)
{
m_values[buildConfiguration].buildTargets = map["buildTargets"].toStringList();
m_values[buildConfiguration].additionalArguments = map["additionalArguments"].toStringList();
ProjectExplorer::AbstractMakeStep::restoreFromMap(buildConfiguration, map);
}
void MakeStep::storeIntoMap(const QString &buildConfiguration, QMap<QString, QVariant> &map)
{
map["buildTargets"] = m_values.value(buildConfiguration).buildTargets;
map["additionalArguments"] = m_values.value(buildConfiguration).additionalArguments;
ProjectExplorer::AbstractMakeStep::storeIntoMap(buildConfiguration, map);
}
void MakeStep::addBuildConfiguration(const QString & name)
{
m_values.insert(name, MakeStepSettings());
}
void MakeStep::removeBuildConfiguration(const QString & name)
{
m_values.remove(name);
}
void MakeStep::copyBuildConfiguration(const QString &source, const QString &dest)
{
m_values.insert(dest, m_values.value(source));
}
bool MakeStep::init(const QString &buildConfiguration)
{
ProjectExplorer::BuildConfiguration *bc = m_pro->buildConfiguration(buildConfiguration);
setBuildParser(m_pro->buildParser(bc));
setEnabled(buildConfiguration, true);
setWorkingDirectory(buildConfiguration, m_pro->buildDirectory(bc));
setEnabled(true);
setWorkingDirectory(m_pro->buildDirectory(bc));
setCommand(buildConfiguration, m_pro->toolChain(bc)->makeCommand());
if (!value(buildConfiguration, "cleanConfig").isValid() &&value("clean").isValid() && value("clean").toBool()) {
// Import old settings
setValue(buildConfiguration, "cleanConfig", true);
setAdditionalArguments(buildConfiguration, QStringList() << "clean");
}
setCommand(m_pro->toolChain(bc)->makeCommand());
QStringList arguments = value(buildConfiguration, "buildTargets").toStringList();
QStringList arguments = m_values.value(buildConfiguration).buildTargets;
arguments << additionalArguments(buildConfiguration);
setArguments(buildConfiguration, arguments); // TODO
setEnvironment(buildConfiguration, m_pro->environment(bc));
setIgnoreReturnValue(buildConfiguration, value(buildConfiguration, "cleanConfig").isValid());
setArguments(arguments); // TODO
setEnvironment(m_pro->environment(bc));
setIgnoreReturnValue(m_clean);
return AbstractMakeStep::init(buildConfiguration);
}
......@@ -125,28 +168,27 @@ CMakeProject *MakeStep::project() const
bool MakeStep::buildsTarget(const QString &buildConfiguration, const QString &target) const
{
return value(buildConfiguration, "buildTargets").toStringList().contains(target);
return m_values.value(buildConfiguration).buildTargets.contains(target);
}
void MakeStep::setBuildTarget(const QString &buildConfiguration, const QString &target, bool on)
{
QStringList old = value(buildConfiguration, "buildTargets").toStringList();
QStringList old = m_values.value(buildConfiguration).buildTargets;
if (on && !old.contains(target))
old.append(target);
old << target;
else if(!on && old.contains(target))
old.removeOne(target);
setValue(buildConfiguration, "buildTargets", old);
m_values[buildConfiguration].buildTargets = old;
}
QStringList MakeStep::additionalArguments(const QString &buildConfiguration) const
{
return value(buildConfiguration, "additionalArguments").toStringList();
return m_values.value(buildConfiguration).additionalArguments;
}
void MakeStep::setAdditionalArguments(const QString &buildConfiguration, const QStringList &list)
{
setValue(buildConfiguration, "additionalArguments", list);
m_values[buildConfiguration].additionalArguments = list;
}
//
......@@ -202,12 +244,6 @@ 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;
......@@ -225,7 +261,7 @@ void MakeStepConfigWidget::init(const QString &buildConfiguration)
void MakeStepConfigWidget::updateDetails()
{
QStringList arguments = m_makeStep->value(m_buildConfiguration, "buildTargets").toStringList();
QStringList arguments = m_makeStep->m_values.value(m_buildConfiguration).buildTargets;
arguments << m_makeStep->additionalArguments(m_buildConfiguration);
m_summaryText = tr("<b>Make:</b> %1 %2")
.arg(m_makeStep->project()->toolChain(
......
......@@ -43,9 +43,17 @@ namespace Internal {
class CMakeProject;
struct MakeStepSettings
{
QStringList buildTargets;
QStringList additionalArguments;
};
class MakeStep : public ProjectExplorer::AbstractMakeStep
{
Q_OBJECT
friend class MakeStepConfigWidget; // TODO remove
// This is for modifying m_values
public:
MakeStep(CMakeProject *pro);
~MakeStep();
......@@ -62,13 +70,27 @@ public:
void setBuildTarget(const QString &buildConfiguration, const QString &target, bool on);
QStringList additionalArguments(const QString &buildConfiguration) const;
void setAdditionalArguments(const QString &buildConfiguration, const QStringList &list);
virtual void restoreFromMap(const QMap<QString, QVariant> &map);
virtual void storeIntoMap(QMap<QString, QVariant> &map);
void setClean(bool clean);
virtual void restoreFromMap(const QString &buildConfiguration, const QMap<QString, QVariant> &map);
virtual void storeIntoMap(const QString &buildConfiguration, QMap<QString, QVariant> &map);
virtual void addBuildConfiguration(const QString & name);
virtual void removeBuildConfiguration(const QString & name);
virtual void copyBuildConfiguration(const QString &source, const QString &dest);
protected:
// For parsing [ 76%]
virtual void stdOut(const QString &line);
private:
CMakeProject *m_pro;
bool m_clean;
QRegExp m_percentProgress;
QFutureInterface<bool> *m_futureInterface;
QMap<QString, MakeStepSettings> m_values;
};
class MakeStepConfigWidget :public ProjectExplorer::BuildStepConfigWidget
......
......@@ -63,24 +63,56 @@ bool GenericMakeStep::init(const QString &buildConfigurationName)
setBuildParser(buildParser);
qDebug() << "*** build parser:" << buildParser;
setEnabled(buildConfigurationName, true);
setEnabled(true);
Core::VariableManager *vm = Core::VariableManager::instance();
const QString rawBuildDir = m_pro->buildDirectory(bc);
const QString buildDir = vm->resolve(rawBuildDir);
setWorkingDirectory(buildConfigurationName, buildDir);
setWorkingDirectory(buildDir);
setCommand(buildConfigurationName, makeCommand(buildConfigurationName));
setArguments(buildConfigurationName, replacedArguments(buildConfigurationName));
setCommand(makeCommand(buildConfigurationName));
setArguments(replacedArguments(buildConfigurationName));
setEnvironment(buildConfigurationName, m_pro->environment(bc));
setEnvironment(m_pro->environment(bc));
return AbstractMakeStep::init(buildConfigurationName);
}
void GenericMakeStep::restoreFromMap(const QString &buildConfiguration, const QMap<QString, QVariant> &map)
{
m_values[buildConfiguration].buildTargets = map.value("buildTargets").toStringList();
m_values[buildConfiguration].makeArguments = map.value("makeArguments").toStringList();
m_values[buildConfiguration].makeCommand = map.value("makeCommand").toString();
ProjectExplorer::AbstractMakeStep::restoreFromMap(buildConfiguration, map);
}
void GenericMakeStep::storeIntoMap(const QString &buildConfiguration, QMap<QString, QVariant> &map)
{
map["buildTargets"] = m_values.value(buildConfiguration).buildTargets;
map["makeArguments"] = m_values.value(buildConfiguration).makeArguments;
map["makeCommand"] = m_values.value(buildConfiguration).makeCommand;
ProjectExplorer::AbstractMakeStep::storeIntoMap(buildConfiguration, map);
}
void GenericMakeStep::addBuildConfiguration(const QString & name)
{
m_values.insert(name, GenericMakeStepSettings());
}
void GenericMakeStep::removeBuildConfiguration(const QString & name)
{
m_values.remove(name);
}
void GenericMakeStep::copyBuildConfiguration(const QString &source, const QString &dest)
{
m_values.insert(dest, m_values.value(source));
}
QStringList GenericMakeStep::replacedArguments(const QString &buildConfiguration) const
{
Core::VariableManager *vm = Core::VariableManager::instance();
const QStringList targets = value(buildConfiguration, "buildTargets").toStringList();
QStringList arguments = value(buildConfiguration, "makeArguments").toStringList();
const QStringList targets = m_values.value(buildConfiguration).buildTargets;
QStringList arguments = m_values.value(buildConfiguration).makeArguments;
QStringList replacedArguments;
foreach (const QString &arg, arguments) {
replacedArguments.append(vm->resolve(arg));
......@@ -93,7 +125,7 @@ QStringList GenericMakeStep::replacedArguments(const QString &buildConfiguration
QString GenericMakeStep::makeCommand(const QString &buildConfiguration) const
{
QString command = value(buildConfiguration, "makeCommand").toString();
QString command = m_values.value(buildConfiguration).makeCommand;
if (command.isEmpty()) {
if (ProjectExplorer::ToolChain *toolChain = m_pro->toolChain())
command = toolChain->makeCommand();
......@@ -135,17 +167,18 @@ GenericProject *GenericMakeStep::project() const
bool GenericMakeStep::buildsTarget(const QString &buildConfiguration, const QString &target) const
{
return value(buildConfiguration, "buildTargets").toStringList().contains(target);
return m_values.value(buildConfiguration).buildTargets.contains(target);
}
void GenericMakeStep::setBuildTarget(const QString &buildConfiguration, const QString &target, bool on)
{
QStringList old = value(buildConfiguration, "buildTargets").toStringList();
QStringList old = m_values.value(buildConfiguration).buildTargets;
if (on && !old.contains(target))
old << target;
old << target;
else if(!on && old.contains(target))
old.removeOne(target);
setValue(buildConfiguration, "buildTargets", old);
m_values[buildConfiguration].buildTargets = old;
}
//
......@@ -196,11 +229,10 @@ void GenericMakeStepConfigWidget::init(const QString &buildConfiguration)
updateMakeOverrrideLabel();
QString makeCommand = m_makeStep->value(buildConfiguration, "makeCommand").toString();
QString makeCommand = m_makeStep->m_values.value(buildConfiguration).makeCommand;
m_ui->makeLineEdit->setText(makeCommand);
const QStringList &makeArguments =
m_makeStep->value(buildConfiguration, "makeArguments").toStringList();
const QStringList &makeArguments = m_makeStep->m_values.value(buildConfiguration).makeArguments;
m_ui->makeArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(makeArguments));
// Disconnect to make the changes to the items
......@@ -240,15 +272,15 @@ void GenericMakeStepConfigWidget::itemChanged(QListWidgetItem *item)
void GenericMakeStepConfigWidget::makeLineEditTextEdited()
{
QTC_ASSERT(!m_buildConfiguration.isNull(), return);
m_makeStep->setValue(m_buildConfiguration, "makeCommand", m_ui->makeLineEdit->text());
m_makeStep->m_values[m_buildConfiguration].makeCommand = m_ui->makeLineEdit->text();
updateDetails();
}
void GenericMakeStepConfigWidget::makeArgumentsLineEditTextEdited()
{
QTC_ASSERT(!m_buildConfiguration.isNull(), return);
m_makeStep->setValue(m_buildConfiguration, "makeArguments",
ProjectExplorer::Environment::parseCombinedArgString(m_ui->makeArgumentsLineEdit->text()));
m_makeStep->m_values[m_buildConfiguration].makeArguments =
ProjectExplorer::Environment::parseCombinedArgString(m_ui->makeArgumentsLineEdit->text());
updateDetails();
}
......
......@@ -44,10 +44,20 @@ namespace GenericProjectManager {
namespace Internal {
class GenericProject;
class GenericMakeStepConfigWidget;
struct GenericMakeStepSettings
{
QStringList buildTargets;
QStringList makeArguments;
QString makeCommand;
};
class GenericMakeStep : public ProjectExplorer::AbstractMakeStep
{
Q_OBJECT
friend class GenericMakeStepConfigWidget; // TODO remove again?
// Currently the ConfigWidget accesses the m_values directly
public:
GenericMakeStep(GenericProject *pro);
~GenericMakeStep();
......@@ -64,8 +74,16 @@ public:
void setBuildTarget(const QString &buildConfiguration, const QString &target, bool on);
QStringList replacedArguments(const QString &buildConfiguration) const;
QString makeCommand(const QString &buildConfiguration) const;
virtual void restoreFromMap(const QString &buildConfiguration, const QMap<QString, QVariant> &map);
virtual void storeIntoMap(const QString &buildConfiguration, QMap<QString, QVariant> &map);
virtual void addBuildConfiguration(const QString & name);
virtual void removeBuildConfiguration(const QString & name);
virtual void copyBuildConfiguration(const QString &source, const QString &dest);
private:
GenericProject *m_pro;
QMap<QString, GenericMakeStepSettings> m_values;
};
class GenericMakeStepConfigWidget :public ProjectExplorer::BuildStepConfigWidget
......
......@@ -64,7 +64,7 @@ bool AbstractMakeStep::init(const QString &buildConfiguration)
m_buildConfiguration = buildConfiguration;
m_openDirectories.clear();
addDirectory(workingDirectory(buildConfiguration));
addDirectory(workingDirectory());
return AbstractProcessStep::init(buildConfiguration);
}
......
......@@ -39,92 +39,54 @@
using namespace ProjectExplorer;
static const char * const PROCESS_COMMAND = "abstractProcess.command";
static const char * const PROCESS_WORKINGDIRECTORY = "abstractProcess.workingDirectory";
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)
{
}
void AbstractProcessStep::setCommand(const QString &buildConfiguration, const QString &cmd)
{
setValue(buildConfiguration, PROCESS_COMMAND, cmd);
}
QString AbstractProcessStep::command(const QString &buildConfiguration) const
{
QString result = value(buildConfiguration, PROCESS_COMMAND).toString();
if (QFileInfo(result).isRelative()) {
QString searchInPath = environment(buildConfiguration).searchInPath(result);
if (!searchInPath.isEmpty())
result = searchInPath;
}
return result;
}
void AbstractProcessStep::setWorkingDirectory(const QString &buildConfiguration, const QString &workingDirectory)
{
setValue(buildConfiguration, PROCESS_WORKINGDIRECTORY, workingDirectory);
}
QString AbstractProcessStep::workingDirectory(const QString &buildConfiguration) const
{
return value(buildConfiguration, PROCESS_WORKINGDIRECTORY).toString();
}
void AbstractProcessStep::setArguments(const QString &buildConfiguration, const QStringList &arguments)
void AbstractProcessStep::setCommand(const QString &cmd)
{
setValue(buildConfiguration, PROCESS_ARGUMENTS, arguments);
m_command = cmd;
}
QStringList AbstractProcessStep::arguments(const QString &buildConfiguration) const
QString AbstractProcessStep::workingDirectory() const
{
return value(buildConfiguration, PROCESS_ARGUMENTS).toStringList();
return m_workingDirectory;
}
void AbstractProcessStep::setEnabled(const QString &buildConfiguration, bool b)
void AbstractProcessStep::setWorkingDirectory(const QString &workingDirectory)
{
setValue(buildConfiguration, PROCESS_ENABLED, b);
m_workingDirectory = workingDirectory;
}
bool AbstractProcessStep::enabled(const QString &buildConfiguration) const
void AbstractProcessStep::setArguments(const QStringList &arguments)
{
return value(buildConfiguration, PROCESS_ENABLED).toBool();
m_arguments = arguments;
}
void AbstractProcessStep::setIgnoreReturnValue(const QString &buildConfiguration, bool b)
void AbstractProcessStep::setEnabled(bool b)
{
setValue(buildConfiguration, PROCESS_IGNORE_RETURN_VALUE, b);
m_enabled = b;
}
bool AbstractProcessStep::ignoreReturnValue(const QString &buildConfiguration) const
void AbstractProcessStep::setIgnoreReturnValue(bool b)
{
return value(buildConfiguration, PROCESS_IGNORE_RETURN_VALUE).toBool();
m_ignoreReturnValue = b;
}
void AbstractProcessStep::setEnvironment(const QString &buildConfiguration, Environment env)
void AbstractProcessStep::setEnvironment(Environment env)
{
setValue(buildConfiguration, PROCESS_ENVIRONMENT, env.toStringList());
m_environment = env;
}
Environment AbstractProcessStep::environment(const QString &buildConfiguration) const
bool AbstractProcessStep::init(const QString &buildConfiguration)
{
return Environment(value(buildConfiguration, PROCESS_ENVIRONMENT).toStringList());
}
bool AbstractProcessStep::init(const QString &name)
{
m_command = command(name);
m_arguments = arguments(name);
m_enabled = enabled(name);
m_workingDirectory = workingDirectory(name);
m_environment = environment(name);
m_ignoreReturnValue = ignoreReturnValue(name);
Q_UNUSED(buildConfiguration)
if (QFileInfo(m_command).isRelative()) {
QString searchInPath = m_environment.searchInPath(m_command);
if (!searchInPath.isEmpty())
m_command = searchInPath;
}
return true;
}
......
......@@ -80,39 +80,34 @@ public:
virtual bool immutable() const = 0;
/// 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
QString command(const QString &buildConfiguration) const;
/// should be called from init()
void setCommand(const QString &cmd);
/// 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
QString workingDirectory(const QString &buildConfiguration) const;
/// should be called from init()
void setWorkingDirectory(const QString &workingDirectory);
/// 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
QStringList arguments(const QString &buildConfiguration) const;
/// should be called from init()
void setArguments(const QStringList &arguments);
/// 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
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;
/// should be called from init()
void setEnabled(bool b);
/// If ignoreReturnValue is set to true, then the abstractprocess step will
/// return sucess even if the return value indicates otherwise
/// should be called from init
void setIgnoreReturnValue(bool b);
/// Set the Environment for running the command
/// should be called from init()
void setEnvironment(Environment env);
// TODO can I remove this?
QString workingDirectory() const;
protected:
/// Called after the process is started
/// the default implementation adds a process started message to the output message
virtual void processStarted();
......@@ -122,7 +117,13 @@ protected:
/// Called if the process could not be started,
/// by default adds a message to the output window
virtual void processStartupFailed();
/// Called for each line of output on stdOut()
/// the default implementation adds the line to the
/// application output window
virtual void stdOut(const QString &line);
/// Called for each line of output on StdErrror()
/// the default implementation adds the line to the
/// application output window
virtual void stdError(const QString &line);
private slots:
void processReadyReadStdOutput();
......
......@@ -39,94 +39,55 @@ using namespace ProjectExplorer;
BuildStep::BuildStep(Project * pro)
: m_project(pro)
{
m_configuration = new BuildConfiguration("");
}
BuildStep::~BuildStep()
{
qDeleteAll(m_buildConfigurations