aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@digia.com>2012-12-03 12:19:02 +0100
committerChristian Kandeler <christian.kandeler@digia.com>2012-12-03 13:01:58 +0100
commit8bff8ddd397cf7c7b7d2c5d38b2153c5133d406f (patch)
tree51321947b2c05fe1dcc38aaf521772316f9a6c40
parentd58e3cfae7f744f02134c72c925822a6c401a04c (diff)
fix spurious caching error in InputArtifactScanner
Depending on which scanner was used first, the input artifact got scanned with or without include paths. The result was cached and potentially retrieved in the next round where it might be wrong. Keep a dependency cache per scanner, because different scanners might yield different results. Change-Id: I0eb6ac9675205e26600ad99015a17e911ecb68a7 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
-rw-r--r--src/lib/buildgraph/inputartifactscanner.cpp44
-rw-r--r--src/lib/buildgraph/inputartifactscanner.h2
2 files changed, 28 insertions, 18 deletions
diff --git a/src/lib/buildgraph/inputartifactscanner.cpp b/src/lib/buildgraph/inputartifactscanner.cpp
index 670dbd74f..bbe3f778a 100644
--- a/src/lib/buildgraph/inputartifactscanner.cpp
+++ b/src/lib/buildgraph/inputartifactscanner.cpp
@@ -165,27 +165,37 @@ void InputArtifactScanner::scan()
for (; it != m_artifact->transformer->inputs.end(); ++it) {
Artifact *inputArtifact = *it;
QStringList includePaths;
- bool includePathsCollected = false;
-
- InputArtifactScannerContext::CacheItem &cacheItem = m_context->cache[inputArtifact->properties];
+ bool mustCollectIncludePaths = false;
+ QSet<ScannerPlugin *> scanners;
foreach (const QString &fileTag, inputArtifact->fileTags) {
- QList<ScannerPlugin *> scanners = ScannerPluginManager::scannersForFileTag(fileTag);
- foreach (ScannerPlugin *scanner, scanners) {
- if (scanner->usesCppIncludePaths && !includePathsCollected) {
- if (cacheItem.valid) {
- //qDebug() << "CACHE HIT";
- includePaths = cacheItem.includePaths;
- } else {
- //qDebug() << "CACHE MISS";
- includePaths = collectIncludePaths(inputArtifact->properties->value().value("modules").toMap());
- cacheItem.includePaths = includePaths;
- cacheItem.valid = true;
- }
- }
- scanForFileDependencies(scanner, includePaths, inputArtifact, cacheItem.resolvedDependenciesCache);
+ foreach (ScannerPlugin *scanner, ScannerPluginManager::scannersForFileTag(fileTag)) {
+ scanners += scanner;
+ if (scanner->usesCppIncludePaths)
+ mustCollectIncludePaths = true;
+ }
+ }
+
+ InputArtifactScannerContext::CacheItem &cacheItem = m_context->cache[inputArtifact->properties];
+ if (mustCollectIncludePaths) {
+ if (cacheItem.valid) {
+ //qDebug() << "CACHE HIT";
+ includePaths = cacheItem.includePaths;
+ } else {
+ //qDebug() << "CACHE MISS";
+ includePaths = collectIncludePaths(inputArtifact->properties->value().value("modules").toMap());
+ cacheItem.includePaths = includePaths;
+ cacheItem.valid = true;
}
}
+
+ const QStringList emptyIncludePaths;
+ foreach (ScannerPlugin *scanner, scanners) {
+ scanForFileDependencies(scanner,
+ scanner->usesCppIncludePaths ? includePaths : emptyIncludePaths,
+ inputArtifact,
+ cacheItem.resolvedDependenciesCache[scanner]);
+ }
}
}
diff --git a/src/lib/buildgraph/inputartifactscanner.h b/src/lib/buildgraph/inputartifactscanner.h
index f6d0faefa..ddc132c41 100644
--- a/src/lib/buildgraph/inputartifactscanner.h
+++ b/src/lib/buildgraph/inputartifactscanner.h
@@ -85,7 +85,7 @@ private:
bool valid;
QStringList includePaths;
- ResolvedDependenciesCache resolvedDependenciesCache;
+ QHash<ScannerPlugin *, ResolvedDependenciesCache> resolvedDependenciesCache;
};
QHash<PropertyMapConstPtr, CacheItem> cache;