forked from qt-creator/qt-creator
Make BuildSteps one instance per BuildConfiguration
Enables users to change which buildsteps get run per buildconfiguration. Some further tweaks are probably necessary. This is a rather big change, though it should work. :)
This commit is contained in:
@@ -44,8 +44,17 @@ using ExtensionSystem::PluginManager;
|
||||
using namespace Qt4ProjectManager;
|
||||
using namespace Qt4ProjectManager::Internal;
|
||||
|
||||
MakeStep::MakeStep(Qt4Project * project)
|
||||
: AbstractMakeStep(project), m_clean(false)
|
||||
MakeStep::MakeStep(Qt4Project * project, ProjectExplorer::BuildConfiguration *bc)
|
||||
: AbstractMakeStep(project, bc), m_clean(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MakeStep::MakeStep(MakeStep *bs, ProjectExplorer::BuildConfiguration *bc)
|
||||
: AbstractMakeStep(bs, bc),
|
||||
m_clean(bs->m_clean),
|
||||
m_makeargs(bs->m_makeargs),
|
||||
m_makeCmd(bs->m_makeCmd)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -60,54 +69,34 @@ void MakeStep::setClean(bool clean)
|
||||
m_clean = clean;
|
||||
}
|
||||
|
||||
void MakeStep::restoreFromMap(const QMap<QString, QVariant> &map)
|
||||
void MakeStep::restoreFromGlobalMap(const QMap<QString, QVariant> &map)
|
||||
{
|
||||
if (map.value("clean").isValid() && map.value("clean").toBool())
|
||||
m_clean = true;
|
||||
ProjectExplorer::AbstractMakeStep::restoreFromMap(map);
|
||||
ProjectExplorer::AbstractMakeStep::restoreFromGlobalMap(map);
|
||||
}
|
||||
|
||||
void MakeStep::storeIntoMap(QMap<QString, QVariant> &map)
|
||||
void MakeStep::restoreFromLocalMap(const QMap<QString, QVariant> &map)
|
||||
{
|
||||
m_makeargs = map.value("makeargs").toStringList();
|
||||
m_makeCmd = map.value("makeCmd").toString();
|
||||
if (map.value("clean").isValid() && map.value("clean").toBool())
|
||||
m_clean = true;
|
||||
ProjectExplorer::AbstractMakeStep::restoreFromLocalMap(map);
|
||||
}
|
||||
|
||||
void MakeStep::storeIntoLocalMap(QMap<QString, QVariant> &map)
|
||||
{
|
||||
map["makeargs"] = m_makeargs;
|
||||
map["makeCmd"] = m_makeCmd;
|
||||
if (m_clean)
|
||||
map["clean"] = true;
|
||||
ProjectExplorer::AbstractMakeStep::storeIntoMap(map);
|
||||
ProjectExplorer::AbstractMakeStep::storeIntoLocalMap(map);
|
||||
}
|
||||
|
||||
void MakeStep::restoreFromMap(const QString &buildConfiguration, const QMap<QString, QVariant> &map)
|
||||
bool MakeStep::init()
|
||||
{
|
||||
m_values[buildConfiguration].makeargs = map.value("makeargs").toStringList();
|
||||
m_values[buildConfiguration].makeCmd = map.value("makeCmd").toString();
|
||||
ProjectExplorer::AbstractMakeStep::restoreFromMap(buildConfiguration, map);
|
||||
}
|
||||
|
||||
void MakeStep::storeIntoMap(const QString &buildConfiguration, QMap<QString, QVariant> &map)
|
||||
{
|
||||
map["makeargs"] = m_values.value(buildConfiguration).makeargs;
|
||||
map["makeCmd"] = m_values.value(buildConfiguration).makeCmd;
|
||||
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 &name)
|
||||
{
|
||||
m_buildConfiguration = name;
|
||||
ProjectExplorer::BuildConfiguration *bc = project()->buildConfiguration(name);
|
||||
ProjectExplorer::BuildConfiguration *bc = buildConfiguration();
|
||||
Environment environment = project()->environment(bc);
|
||||
setEnvironment(environment);
|
||||
|
||||
@@ -116,8 +105,8 @@ bool MakeStep::init(const QString &name)
|
||||
setWorkingDirectory(workingDirectory);
|
||||
|
||||
QString makeCmd = qt4project->makeCommand(bc);
|
||||
if (!m_values.value(name).makeCmd.isEmpty())
|
||||
makeCmd = m_values.value(name).makeCmd;
|
||||
if (!m_makeCmd.isEmpty())
|
||||
makeCmd = m_makeCmd;
|
||||
if (!QFileInfo(makeCmd).isAbsolute()) {
|
||||
// Try to detect command in environment
|
||||
QString tmp = environment.searchInPath(makeCmd);
|
||||
@@ -134,7 +123,7 @@ bool MakeStep::init(const QString &name)
|
||||
// we should stop the clean queue
|
||||
// That is mostly so that rebuild works on a alrady clean project
|
||||
setIgnoreReturnValue(m_clean);
|
||||
QStringList args = m_values.value(name).makeargs;
|
||||
QStringList args = m_makeargs;
|
||||
if (!m_clean) {
|
||||
if (!qt4project->defaultMakeTarget(bc).isEmpty())
|
||||
args << qt4project->defaultMakeTarget(bc);
|
||||
@@ -150,7 +139,7 @@ bool MakeStep::init(const QString &name)
|
||||
if (toolchain)
|
||||
type = toolchain->type();
|
||||
if (type != ProjectExplorer::ToolChain::MSVC && type != ProjectExplorer::ToolChain::WINCE) {
|
||||
if (m_values.value(name).makeCmd.isEmpty())
|
||||
if (m_makeCmd.isEmpty())
|
||||
args << "-w";
|
||||
}
|
||||
|
||||
@@ -169,7 +158,7 @@ bool MakeStep::init(const QString &name)
|
||||
else
|
||||
setBuildParser(ProjectExplorer::Constants::BUILD_PARSER_GCC);
|
||||
|
||||
return AbstractMakeStep::init(name);
|
||||
return AbstractMakeStep::init();
|
||||
}
|
||||
|
||||
void MakeStep::run(QFutureInterface<bool> & fi)
|
||||
@@ -202,14 +191,14 @@ ProjectExplorer::BuildStepConfigWidget *MakeStep::createConfigWidget()
|
||||
return new MakeStepConfigWidget(this);
|
||||
}
|
||||
|
||||
QStringList MakeStep::makeArguments(const QString &buildConfiguration)
|
||||
QStringList MakeStep::makeArguments()
|
||||
{
|
||||
return m_values.value(buildConfiguration).makeargs;
|
||||
return m_makeargs;
|
||||
}
|
||||
|
||||
void MakeStep::setMakeArguments(const QString &buildConfiguration, const QStringList &arguments)
|
||||
void MakeStep::setMakeArguments(const QStringList &arguments)
|
||||
{
|
||||
m_values[buildConfiguration].makeargs = arguments;
|
||||
m_makeargs = arguments;
|
||||
emit changed();
|
||||
}
|
||||
|
||||
@@ -237,18 +226,18 @@ void MakeStepConfigWidget::updateMakeOverrideLabel()
|
||||
{
|
||||
Qt4Project *qt4project = qobject_cast<Qt4Project *>(m_makeStep->project());
|
||||
m_ui.makeLabel->setText(tr("Override %1:").arg(qt4project->
|
||||
makeCommand(qt4project->buildConfiguration(m_buildConfiguration))));
|
||||
makeCommand(m_makeStep->buildConfiguration())));
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::updateDetails()
|
||||
{
|
||||
Qt4Project *pro = static_cast<Qt4Project *>(m_makeStep->project());
|
||||
ProjectExplorer::BuildConfiguration *bc = pro->buildConfiguration(m_buildConfiguration);
|
||||
ProjectExplorer::BuildConfiguration *bc = m_makeStep->buildConfiguration();
|
||||
QString workingDirectory = pro->buildDirectory(bc);
|
||||
|
||||
QString makeCmd = pro->makeCommand(bc);
|
||||
if (!m_makeStep->m_values.value(m_buildConfiguration).makeCmd.isEmpty())
|
||||
makeCmd = m_makeStep->m_values.value(m_buildConfiguration).makeCmd;
|
||||
if (!m_makeStep->m_makeCmd.isEmpty())
|
||||
makeCmd = m_makeStep->m_makeCmd;
|
||||
if (!QFileInfo(makeCmd).isAbsolute()) {
|
||||
Environment environment = pro->environment(bc);
|
||||
// Try to detect command in environment
|
||||
@@ -265,13 +254,13 @@ void MakeStepConfigWidget::updateDetails()
|
||||
// FIXME doing this without the user having a way to override this is rather bad
|
||||
// so we only do it for unix and if the user didn't override the make command
|
||||
// but for now this is the least invasive change
|
||||
QStringList args = m_makeStep->makeArguments(m_buildConfiguration);
|
||||
QStringList args = m_makeStep->makeArguments();
|
||||
ProjectExplorer::ToolChain::ToolChainType t = ProjectExplorer::ToolChain::UNKNOWN;
|
||||
ProjectExplorer::ToolChain *toolChain = pro->toolChain(bc);
|
||||
if (toolChain)
|
||||
t = toolChain->type();
|
||||
if (t != ProjectExplorer::ToolChain::MSVC && t != ProjectExplorer::ToolChain::WINCE) {
|
||||
if (m_makeStep->m_values.value(m_buildConfiguration).makeCmd.isEmpty())
|
||||
if (m_makeStep->m_makeCmd.isEmpty())
|
||||
args << "-w";
|
||||
}
|
||||
m_summaryText = tr("<b>Make:</b> %1 %2 in %3").arg(QFileInfo(makeCmd).fileName(), args.join(" "),
|
||||
@@ -291,35 +280,31 @@ QString MakeStepConfigWidget::displayName() const
|
||||
|
||||
void MakeStepConfigWidget::update()
|
||||
{
|
||||
init(m_buildConfiguration);
|
||||
init();
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::init(const QString &buildConfiguration)
|
||||
void MakeStepConfigWidget::init()
|
||||
{
|
||||
m_buildConfiguration = buildConfiguration;
|
||||
|
||||
updateMakeOverrideLabel();
|
||||
|
||||
const QString &makeCmd = m_makeStep->m_values.value(buildConfiguration).makeCmd;
|
||||
const QString &makeCmd = m_makeStep->m_makeCmd;
|
||||
m_ui.makeLineEdit->setText(makeCmd);
|
||||
|
||||
const QStringList &makeArguments = m_makeStep->makeArguments(buildConfiguration);
|
||||
const QStringList &makeArguments = m_makeStep->makeArguments();
|
||||
m_ui.makeArgumentsLineEdit->setText(ProjectExplorer::Environment::joinArgumentList(makeArguments));
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::makeLineEditTextEdited()
|
||||
{
|
||||
Q_ASSERT(!m_buildConfiguration.isNull());
|
||||
m_makeStep->m_values[m_buildConfiguration].makeCmd = m_ui.makeLineEdit->text();
|
||||
m_makeStep->m_makeCmd = m_ui.makeLineEdit->text();
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
void MakeStepConfigWidget::makeArgumentsLineEditTextEdited()
|
||||
{
|
||||
Q_ASSERT(!m_buildConfiguration.isNull());
|
||||
m_makeStep->setMakeArguments(m_buildConfiguration,
|
||||
ProjectExplorer::Environment::parseCombinedArgString(m_ui.makeArgumentsLineEdit->text()));
|
||||
m_makeStep->setMakeArguments(
|
||||
ProjectExplorer::Environment::parseCombinedArgString(m_ui.makeArgumentsLineEdit->text()));
|
||||
updateDetails();
|
||||
}
|
||||
|
||||
@@ -340,10 +325,15 @@ bool MakeStepFactory::canCreate(const QString & name) const
|
||||
return (name == Constants::MAKESTEP);
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStep * MakeStepFactory::create(ProjectExplorer::Project * pro, const QString & name) const
|
||||
ProjectExplorer::BuildStep *MakeStepFactory::create(ProjectExplorer::Project *pro, ProjectExplorer::BuildConfiguration *bc, const QString & name) const
|
||||
{
|
||||
Q_UNUSED(name)
|
||||
return new MakeStep(static_cast<Qt4Project *>(pro));
|
||||
return new MakeStep(static_cast<Qt4Project *>(pro), bc);
|
||||
}
|
||||
|
||||
ProjectExplorer::BuildStep *MakeStepFactory::clone(ProjectExplorer::BuildStep *bs, ProjectExplorer::BuildConfiguration *bc) const
|
||||
{
|
||||
return new MakeStep(static_cast<MakeStep *>(bs), bc);
|
||||
}
|
||||
|
||||
QStringList MakeStepFactory::canCreateForProject(ProjectExplorer::Project *pro) const
|
||||
|
||||
Reference in New Issue
Block a user