diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2016-11-16 16:22:20 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2016-11-17 07:35:36 +0000 |
commit | a6fca88b0eebab5c50849fd9bcf1adb4fa8f171c (patch) | |
tree | 047e35bc054cf1455152ed1e754552472fcd81f1 /src/lib/corelib/buildgraph/depscanner.cpp | |
parent | 871011aa97501d948c90250ec33ace9e0463702e (diff) |
Fix include path order in C++ dependency scanner
The list of include paths must not be stored in a temporary
set. Otherwise the order of include paths is undefined.
Also, since introduction of merged top-level modules in commit 16404c35
we don't need to recurse through the dependency hierarchy.
Change-Id: I50a843fc85dbf1cb04883774d43e5904da815579
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/corelib/buildgraph/depscanner.cpp')
-rw-r--r-- | src/lib/corelib/buildgraph/depscanner.cpp | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/src/lib/corelib/buildgraph/depscanner.cpp b/src/lib/corelib/buildgraph/depscanner.cpp index 804327955..dd206d158 100644 --- a/src/lib/corelib/buildgraph/depscanner.cpp +++ b/src/lib/corelib/buildgraph/depscanner.cpp @@ -58,31 +58,19 @@ namespace qbs { namespace Internal { -static void collectCppIncludePaths(const QVariantMap &modules, QSet<QString> *collectedPaths) +static QStringList collectCppIncludePaths(const QVariantMap &modules) { - QMapIterator<QString, QVariant> iterator(modules); - while (iterator.hasNext()) { - iterator.next(); - const auto properties = iterator.value().toMap(); - if (iterator.key() == QLatin1String("cpp")) { - QVariant includePathsVariant = properties.value(QLatin1String("includePaths")); - if (includePathsVariant.isValid()) - collectedPaths->unite(QSet<QString>::fromList(includePathsVariant.toStringList())); - QVariant systemIncludePathsVariant = - properties.value(QLatin1String("systemIncludePaths")); - if (systemIncludePathsVariant.isValid()) - collectedPaths->unite(QSet<QString>::fromList( - systemIncludePathsVariant.toStringList())); - QVariant compilerIncludePathsVariant = - properties.value(QLatin1String("compilerIncludePaths")); - if (compilerIncludePathsVariant.isValid()) - collectedPaths->unite(QSet<QString>::fromList( - compilerIncludePathsVariant.toStringList())); - } else { - collectCppIncludePaths(properties.value(QLatin1String("modules")).toMap(), - collectedPaths); - } - } + QStringList result; + const QVariantMap cpp = modules.value(QLatin1String("cpp")).toMap(); + if (cpp.isEmpty()) + return result; + + result + << cpp.value(QLatin1String("includePaths")).toStringList() + << cpp.value(QLatin1String("systemIncludePaths")).toStringList() + << cpp.value(QLatin1String("compilerIncludePaths")).toStringList(); + result.removeDuplicates(); + return result; } PluginDependencyScanner::PluginDependencyScanner(ScannerPlugin *plugin) @@ -94,9 +82,7 @@ QStringList PluginDependencyScanner::collectSearchPaths(Artifact *artifact) { if (m_plugin->flags & ScannerUsesCppIncludePaths) { QVariantMap modules = artifact->properties->value().value(QLatin1String("modules")).toMap(); - QSet<QString> collectedPaths; - collectCppIncludePaths(modules, &collectedPaths); - return QStringList(collectedPaths.toList()); + return collectCppIncludePaths(modules); } else { return QStringList(); } |