diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-02-01 22:25:04 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-21 22:31:00 +0100 |
commit | a0da58b5dd358b9728fc428153463cbca9c23689 (patch) | |
tree | 510b37926a64946b0d926ed447272ef8388aaefd /qmake | |
parent | 3cf6521f54175031382672c3331899fe1f98a6c9 (diff) |
make resolution of default spec less inefficient
resolve only once, in particular on unix.
Change-Id: I090698fc6029322a3a16d179d461af3e8336f6ad
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/project.cpp | 63 | ||||
-rw-r--r-- | qmake/project.h | 1 |
2 files changed, 29 insertions, 35 deletions
diff --git a/qmake/project.cpp b/qmake/project.cpp index 138e2cf350..2029e068ec 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -1512,6 +1512,33 @@ void QMakeProject::validateModes() } } +void +QMakeProject::resolveSpec(QString *spec, const QString &qmakespec) +{ + if (spec->isEmpty()) { + *spec = QFileInfo(qmakespec).fileName(); + if (*spec == "default") { +#ifdef Q_OS_UNIX + char buffer[1024]; + int l = readlink(qmakespec.toLatin1(), buffer, 1023); + if (l != -1) { + buffer[l] = '\0'; + *spec = QString::fromLatin1(buffer); +#else + // We can't resolve symlinks as they do on Unix, so configure.exe puts the source of the + // qmake.conf at the end of the default/qmake.conf in the QMAKESPEC_ORG variable. + const QStringList &spec_org = base_vars["QMAKESPEC_ORIGINAL"]; + if (!spec_org.isEmpty()) { + *spec = spec_org.at(0); +#endif + int lastSlash = spec->lastIndexOf(QLatin1Char('/')); + if (lastSlash != -1) + spec->remove(lastSlash + 1); + } + } + } +} + bool QMakeProject::isActiveConfig(const QString &x, bool regex, QHash<QString, QStringList> *place) { @@ -1538,44 +1565,10 @@ QMakeProject::isActiveConfig(const QString &x, bool regex, QHash<QString, QStrin //mkspecs static QString spec; - if(spec.isEmpty()) - spec = QFileInfo(Option::mkfile::qmakespec).fileName(); + resolveSpec(&spec, Option::mkfile::qmakespec); QRegExp re(x, Qt::CaseSensitive, QRegExp::Wildcard); if((regex && re.exactMatch(spec)) || (!regex && spec == x)) return true; -#ifdef Q_OS_UNIX - else if(spec == "default") { - static char *buffer = NULL; - if(!buffer) { - buffer = (char *)malloc(1024); - qmakeAddCacheClear(qmakeFreeCacheClear, (void**)&buffer); - } - int l = readlink(Option::mkfile::qmakespec.toLatin1(), buffer, 1024); - if(l != -1) { - buffer[l] = '\0'; - QString r = buffer; - if(r.lastIndexOf('/') != -1) - r = r.mid(r.lastIndexOf('/') + 1); - if((regex && re.exactMatch(r)) || (!regex && r == x)) - return true; - } - } -#elif defined(Q_OS_WIN) - else if(spec == "default") { - // We can't resolve symlinks as they do on Unix, so configure.exe puts the source of the - // qmake.conf at the end of the default/qmake.conf in the QMAKESPEC_ORG variable. - const QStringList &spec_org = (place ? (*place)["QMAKESPEC_ORIGINAL"] - : vars["QMAKESPEC_ORIGINAL"]); - if (!spec_org.isEmpty()) { - spec = spec_org.at(0); - int lastSlash = spec.lastIndexOf('/'); - if(lastSlash != -1) - spec = spec.mid(lastSlash + 1); - if((regex && re.exactMatch(spec)) || (!regex && spec == x)) - return true; - } - } -#endif //simple matching const QStringList &configs = (place ? (*place)["CONFIG"] : vars["CONFIG"]); diff --git a/qmake/project.h b/qmake/project.h index 7a9cc1eae4..ce90be035f 100644 --- a/qmake/project.h +++ b/qmake/project.h @@ -108,6 +108,7 @@ class QMakeProject void init(QMakeProperty *, const QHash<QString, QStringList> *); QStringList &values(const QString &v, QHash<QString, QStringList> &place); void validateModes(); + void resolveSpec(QString *spec, const QString &qmakespec); public: QMakeProject() { init(0, 0); } |