diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-06 12:01:37 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-07 02:42:47 +0000 |
commit | 1a0277e925c0500a09968dec95dccdb67f0ddee8 (patch) | |
tree | 2af5a7e1eb6620cc0028717c45cd77aef2399424 | |
parent | ae1f2a6cd4e877e50d185db857c9aaa70aee8b86 (diff) |
Fix handling of QML_COMPILE_HASH
We need to check for the contents of the tag file, not its name. We need
to strip the contents before checking. We need to run git in the right
directory. We need to fail if we cannot find any QML_COMPILE_HASH.
Task-number: QTBUG-99608
Change-Id: Ic42a073b196143f8576a84e7a4531b5f2927fb68
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 0616a44e8ad0faa9c441212e281a61136c287f73)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | cmake/QtDeclarativeSetup.cmake | 28 | ||||
-rw-r--r-- | src/qml/CMakeLists.txt | 16 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4executablecompilationunit.cpp | 4 |
3 files changed, 23 insertions, 25 deletions
diff --git a/cmake/QtDeclarativeSetup.cmake b/cmake/QtDeclarativeSetup.cmake index cd5ae32e14..5f7de2c2ee 100644 --- a/cmake/QtDeclarativeSetup.cmake +++ b/cmake/QtDeclarativeSetup.cmake @@ -4,18 +4,32 @@ function(qt_declarative_write_tag_header target_name) set(tag_contents "") if(EXISTS "${tag_file}") file(READ "${tag_file}" tag_contents) + string(STRIP "${tag_contents}" tag_contents) endif() - if(NOT tag_file STREQUAL "$Format:%H$") + if(NOT tag_contents STREQUAL "$Format:%H$") set(QML_COMPILE_HASH "${tag_contents}") - string(STRIP "${QML_COMPILE_HASH}" QML_COMPILE_HASH) elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../.git") - execute_process( - COMMAND git rev-parse HEAD - OUTPUT_VARIABLE QML_COMPILE_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE) + find_program(git_path git) + if(git_path) + execute_process( + COMMAND ${git_path} rev-parse HEAD + OUTPUT_VARIABLE QML_COMPILE_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + else() + message(FATAL_ERROR "Cannot find a 'git' binary to retrieve QML compile hash in PATH!") + endif() + else() + message(FATAL_ERROR "Cannot find a source for the QML compile hash! " + "You need either a valid git repository or a non-empty .tag file.") endif() string(LENGTH "${QML_COMPILE_HASH}" QML_COMPILE_HASH_LENGTH) - configure_file("qml_compile_hash_p.h.in" "${CMAKE_CURRENT_BINARY_DIR}/qml_compile_hash_p.h") + if(QML_COMPILE_HASH_LENGTH GREATER 0) + configure_file("qml_compile_hash_p.h.in" "${CMAKE_CURRENT_BINARY_DIR}/qml_compile_hash_p.h") + else() + message(FATAL_ERROR "QML compile hash is empty! " + "You need either a valid git repository or a non-empty .tag file.") + endif() endfunction() find_package(PythonInterp REQUIRED) diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt index 046e29fdcd..4d460286ff 100644 --- a/src/qml/CMakeLists.txt +++ b/src/qml/CMakeLists.txt @@ -509,22 +509,6 @@ qt_internal_extend_target(Qml CONDITION QT_FEATURE_qml_animation animations ) -#### Keys ignored in scope 18:.:common:common/common.pri:NOT build_pass: -# compile_hash_contents = "// Generated file, DO NOT EDIT" "$${LITERAL_HASH}define QML_COMPILE_HASH "$$QML_COMPILE_HASH"" "$${LITERAL_HASH}define QML_COMPILE_HASH_LENGTH $$str_size($$QML_COMPILE_HASH)" -# tag = <EMPTY> -# tagFile = "$$PWD/../../.tag" - -#### Keys ignored in scope 19:.:common:common/common.pri:EXISTS _ss_tagFile: -# QMAKE_INTERNAL_INCLUDED_FILES = "$$tagFile" -# tag = "$$cat($$tagFile, singleline)" - -#### Keys ignored in scope 20:.:common:common/common.pri:NOT tag___equals____ss_{LITERAL_DOLLAR}Format AND %H_ss_{LITERAL_DOLLAR}: -# QML_COMPILE_HASH = "$$tag" - -#### Keys ignored in scope 22:.:common:common/common.pri:EXISTS _ss_PWD/../../.git: -# QML_COMPILE_HASH = "$$commit" -# commit = "$$system(git rev-parse HEAD)" - qt_internal_extend_target(Qml CONDITION GCC AND QT_COMPILER_VERSION_MAJOR STREQUAL 5 COMPILE_OPTIONS -fno-strict-aliasing diff --git a/src/qml/jsruntime/qv4executablecompilationunit.cpp b/src/qml/jsruntime/qv4executablecompilationunit.cpp index a8f8061528..f1253aa6f8 100644 --- a/src/qml/jsruntime/qv4executablecompilationunit.cpp +++ b/src/qml/jsruntime/qv4executablecompilationunit.cpp @@ -69,7 +69,7 @@ #include <QtCore/qcryptographichash.h> #include <QtCore/QScopedValueRollback> -#if defined(QML_COMPILE_HASH) +#if defined(QML_COMPILE_HASH) && defined(QML_COMPILE_HASH_LENGTH) && QML_COMPILE_HASH_LENGTH > 0 # ifdef Q_OS_LINUX // Place on a separate section on Linux so it's easier to check from outside // what the hash version is. @@ -940,7 +940,7 @@ bool ExecutableCompilationUnit::verifyHeader( } } -#if defined(QML_COMPILE_HASH) +#if defined(QML_COMPILE_HASH) && defined(QML_COMPILE_HASH_LENGTH) && QML_COMPILE_HASH_LENGTH > 0 if (qstrcmp(qml_compile_hash, unit->libraryVersionHash) != 0) { *errorString = QStringLiteral("QML library version mismatch. Expected compile hash does not match"); return false; |