Commit f3bdeb8c authored by con's avatar con
Browse files

Share the code for determining used qmake arguments.

Move the code that compares the Qt version's debug|release property
with the build configuration's debug|release property
to the new build configuration class.

Reviewed-by: dt
parent 65c80300
......@@ -87,22 +87,17 @@ QStringList QMakeStep::allArguments()
arguments << QLatin1String("-unix");
#endif
if (bc->value("buildConfiguration").isValid()) {
QStringList configarguments;
QtVersion::QmakeBuildConfigs defaultBuildConfiguration = bc->qtVersion()->defaultBuildConfig();
QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(bc->value("buildConfiguration").toInt());
if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll))
configarguments << "CONFIG-=debug_and_release";
if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (projectBuildConfiguration & QtVersion::BuildAll))
configarguments << "CONFIG+=debug_and_release";
if ((defaultBuildConfiguration & QtVersion::DebugBuild) && !(projectBuildConfiguration & QtVersion::DebugBuild))
configarguments << "CONFIG+=release";
if (!(defaultBuildConfiguration & QtVersion::DebugBuild) && (projectBuildConfiguration & QtVersion::DebugBuild))
configarguments << "CONFIG+=debug";
if (!configarguments.isEmpty())
arguments << configarguments;
} else {
qWarning()<< "The project should always have a qmake build configuration set";
// Find out what flags we pass on to qmake
QStringList addedUserConfigArguments;
QStringList removedUserConfigArguments;
bc->getConfigCommandLineArguments(&addedUserConfigArguments, &removedUserConfigArguments);
if (!removedUserConfigArguments.isEmpty()) {
foreach (const QString &removedConfig, removedUserConfigArguments)
arguments.append("CONFIG-=" + removedConfig);
}
if (!addedUserConfigArguments.isEmpty()) {
foreach (const QString &addedConfig, addedUserConfigArguments)
arguments.append("CONFIG+=" + addedConfig);
}
if (!additonalArguments.isEmpty())
......
......@@ -565,34 +565,11 @@ void MaemoRunConfiguration::updateTarget()
reader->setCumulative(false);
reader->setQtVersion(qtVersion);
// Find out what flags we pass on to qmake, this code is duplicated in
// the qmake step
QtVersion::QmakeBuildConfigs defaultBuildConfiguration =
qtVersion->defaultBuildConfig();
QtVersion::QmakeBuildConfig projectBuildConfiguration =
QtVersion::QmakeBuildConfig(qt4Project->activeBuildConfiguration()
->value("buildConfiguration").toInt());
// Find out what flags we pass on to qmake
QStringList addedUserConfigArguments;
QStringList removedUserConfigArguments;
if ((defaultBuildConfiguration & QtVersion::BuildAll)
&& !(projectBuildConfiguration & QtVersion::BuildAll))
removedUserConfigArguments << "debug_and_release";
if (!(defaultBuildConfiguration & QtVersion::BuildAll)
&& (projectBuildConfiguration & QtVersion::BuildAll))
addedUserConfigArguments << "debug_and_release";
if ((defaultBuildConfiguration & QtVersion::DebugBuild)
&& !(projectBuildConfiguration & QtVersion::DebugBuild))
addedUserConfigArguments << "release";
if (!(defaultBuildConfiguration & QtVersion::DebugBuild)
&& (projectBuildConfiguration & QtVersion::DebugBuild))
addedUserConfigArguments << "debug";
reader->setUserConfigCmdArgs(addedUserConfigArguments,
removedUserConfigArguments);
qt4bc->getConfigCommandLineArguments(&addedUserConfigArguments, &removedUserConfigArguments);
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
if (!reader->readProFile(m_proFilePath)) {
delete reader;
......
......@@ -286,22 +286,11 @@ void S60DeviceRunConfiguration::updateTarget()
reader->setCumulative(false);
reader->setQtVersion(qtVersion);
// Find out what flags we pass on to qmake, this code is duplicated in the qmake step
QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion->defaultBuildConfig();
QtVersion::QmakeBuildConfigs projectBuildConfiguration =
QtVersion::QmakeBuildConfigs(qt4bc->value("buildConfiguration").toInt());
// Find out what flags we pass on to qmake
QStringList addedUserConfigArguments;
QStringList removedUserConfigArguments;
if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll))
removedUserConfigArguments << "debug_and_release";
if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (projectBuildConfiguration & QtVersion::BuildAll))
addedUserConfigArguments << "debug_and_release";
if ((defaultBuildConfiguration & QtVersion::DebugBuild) && !(projectBuildConfiguration & QtVersion::DebugBuild))
addedUserConfigArguments << "release";
if (!(defaultBuildConfiguration & QtVersion::DebugBuild) && (projectBuildConfiguration & QtVersion::DebugBuild))
addedUserConfigArguments << "debug";
reader->setUserConfigCmdArgs(addedUserConfigArguments, removedUserConfigArguments);
qt4bc->getConfigCommandLineArguments(&addedUserConfigArguments, &removedUserConfigArguments);
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
if (!reader->readProFile(m_proFilePath)) {
delete reader;
......@@ -346,7 +335,7 @@ void S60DeviceRunConfiguration::updateTarget()
m_platform = QLatin1String("armv6");
break;
}
if (projectBuildConfiguration & QtVersion::DebugBuild)
if (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild)
m_target = QLatin1String("udeb");
else
m_target = QLatin1String("urel");
......
......@@ -133,21 +133,11 @@ void S60EmulatorRunConfiguration::updateTarget()
reader->setCumulative(false);
reader->setQtVersion(qtVersion);
// Find out what flags we pass on to qmake, this code is duplicated in the qmake step
QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion->defaultBuildConfig();
QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(qt4bc->value("buildConfiguration").toInt());
// Find out what flags we pass on to qmake
QStringList addedUserConfigArguments;
QStringList removedUserConfigArguments;
if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll))
removedUserConfigArguments << "debug_and_release";
if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (projectBuildConfiguration & QtVersion::BuildAll))
addedUserConfigArguments << "debug_and_release";
if ((defaultBuildConfiguration & QtVersion::DebugBuild) && !(projectBuildConfiguration & QtVersion::DebugBuild))
addedUserConfigArguments << "release";
if (!(defaultBuildConfiguration & QtVersion::DebugBuild) && (projectBuildConfiguration & QtVersion::DebugBuild))
addedUserConfigArguments << "debug";
reader->setUserConfigCmdArgs(addedUserConfigArguments, removedUserConfigArguments);
qt4bc->getConfigCommandLineArguments(&addedUserConfigArguments, &removedUserConfigArguments);
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
if (!reader->readProFile(m_proFilePath)) {
delete reader;
......@@ -157,7 +147,7 @@ void S60EmulatorRunConfiguration::updateTarget()
QString baseDir = S60Manager::instance()->deviceForQtVersion(qtVersion).epocRoot;
QString qmakeBuildConfig = "urel";
if (projectBuildConfiguration & QtVersion::DebugBuild)
if (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild)
qmakeBuildConfig = "udeb";
baseDir += "/epoc32/release/winscw/" + qmakeBuildConfig;
......
......@@ -133,7 +133,7 @@ QString Qt4BuildConfiguration::makeCommand() const
}
#ifdef QTCREATOR_WITH_S60
static inline QString symbianMakeTarget(QtVersion::QmakeBuildConfig buildConfig,
static inline QString symbianMakeTarget(QtVersion::QmakeBuildConfigs buildConfig,
const QString &type)
{
QString rc = (buildConfig & QtVersion::DebugBuild) ?
......@@ -149,8 +149,7 @@ QString Qt4BuildConfiguration::defaultMakeTarget() const
ToolChain *tc = toolChain();
if (!tc)
return QString::null;
const QtVersion::QmakeBuildConfig buildConfig
= QtVersion::QmakeBuildConfig(value("buildConfiguration").toInt());
const QtVersion::QmakeBuildConfigs buildConfig = qmakeBuildConfiguration();
switch (tc->type()) {
case ToolChain::GCCE:
......@@ -279,7 +278,7 @@ bool Qt4BuildConfiguration::compareToImportFrom(const QString &workingDirectory)
// same qtversion
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
QtVersionManager::scanMakeFile(workingDirectory, version->defaultBuildConfig());
if (QtVersion::QmakeBuildConfig(value("buildConfiguration").toInt()) == result.first) {
if (qmakeBuildConfiguration() == result.first) {
// The QMake Build Configuration are the same,
// now compare arguments lists
// we have to compare without the spec/platform cmd argument
......@@ -402,3 +401,26 @@ QString Qt4BuildConfiguration::extractSpecFromArgumentList(const QStringList &li
return parsedSpec;
}
QtVersion::QmakeBuildConfigs Qt4BuildConfiguration::qmakeBuildConfiguration() const
{
return QtVersion::QmakeBuildConfigs(value("buildConfiguration").toInt());
}
void Qt4BuildConfiguration::getConfigCommandLineArguments(QStringList *addedUserConfigs, QStringList *removedUserConfigs) const
{
QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qtVersion()->defaultBuildConfig();
QtVersion::QmakeBuildConfigs userBuildConfiguration = qmakeBuildConfiguration();
if (removedUserConfigs) {
if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(userBuildConfiguration & QtVersion::BuildAll))
(*removedUserConfigs) << "debug_and_release";
}
if (addedUserConfigs) {
if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (userBuildConfiguration & QtVersion::BuildAll))
(*addedUserConfigs) << "debug_and_release";
if ((defaultBuildConfiguration & QtVersion::DebugBuild) && !(userBuildConfiguration & QtVersion::DebugBuild))
(*addedUserConfigs) << "release";
if (!(defaultBuildConfiguration & QtVersion::DebugBuild) && (userBuildConfiguration & QtVersion::DebugBuild))
(*addedUserConfigs) << "debug";
}
}
......@@ -30,13 +30,14 @@
#ifndef QT4BUILDCONFIGURATION_H
#define QT4BUILDCONFIGURATION_H
#include "qtversionmanager.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/toolchain.h>
namespace Qt4ProjectManager {
class Qt4Project;
class QtVersion;
class QMakeStep;
class MakeStep;
......@@ -98,6 +99,9 @@ public:
static QStringList removeSpecFromArgumentList(const QStringList &old);
static QString extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version);
QtVersion::QmakeBuildConfigs qmakeBuildConfiguration() const;
void getConfigCommandLineArguments(QStringList *addedUserConfigs, QStringList *removedUserConfigs) const;
signals:
void qtVersionChanged();
};
......
......@@ -574,21 +574,11 @@ void Qt4RunConfiguration::updateTarget()
reader->setCumulative(false);
reader->setQtVersion(qt4bc->qtVersion());
// Find out what flags we pass on to qmake, this code is duplicated in the qmake step
QtVersion::QmakeBuildConfigs defaultBuildConfiguration = qt4bc->qtVersion()->defaultBuildConfig();
QtVersion::QmakeBuildConfigs projectBuildConfiguration = QtVersion::QmakeBuildConfig(qt4bc->value("buildConfiguration").toInt());
// Find out what flags we pass on to qmake
QStringList addedUserConfigArguments;
QStringList removedUserConfigArguments;
if ((defaultBuildConfiguration & QtVersion::BuildAll) && !(projectBuildConfiguration & QtVersion::BuildAll))
removedUserConfigArguments << "debug_and_release";
if (!(defaultBuildConfiguration & QtVersion::BuildAll) && (projectBuildConfiguration & QtVersion::BuildAll))
addedUserConfigArguments << "debug_and_release";
if ((defaultBuildConfiguration & QtVersion::DebugBuild) && !(projectBuildConfiguration & QtVersion::DebugBuild))
addedUserConfigArguments << "release";
if (!(defaultBuildConfiguration & QtVersion::DebugBuild) && (projectBuildConfiguration & QtVersion::DebugBuild))
addedUserConfigArguments << "debug";
reader->setUserConfigCmdArgs(addedUserConfigArguments, removedUserConfigArguments);
qt4bc->getConfigCommandLineArguments(&addedUserConfigArguments, &removedUserConfigArguments);
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
if (!reader->readProFile(m_proFilePath)) {
delete reader;
......@@ -618,7 +608,7 @@ void Qt4RunConfiguration::updateTarget()
if (reader->values("CONFIG").contains("debug_and_release_target")) {
//qDebug()<<"reader has debug_and_release_target";
QString qmakeBuildConfig = "release";
if (projectBuildConfiguration & QtVersion::DebugBuild)
if (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild)
qmakeBuildConfig = "debug";
if (!reader->contains("DESTDIR"))
m_workingDir += QLatin1Char('/') + qmakeBuildConfig;
......
......@@ -3068,7 +3068,7 @@ void ProFileEvaluator::setOutputDir(const QString &dir)
d->m_outputDir = dir;
}
void ProFileEvaluator::setUserConfigCmdArgs(const QStringList &addUserConfigCmdArgs, const QStringList &removeUserConfigCmdArgs)
void ProFileEvaluator::setConfigCommandLineArguments(const QStringList &addUserConfigCmdArgs, const QStringList &removeUserConfigCmdArgs)
{
d->m_addUserConfigCmdArgs = addUserConfigCmdArgs;
d->m_removeUserConfigCmdArgs = removeUserConfigCmdArgs;
......
......@@ -112,7 +112,7 @@ public:
// -nocache, -cache, -spec, QMAKESPEC
// -set persistent value
void setUserConfigCmdArgs(const QStringList &addUserConfigCmdArgs, const QStringList &removeUserConfigCmdArgs);
void setConfigCommandLineArguments(const QStringList &addUserConfigCmdArgs, const QStringList &removeUserConfigCmdArgs);
void setParsePreAndPostFiles(bool on); // Default is true
bool queryProFile(ProFile *pro);
......
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