From f8918c43e88c68e2e447226d6249b47c58539cbc Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 31 Aug 2016 14:31:29 +0200 Subject: Improve QML development experience With the cache files it is tricky to do changes to the code generator and it is easy to forget that the cache files need to be re-generated. So facilitate this, we add the sha1 checksum of the QtQml library to the checksum embedded in the cache files. This is currently only implemented on Unixy platforms and it is limited to developer builds with shared libraries. This is not intended for release builds. Change-Id: If59f31f700254f7e9c6e3384d2fae4e5396fb698 Reviewed-by: Qt CI Bot Reviewed-by: Lars Knoll --- src/qml/compiler/compiler.pri | 1 + src/qml/compiler/qv4compileddata.cpp | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) (limited to 'src') diff --git a/src/qml/compiler/compiler.pri b/src/qml/compiler/compiler.pri index a63de67b4c..1de5dfa6fa 100644 --- a/src/qml/compiler/compiler.pri +++ b/src/qml/compiler/compiler.pri @@ -49,4 +49,5 @@ qtConfig(qml-interpreter) { } +qtConfig(private_tests): LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD } diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp index 0ab09f66ec..81acc71717 100644 --- a/src/qml/compiler/qv4compileddata.cpp +++ b/src/qml/compiler/qv4compileddata.cpp @@ -65,6 +65,12 @@ #include +#if defined(QT_BUILD_INTERNAL) +#if defined(Q_OS_UNIX) && !defined(QT_NO_DYNAMIC_CAST) +#include +#endif +#endif + QT_BEGIN_NAMESPACE namespace QV4 { @@ -604,12 +610,47 @@ void ResolvedTypeReference::doDynamicTypeCheck() isFullyDynamicType = qtTypeInherits(mo); } +#if defined(QT_BUILD_INTERNAL) + +static QByteArray ownLibraryChecksum() +{ + static QByteArray libraryChecksum; + static bool checksumInitialized = false; + if (checksumInitialized) + return libraryChecksum; + checksumInitialized = true; +#if defined(Q_OS_UNIX) && !defined(QT_NO_DYNAMIC_CAST) + Dl_info libInfo; + if (dladdr(reinterpret_cast(&ownLibraryChecksum), &libInfo) != 0) { + QFile library(QFile::decodeName(libInfo.dli_fname)); + if (library.open(QIODevice::ReadOnly)) { + QCryptographicHash hash(QCryptographicHash::Sha1); + hash.addData(&library); + libraryChecksum = hash.result(); + } + } +#else + // Not implemented. +#endif + return libraryChecksum; +} + +#endif + bool ResolvedTypeReferenceMap::addToHash(QCryptographicHash *hash, QQmlEngine *engine) const { for (auto it = constBegin(), end = constEnd(); it != end; ++it) { if (!it.value()->addToHash(hash, engine)) return false; } + + // This is a bit of a hack to make development easier. When hacking on the code generator + // the cache files may end up being re-used. To avoid that we also add the checksum of + // the QtQml library. +#if defined(QT_BUILD_INTERNAL) + hash->addData(ownLibraryChecksum()); +#endif + return true; } -- cgit v1.2.3