From a0da58b5dd358b9728fc428153463cbca9c23689 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 1 Feb 2012 22:25:04 +0100 Subject: make resolution of default spec less inefficient resolve only once, in particular on unix. Change-Id: I090698fc6029322a3a16d179d461af3e8336f6ad Reviewed-by: Marius Storm-Olsen --- qmake/project.cpp | 63 +++++++++++++++++++++++++------------------------------ qmake/project.h | 1 + 2 files changed, 29 insertions(+), 35 deletions(-) (limited to 'qmake') 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 *place) { @@ -1538,44 +1565,10 @@ QMakeProject::isActiveConfig(const QString &x, bool regex, QHash *); QStringList &values(const QString &v, QHash &place); void validateModes(); + void resolveSpec(QString *spec, const QString &qmakespec); public: QMakeProject() { init(0, 0); } -- cgit v1.2.3