diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-08-31 14:31:29 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-10-18 21:09:04 +0000 |
commit | f8918c43e88c68e2e447226d6249b47c58539cbc (patch) | |
tree | 291ca11a76e9e3a2990270cf843c912e5ff74ff3 /src | |
parent | 06e3cfb0c49ca94d4456d7abc8b332ef9582ae62 (diff) |
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 <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/compiler/compiler.pri | 1 | ||||
-rw-r--r-- | src/qml/compiler/qv4compileddata.cpp | 41 |
2 files changed, 42 insertions, 0 deletions
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 <algorithm> +#if defined(QT_BUILD_INTERNAL) +#if defined(Q_OS_UNIX) && !defined(QT_NO_DYNAMIC_CAST) +#include <dlfcn.h> +#endif +#endif + QT_BEGIN_NAMESPACE namespace QV4 { @@ -604,12 +610,47 @@ void ResolvedTypeReference::doDynamicTypeCheck() isFullyDynamicType = qtTypeInherits<QQmlPropertyMap>(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<const void *>(&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; } |