forked from qt-creator/qt-creator
Move extractSpec and removeSpec to Qt4BuildConfiguration
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user