From 9c533df1e0aae420fa6439e7a64a4480e9f62ef1 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Tue, 4 Oct 2022 17:12:39 +0200 Subject: [PATCH] Add flag that skips Qml import scanning to android deployment settings If Qml module is not found it doesn't make sense to run any functionality that is related to Qml inside androiddeployqt. Add the deployment setting option that indicates this explicitly and set it to true when Qml module is not found by CMake or by qmake. Task-number: QTBUG-106939 Change-Id: I1e6cffbdd230007feffe7448617097c10238a6c9 Reviewed-by: Alexandru Croitor Reviewed-by: Assam Boudjelthia (cherry picked from commit 720d5cc1a47ad0702d51548009bdcf229368d6fc) Reviewed-by: Qt Cherry-pick Bot --- .../android/android_deployment_settings.prf | 27 ++++++++++++------- src/corelib/Qt6AndroidMacros.cmake | 3 +++ src/tools/androiddeployqt/main.cpp | 16 +++++++---- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/mkspecs/features/android/android_deployment_settings.prf b/mkspecs/features/android/android_deployment_settings.prf index 1819a1f52c3..d56d79960c5 100644 --- a/mkspecs/features/android/android_deployment_settings.prf +++ b/mkspecs/features/android/android_deployment_settings.prf @@ -64,23 +64,30 @@ contains(TEMPLATE, ".*app"):!build_pass { tool_extension = "" contains(QMAKE_HOST.os, Windows): tool_extension = ".exe" - FILE_CONTENT += " \"qml-importscanner-binary\": $$emitString($$[QT_HOST_LIBEXECS]/qmlimportscanner$${tool_extension})," FILE_CONTENT += " \"rcc-binary\": $$emitString($$[QT_HOST_LIBEXECS]/rcc$${tool_extension})," - qml_import_paths = $$(QML2_IMPORT_PATH) - qml_import_paths = $$split(qml_import_paths, $$DIRLIST_SEPARATOR) - qml_import_paths += $$QML_IMPORT_PATH - !isEmpty(qml_import_paths) { - FILE_CONTENT += " \"qml-import-paths\": $$emitString($$join(qml_import_paths, ","))," + contains(QT_MODULES, qml) { + FILE_CONTENT += " \"qml-importscanner-binary\": $$emitString($$[QT_HOST_LIBEXECS]/qmlimportscanner$${tool_extension})," + + qml_import_paths = $$(QML2_IMPORT_PATH) + qml_import_paths = $$split(qml_import_paths, $$DIRLIST_SEPARATOR) + qml_import_paths += $$QML_IMPORT_PATH + !isEmpty(qml_import_paths) { + FILE_CONTENT += " \"qml-import-paths\": $$emitString($$join(qml_import_paths, ","))," + } + unset(qml_import_paths) + + + isEmpty(QML_ROOT_PATH): \ + QML_ROOT_PATH = $$_PRO_FILE_PWD_ + FILE_CONTENT += " \"qml-root-path\": $$emitString($$QML_ROOT_PATH)," + } else { + FILE_CONTENT += " \"qml-skip-import-scanning\": true," } - unset(qml_import_paths) !isEmpty(ANDROID_APPLICATION_ARGUMENTS): \ FILE_CONTENT += " \"android-application-arguments\": $$emitString($$ANDROID_APPLICATION_ARGUMENTS)," - isEmpty(QML_ROOT_PATH): \ - QML_ROOT_PATH = $$_PRO_FILE_PWD_ - FILE_CONTENT += " \"qml-root-path\": $$emitString($$QML_ROOT_PATH)," FILE_CONTENT += " \"stdcpp-path\": $$emitString($$ANDROID_STDCPP_PATH)," !isEmpty(RESOURCES)|!isEmpty(QMLCACHE_RESOURCE_FILES) { # Make sure that qmake generated qrc files are accounted for diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index 9424053743a..03e44b8ad15 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -254,6 +254,9 @@ function(qt6_android_generate_deployment_settings target) if(COMMAND _qt_internal_generate_android_qml_deployment_settings) _qt_internal_generate_android_qml_deployment_settings(file_contents ${target}) + else() + string(APPEND file_contents + " \"qml-skip-import-scanning\": true,\n") endif() # Override rcc binary path diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index d42f05f4c79..6c79ce6ad32 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -218,6 +218,7 @@ struct Options // Override qml import scanner path QString qmlImportScannerBinaryPath; + bool qmlSkipImportScanning = false; }; static const QHash elfArchitectures = { @@ -1032,6 +1033,12 @@ bool readInputFile(Options *options) options->extraLibs = extraLibs.toString().split(u',', Qt::SkipEmptyParts); } + { + const QJsonValue qmlSkipImportScanning = jsonObject.value("qml-skip-import-scanning"_L1); + if (!qmlSkipImportScanning.isUndefined()) + options->qmlSkipImportScanning = qmlSkipImportScanning.toBool(); + } + { const QJsonValue extraPlugins = jsonObject.value("android-extra-plugins"_L1); if (!extraPlugins.isUndefined()) @@ -2298,11 +2305,10 @@ bool readDependencies(Options *options) } } - if ((!options->rootPaths.empty() || !options->qrcFiles.isEmpty()) && - !scanImports(options, &usedDependencies)) - return false; - - return true; + if (options->qmlSkipImportScanning + || (options->rootPaths.empty() && options->qrcFiles.isEmpty())) + return true; + return scanImports(options, &usedDependencies); } bool containsApplicationBinary(Options *options)