diff options
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/bootstrap/bootstrap.pro | 5 | ||||
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 29 | ||||
-rw-r--r-- | src/tools/moc/preprocessor.h | 1 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwriteincludes.cpp | 24 | ||||
-rw-r--r-- | src/tools/uic/cpp/cppwriteincludes.h | 4 |
5 files changed, 41 insertions, 22 deletions
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index d51f9e98a4..0a61497588 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -28,6 +28,7 @@ SOURCES += \ ../../corelib/global/qlogging.cpp \ ../../corelib/global/qmalloc.cpp \ ../../corelib/global/qnumeric.cpp \ + ../../corelib/global/qoperatingsystemversion.cpp \ ../../corelib/io/qabstractfileengine.cpp \ ../../corelib/io/qbuffer.cpp \ ../../corelib/io/qdatastream.cpp \ @@ -96,7 +97,8 @@ unix:SOURCES += ../../corelib/io/qfilesystemengine_unix.cpp \ ../../corelib/io/qfilesystemiterator_unix.cpp \ ../../corelib/io/qfsfileengine_unix.cpp -win32:SOURCES += ../../corelib/io/qfilesystemengine_win.cpp \ +win32:SOURCES += ../../corelib/global/qoperatingsystemversion_win.cpp \ + ../../corelib/io/qfilesystemengine_win.cpp \ ../../corelib/io/qfilesystemiterator_win.cpp \ ../../corelib/io/qfsfileengine_win.cpp \ ../../corelib/kernel/qcoreapplication_win.cpp \ @@ -107,6 +109,7 @@ mac { ../../corelib/kernel/qcoreapplication_mac.cpp \ ../../corelib/kernel/qcore_mac.cpp OBJECTIVE_SOURCES += \ + ../../corelib/global/qoperatingsystemversion_darwin.mm \ ../../corelib/kernel/qcore_mac_objc.mm \ ../../corelib/kernel/qcore_foundation.mm diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 11bf8d7937..f5639ffe31 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -1005,22 +1005,20 @@ static void mergeStringLiterals(Symbols *_symbols) } } -QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteArray &relativeTo) +static QByteArray searchIncludePaths(const QList<Parser::IncludePath> &includepaths, + const QByteArray &include) { - // #### stringery QFileInfo fi; - if (!relativeTo.isEmpty()) - fi.setFile(QFileInfo(QString::fromLocal8Bit(relativeTo.constData())).dir(), QString::fromLocal8Bit(include.constData())); - for (int j = 0; j < Preprocessor::includes.size() && !fi.exists(); ++j) { - const IncludePath &p = Preprocessor::includes.at(j); + for (int j = 0; j < includepaths.size() && !fi.exists(); ++j) { + const Parser::IncludePath &p = includepaths.at(j); if (p.isFrameworkPath) { const int slashPos = include.indexOf('/'); if (slashPos == -1) continue; fi.setFile(QString::fromLocal8Bit(p.path + '/' + include.left(slashPos) + ".framework/Headers/"), - QString::fromLocal8Bit(include.mid(slashPos + 1).constData())); + QString::fromLocal8Bit(include.mid(slashPos + 1))); } else { - fi.setFile(QString::fromLocal8Bit(p.path.constData()), QString::fromLocal8Bit(include.constData())); + fi.setFile(QString::fromLocal8Bit(p.path), QString::fromLocal8Bit(include)); } // try again, maybe there's a file later in the include paths with the same name // (186067) @@ -1035,6 +1033,21 @@ QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteAr return fi.canonicalFilePath().toLocal8Bit(); } +QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteArray &relativeTo) +{ + if (!relativeTo.isEmpty()) { + QFileInfo fi; + fi.setFile(QFileInfo(QString::fromLocal8Bit(relativeTo)).dir(), QString::fromLocal8Bit(include)); + if (fi.exists() && !fi.isDir()) + return fi.canonicalFilePath().toLocal8Bit(); + } + + auto it = nonlocalIncludePathResolutionCache.find(include); + if (it == nonlocalIncludePathResolutionCache.end()) + it = nonlocalIncludePathResolutionCache.insert(include, searchIncludePaths(includes, include)); + return it.value(); +} + void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) { currentFilenames.push(filename); diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h index a7eb1a19e1..39f56d6e92 100644 --- a/src/tools/moc/preprocessor.h +++ b/src/tools/moc/preprocessor.h @@ -61,6 +61,7 @@ public: static bool preprocessOnly; QList<QByteArray> frameworks; QSet<QByteArray> preprocessedIncludes; + QHash<QByteArray, QByteArray> nonlocalIncludePathResolutionCache; Macros macros; QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo); Symbols preprocessed(const QByteArray &filename, QFile *device); diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index a99d6adf07..dcbe400224 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -114,8 +114,9 @@ void WriteIncludes::acceptUI(DomUI *node) TreeWalker::acceptUI(node); - if (!m_uic->option().includeFile.isEmpty()) - m_globalIncludes.insert(m_uic->option().includeFile, true); + const auto includeFile = m_uic->option().includeFile; + if (!includeFile.isEmpty()) + m_globalIncludes.insert(includeFile); writeHeaders(m_globalIncludes, true); writeHeaders(m_localIncludes, false); @@ -272,10 +273,11 @@ void WriteIncludes::insertInclude(const QString &header, bool global) fprintf(stderr, "%s %s %d\n", Q_FUNC_INFO, qPrintable(header), global); OrderedSet &includes = global ? m_globalIncludes : m_localIncludes; - if (includes.contains(header)) + // Insert (if not already done). + const bool isNewHeader = includes.insert(header).second; + if (!isNewHeader) return; - // Insert. Also remember base name for quick check of suspicious custom plugins - includes.insert(header, false); + // Also remember base name for quick check of suspicious custom plugins const QString lowerBaseName = QFileInfo(header).completeBaseName ().toLower(); m_includeBaseNames.insert(lowerBaseName); } @@ -286,13 +288,11 @@ void WriteIncludes::writeHeaders(const OrderedSet &headers, bool global) const QChar closingQuote = global ? QLatin1Char('>') : QLatin1Char('"'); // Check for the old headers 'qslider.h' and replace by 'QtGui/QSlider' - const OrderedSet::const_iterator cend = headers.constEnd(); - for (OrderedSet::const_iterator sit = headers.constBegin(); sit != cend; ++sit) { - const StringMap::const_iterator hit = m_oldHeaderToNewHeader.constFind(sit.key()); - const bool mapped = hit != m_oldHeaderToNewHeader.constEnd(); - const QString header = mapped ? hit.value() : sit.key(); - if (!QStringRef(&header).trimmed().isEmpty()) - m_output << "#include " << openingQuote << header << closingQuote << QLatin1Char('\n'); + for (const QString &header : headers) { + const QString value = m_oldHeaderToNewHeader.value(header, header); + const auto trimmed = QStringRef(&value).trimmed(); + if (!trimmed.isEmpty()) + m_output << "#include " << openingQuote << trimmed << closingQuote << QLatin1Char('\n'); } } diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h index 397c6a26e1..7a6a499536 100644 --- a/src/tools/uic/cpp/cppwriteincludes.h +++ b/src/tools/uic/cpp/cppwriteincludes.h @@ -35,6 +35,8 @@ #include <qset.h> #include <qstring.h> +#include <set> + QT_BEGIN_NAMESPACE class QTextStream; @@ -72,7 +74,7 @@ private: void add(const QString &className, bool determineHeader = true, const QString &header = QString(), bool global = false); private: - typedef QMap<QString, bool> OrderedSet; + typedef std::set<QString> OrderedSet; void insertIncludeForClass(const QString &className, QString header = QString(), bool global = false); void insertInclude(const QString &header, bool global); void writeHeaders(const OrderedSet &headers, bool global); |