summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2016-07-28 16:10:46 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2016-07-28 15:31:02 +0000
commita3466fc55fb7756fcc9ddd6aeabbdef80c0108e4 (patch)
treeecccb88bbe4913d77a381d2e6568ed7c97284df0
parent304012f6374fe29ebe39e4026fb7d92d2390f4a5 (diff)
downloadqbs-a3466fc55fb7756fcc9ddd6aeabbdef80c0108e4.tar.gz
Share probe results among products, if possible
Most probes are not parameterized per product, meaning they only need to run once. Change-Id: Id1d08c3c552649a3f6147bb854b27b0315791942 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
-rw-r--r--src/lib/corelib/language/moduleloader.cpp12
-rw-r--r--src/lib/corelib/language/moduleloader.h3
-rw-r--r--src/lib/corelib/tools/codelocation.h2
3 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index ff082f87d..7f8dd02a6 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -865,6 +865,15 @@ ProbeConstPtr ModuleLoader::findOldProbe(const QString &product,
return ProbeConstPtr();
}
+ProbeConstPtr ModuleLoader::findCurrentProbe(const CodeLocation &location, bool condition,
+ const QVariantMap &initialProperties) const
+{
+ const ProbeConstPtr cachedProbe = m_currentProbes.value(location);
+ return cachedProbe && cachedProbe->condition() == condition
+ && cachedProbe->initialProperties() == initialProperties
+ ? cachedProbe : ProbeConstPtr();
+}
+
void ModuleLoader::mergeExportItems(const ProductContext &productContext)
{
QVector<Item *> exportItems;
@@ -1721,6 +1730,8 @@ void ModuleLoader::resolveProbe(ProductContext *productContext, Item *parent, It
const bool condition = m_evaluator->boolValue(probe, QLatin1String("condition"));
ProbeConstPtr resolvedProbe = findOldProbe(productContext->name, condition, initialProperties,
configureScript->sourceCode().toString());
+ if (!resolvedProbe)
+ resolvedProbe = findCurrentProbe(probe->location(), condition, initialProperties);
ErrorInfo evalError;
if (!condition) {
m_logger.qbsDebug() << "Probe disabled; skipping";
@@ -1741,6 +1752,7 @@ void ModuleLoader::resolveProbe(ProductContext *productContext, Item *parent, It
if (!resolvedProbe) {
resolvedProbe = Probe::create(probe->location(), condition,
configureScript->sourceCode().toString(), properties, initialProperties);
+ m_currentProbes.insert(probe->location(), resolvedProbe);
}
productContext->info.probes << resolvedProbe;
m_engine->currentContext()->popScope();
diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h
index efc825826..ab251ed2a 100644
--- a/src/lib/corelib/language/moduleloader.h
+++ b/src/lib/corelib/language/moduleloader.h
@@ -244,6 +244,8 @@ private:
ProbeConstPtr findOldProbe(const QString &product, bool condition,
const QVariantMap &initialProperties,
const QString &sourceCode) const;
+ ProbeConstPtr findCurrentProbe(const CodeLocation &location, bool condition,
+ const QVariantMap &initialProperties) const;
ScriptEngine *m_engine;
ItemPool *m_pool;
@@ -259,6 +261,7 @@ private:
QSet<Item *> m_disabledItems;
QStack<bool> m_requiredChain;
QHash<QString, QList<ProbeConstPtr>> m_oldProbes;
+ QHash<CodeLocation, ProbeConstPtr> m_currentProbes;
SetupProjectParameters m_parameters;
Version m_qbsVersion;
Item *m_tempScopeItem = nullptr;
diff --git a/src/lib/corelib/tools/codelocation.h b/src/lib/corelib/tools/codelocation.h
index 97c7cd2eb..758e5cc99 100644
--- a/src/lib/corelib/tools/codelocation.h
+++ b/src/lib/corelib/tools/codelocation.h
@@ -73,6 +73,8 @@ private:
QBS_EXPORT bool operator==(const CodeLocation &cl1, const CodeLocation &cl2);
QBS_EXPORT bool operator!=(const CodeLocation &cl1, const CodeLocation &cl2);
+inline uint qHash(const CodeLocation &cl) { return qHash(cl.toString()); }
+
QDebug operator<<(QDebug debug, const CodeLocation &location);
} // namespace qbs