forked from qt-creator/qt-creator
Move extractSpec and removeSpec to Qt4BuildConfiguration
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "qt4projectmanager.h"
|
||||
#include "qmakestep.h"
|
||||
#include "makestep.h"
|
||||
#include "qt4buildconfiguration.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
@@ -66,9 +67,9 @@ ProjectLoadWizard::ProjectLoadWizard(Qt4Project *project, QWidget *parent, Qt::W
|
||||
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
|
||||
QtVersionManager::scanMakeFile(directory, m_importVersion->defaultBuildConfig());
|
||||
m_importBuildConfig = result.first;
|
||||
m_additionalArguments = Qt4Project::removeSpecFromArgumentList(result.second);
|
||||
m_additionalArguments = Qt4BuildConfiguration::removeSpecFromArgumentList(result.second);
|
||||
|
||||
QString parsedSpec = Qt4Project::extractSpecFromArgumentList(result.second, directory, m_importVersion);
|
||||
QString parsedSpec = Qt4BuildConfiguration::extractSpecFromArgumentList(result.second, directory, m_importVersion);
|
||||
QString versionSpec = m_importVersion->mkspec();
|
||||
|
||||
// Compare mkspecs and add to additional arguments
|
||||
|
@@ -284,16 +284,16 @@ bool Qt4BuildConfiguration::compareBuildConfigurationToImportFrom(const QString
|
||||
// now compare arguments lists
|
||||
// we have to compare without the spec/platform cmd argument
|
||||
// and compare that on its own
|
||||
QString actualSpec = Qt4Project::extractSpecFromArgumentList(qs->qmakeArguments(), workingDirectory, version);
|
||||
QString actualSpec = extractSpecFromArgumentList(qs->qmakeArguments(), workingDirectory, version);
|
||||
if (actualSpec.isEmpty()) {
|
||||
// Easy one the user has choosen not to override the settings
|
||||
actualSpec = version->mkspec();
|
||||
}
|
||||
|
||||
|
||||
QString parsedSpec = Qt4Project::extractSpecFromArgumentList(result.second, workingDirectory, version);
|
||||
QStringList actualArgs = Qt4Project::removeSpecFromArgumentList(qs->qmakeArguments());
|
||||
QStringList parsedArgs = Qt4Project::removeSpecFromArgumentList(result.second);
|
||||
QString parsedSpec = extractSpecFromArgumentList(result.second, workingDirectory, version);
|
||||
QStringList actualArgs = removeSpecFromArgumentList(qs->qmakeArguments());
|
||||
QStringList parsedArgs = removeSpecFromArgumentList(result.second);
|
||||
|
||||
if (debug) {
|
||||
qDebug()<<"Actual args:"<<actualArgs;
|
||||
@@ -317,3 +317,88 @@ bool Qt4BuildConfiguration::compareBuildConfigurationToImportFrom(const QString
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// We match -spec and -platfrom separetly
|
||||
// We ignore -cache, because qmake contained a bug that it didn't
|
||||
// mention the -cache in the Makefile
|
||||
// That means changing the -cache option in the additional arguments
|
||||
// does not automatically rerun qmake. Alas, we could try more
|
||||
// intelligent matching for -cache, but i guess people rarely
|
||||
// do use that.
|
||||
|
||||
QStringList Qt4BuildConfiguration::removeSpecFromArgumentList(const QStringList &old)
|
||||
{
|
||||
if (!old.contains("-spec") && !old.contains("-platform") && !old.contains("-cache"))
|
||||
return old;
|
||||
QStringList newList;
|
||||
bool ignoreNext = false;
|
||||
foreach(const QString &item, old) {
|
||||
if (ignoreNext) {
|
||||
ignoreNext = false;
|
||||
} else if (item == "-spec" || item == "-platform" || item == "-cache") {
|
||||
ignoreNext = true;
|
||||
} else {
|
||||
newList << item;
|
||||
}
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
|
||||
QString Qt4BuildConfiguration::extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version)
|
||||
{
|
||||
int index = list.indexOf("-spec");
|
||||
if (index == -1)
|
||||
index = list.indexOf("-platform");
|
||||
if (index == -1)
|
||||
return QString();
|
||||
|
||||
++index;
|
||||
|
||||
if (index >= list.length())
|
||||
return QString();
|
||||
|
||||
QString baseMkspecDir = version->versionInfo().value("QMAKE_MKSPECS");
|
||||
if (baseMkspecDir.isEmpty())
|
||||
baseMkspecDir = version->versionInfo().value("QT_INSTALL_DATA") + "/mkspecs";
|
||||
|
||||
QString parsedSpec = QDir::cleanPath(list.at(index));
|
||||
#ifdef Q_OS_WIN
|
||||
baseMkspecDir = baseMkspecDir.toLower();
|
||||
parsedSpec = parsedSpec.toLower();
|
||||
#endif
|
||||
// if the path is relative it can be
|
||||
// relative to the working directory (as found in the Makefiles)
|
||||
// or relatively to the mkspec directory
|
||||
// if it is the former we need to get the canonical form
|
||||
// for the other one we don't need to do anything
|
||||
if (QFileInfo(parsedSpec).isRelative()) {
|
||||
if(QFileInfo(directory + "/" + parsedSpec).exists()) {
|
||||
parsedSpec = QDir::cleanPath(directory + "/" + parsedSpec);
|
||||
#ifdef Q_OS_WIN
|
||||
parsedSpec = parsedSpec.toLower();
|
||||
#endif
|
||||
} else {
|
||||
parsedSpec = baseMkspecDir + "/" + parsedSpec;
|
||||
}
|
||||
}
|
||||
|
||||
QFileInfo f2(parsedSpec);
|
||||
while (f2.isSymLink()) {
|
||||
parsedSpec = f2.symLinkTarget();
|
||||
f2.setFile(parsedSpec);
|
||||
}
|
||||
|
||||
if (parsedSpec.startsWith(baseMkspecDir)) {
|
||||
parsedSpec = parsedSpec.mid(baseMkspecDir.length() + 1);
|
||||
} else {
|
||||
QString sourceMkSpecPath = version->sourcePath() + "/mkspecs";
|
||||
if (parsedSpec.startsWith(sourceMkSpecPath)) {
|
||||
parsedSpec = parsedSpec.mid(sourceMkSpecPath.length() + 1);
|
||||
}
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
parsedSpec = parsedSpec.toLower();
|
||||
#endif
|
||||
return parsedSpec;
|
||||
|
||||
}
|
||||
|
@@ -96,6 +96,8 @@ public:
|
||||
|
||||
// TODO rename
|
||||
bool compareBuildConfigurationToImportFrom(const QString &workingDirectory);
|
||||
static QStringList removeSpecFromArgumentList(const QStringList &old);
|
||||
static QString extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version);
|
||||
|
||||
signals:
|
||||
void qtVersionChanged();
|
||||
|
@@ -456,7 +456,7 @@ ProjectExplorer::IBuildConfigurationFactory *Qt4Project::buildConfigurationFacto
|
||||
return m_buildConfigurationFactory;
|
||||
}
|
||||
|
||||
Qt4BuildConfiguration *Qt4Project::addQt4BuildConfiguration(QString buildConfigurationName, QtVersion *qtversion,
|
||||
Qt4BuildConfiguration *Qt4Project::addQt4BuildConfiguration(QString displayName, QtVersion *qtversion,
|
||||
QtVersion::QmakeBuildConfigs qmakeBuildConfiguration,
|
||||
QStringList additionalArguments)
|
||||
{
|
||||
@@ -464,7 +464,7 @@ Qt4BuildConfiguration *Qt4Project::addQt4BuildConfiguration(QString buildConfigu
|
||||
|
||||
// Add the buildconfiguration
|
||||
Qt4BuildConfiguration *bc = new Qt4BuildConfiguration(this);
|
||||
bc->setDisplayName(buildConfigurationName);
|
||||
bc->setDisplayName(displayName);
|
||||
addBuildConfiguration(bc);
|
||||
|
||||
QMakeStep *qmakeStep = new QMakeStep(bc);
|
||||
@@ -821,64 +821,7 @@ void Qt4Project::updateActiveRunConfiguration()
|
||||
emit targetInformationChanged();
|
||||
}
|
||||
|
||||
QString Qt4Project::extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version)
|
||||
{
|
||||
int index = list.indexOf("-spec");
|
||||
if (index == -1)
|
||||
index = list.indexOf("-platform");
|
||||
if (index == -1)
|
||||
return QString();
|
||||
|
||||
++index;
|
||||
|
||||
if (index >= list.length())
|
||||
return QString();
|
||||
|
||||
QString baseMkspecDir = version->versionInfo().value("QMAKE_MKSPECS");
|
||||
if (baseMkspecDir.isEmpty())
|
||||
baseMkspecDir = version->versionInfo().value("QT_INSTALL_DATA") + "/mkspecs";
|
||||
|
||||
QString parsedSpec = QDir::cleanPath(list.at(index));
|
||||
#ifdef Q_OS_WIN
|
||||
baseMkspecDir = baseMkspecDir.toLower();
|
||||
parsedSpec = parsedSpec.toLower();
|
||||
#endif
|
||||
// if the path is relative it can be
|
||||
// relative to the working directory (as found in the Makefiles)
|
||||
// or relatively to the mkspec directory
|
||||
// if it is the former we need to get the canonical form
|
||||
// for the other one we don't need to do anything
|
||||
if (QFileInfo(parsedSpec).isRelative()) {
|
||||
if(QFileInfo(directory + "/" + parsedSpec).exists()) {
|
||||
parsedSpec = QDir::cleanPath(directory + "/" + parsedSpec);
|
||||
#ifdef Q_OS_WIN
|
||||
parsedSpec = parsedSpec.toLower();
|
||||
#endif
|
||||
} else {
|
||||
parsedSpec = baseMkspecDir + "/" + parsedSpec;
|
||||
}
|
||||
}
|
||||
|
||||
QFileInfo f2(parsedSpec);
|
||||
while (f2.isSymLink()) {
|
||||
parsedSpec = f2.symLinkTarget();
|
||||
f2.setFile(parsedSpec);
|
||||
}
|
||||
|
||||
if (parsedSpec.startsWith(baseMkspecDir)) {
|
||||
parsedSpec = parsedSpec.mid(baseMkspecDir.length() + 1);
|
||||
} else {
|
||||
QString sourceMkSpecPath = version->sourcePath() + "/mkspecs";
|
||||
if (parsedSpec.startsWith(sourceMkSpecPath)) {
|
||||
parsedSpec = parsedSpec.mid(sourceMkSpecPath.length() + 1);
|
||||
}
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
parsedSpec = parsedSpec.toLower();
|
||||
#endif
|
||||
return parsedSpec;
|
||||
|
||||
}
|
||||
|
||||
BuildConfigWidget *Qt4Project::createConfigWidget()
|
||||
{
|
||||
@@ -1048,33 +991,6 @@ void Qt4Project::invalidateCachedTargetInformation()
|
||||
emit targetInformationChanged();
|
||||
}
|
||||
|
||||
// We match -spec and -platfrom separetly
|
||||
// We ignore -cache, because qmake contained a bug that it didn't
|
||||
// mention the -cache in the Makefile
|
||||
// That means changing the -cache option in the additional arguments
|
||||
// does not automatically rerun qmake. Alas, we could try more
|
||||
// intelligent matching for -cache, but i guess people rarely
|
||||
// do use that.
|
||||
|
||||
QStringList Qt4Project::removeSpecFromArgumentList(const QStringList &old)
|
||||
{
|
||||
if (!old.contains("-spec") && !old.contains("-platform") && !old.contains("-cache"))
|
||||
return old;
|
||||
QStringList newList;
|
||||
bool ignoreNext = false;
|
||||
foreach(const QString &item, old) {
|
||||
if (ignoreNext) {
|
||||
ignoreNext = false;
|
||||
} else if (item == "-spec" || item == "-platform" || item == "-cache") {
|
||||
ignoreNext = true;
|
||||
} else {
|
||||
newList << item;
|
||||
}
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Handle special case were a subproject of the qt directory is opened, and
|
||||
qt was configured to be built as a shadow build -> also build in the sub-
|
||||
|
@@ -166,7 +166,7 @@ public:
|
||||
Qt4Manager *qt4ProjectManager() const;
|
||||
ProjectExplorer::IBuildConfigurationFactory *buildConfigurationFactory() const;
|
||||
|
||||
Internal::Qt4BuildConfiguration *addQt4BuildConfiguration(QString buildConfigurationName,
|
||||
Internal::Qt4BuildConfiguration *addQt4BuildConfiguration(QString displayName,
|
||||
QtVersion *qtversion,
|
||||
QtVersion::QmakeBuildConfigs qmakeBuildConfiguration,
|
||||
QStringList additionalArguments = QStringList());
|
||||
@@ -201,9 +201,6 @@ public:
|
||||
virtual QStringList includePaths(const QString &fileName) const;
|
||||
virtual QStringList frameworkPaths(const QString &fileName) const;
|
||||
|
||||
static QStringList removeSpecFromArgumentList(const QStringList &old);
|
||||
static QString extractSpecFromArgumentList(const QStringList &list, QString directory, QtVersion *version);
|
||||
|
||||
// TODO can i remove this?
|
||||
void updateActiveRunConfiguration();
|
||||
signals:
|
||||
|
@@ -283,8 +283,8 @@ void Qt4ProjectConfigWidget::importLabelClicked()
|
||||
QPair<QtVersion::QmakeBuildConfigs, QStringList> result =
|
||||
QtVersionManager::scanMakeFile(directory, version->defaultBuildConfig());
|
||||
QtVersion::QmakeBuildConfigs qmakeBuildConfig = result.first;
|
||||
QStringList additionalArguments = Qt4Project::removeSpecFromArgumentList(result.second);
|
||||
QString parsedSpec = Qt4Project::extractSpecFromArgumentList(result.second, directory, version);
|
||||
QStringList additionalArguments = Qt4BuildConfiguration::removeSpecFromArgumentList(result.second);
|
||||
QString parsedSpec = Qt4BuildConfiguration::extractSpecFromArgumentList(result.second, directory, version);
|
||||
QString versionSpec = version->mkspec();
|
||||
if (parsedSpec.isEmpty() || parsedSpec == versionSpec || parsedSpec == "default") {
|
||||
// using the default spec, don't modify additional arguments
|
||||
|
Reference in New Issue
Block a user