From 9af1f3557a60e37f8b7bafb921d265d322f1fc16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tinja=20Paavosepp=C3=A4?= Date: Wed, 19 Jan 2022 13:35:50 +0200 Subject: Add option to not include native libraries in APK Sometimes it is not desirable to include the libraries in the APK, e.g. system and vendor apps could prefer having one set of libraries installed on the device. If unbundled deployment is specified, native libraries will not be included in the APK. With unbundled deployment, optional arguments can be passed to set the path to load the libraries on the device. [ChangeLog][Android][Deployment Changes] Adds option for Unbundled deployment, where native libraries are not packaged in the APK. Task-number: QAA-771 Change-Id: Ica51ef83a24dad58c7586bf610a58abe21fc1100 Reviewed-by: Assam Boudjelthia --- src/corelib/Qt6AndroidMacros.cmake | 8 +++++ src/corelib/doc/src/cmake/cmake-properties.qdoc | 39 +++++++++++++++++++++++++ src/corelib/kernel/qcoreapplication.cpp | 3 -- 3 files changed, 47 insertions(+), 3 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/Qt6AndroidMacros.cmake b/src/corelib/Qt6AndroidMacros.cmake index 6804b942c2..cf996ebb4c 100644 --- a/src/corelib/Qt6AndroidMacros.cmake +++ b/src/corelib/Qt6AndroidMacros.cmake @@ -214,6 +214,10 @@ function(qt6_android_generate_deployment_settings target) _qt_internal_add_android_deployment_multi_value_property(file_contents "android-extra-libs" ${target} "_qt_android_native_extra_libs" ) + # Alternative path to Qt libraries on target device + _qt_internal_add_android_deployment_property(file_contents "android-system-libs-prefix" + ${target} "QT_ANDROID_SYSTEM_LIBS_PREFIX") + # package source dir _qt_internal_add_android_deployment_property(file_contents "android-package-source-directory" ${target} "_qt_android_native_package_source_dir") @@ -234,6 +238,10 @@ function(qt6_android_generate_deployment_settings target) _qt_internal_add_android_deployment_property(file_contents "android-target-sdk-version" ${target} "QT_ANDROID_TARGET_SDK_VERSION") + # should Qt shared libs be excluded from deployment + _qt_internal_add_android_deployment_property(file_contents "android-no-deploy-qt-libs" + ${target} "QT_ANDROID_NO_DEPLOY_QT_LIBS") + # App binary string(APPEND file_contents " \"application-binary\": \"${target_output_name}\",\n") diff --git a/src/corelib/doc/src/cmake/cmake-properties.qdoc b/src/corelib/doc/src/cmake/cmake-properties.qdoc index 9f2e2aed75..bbb948aec2 100644 --- a/src/corelib/doc/src/cmake/cmake-properties.qdoc +++ b/src/corelib/doc/src/cmake/cmake-properties.qdoc @@ -296,6 +296,45 @@ Projects should not try to set this property themselves, as it will be ignored and overwritten by that command. */ +/*! +\page cmake-target-property-QT_ANDROID_SYSTEM_LIBS_PREFIX.html +\ingroup cmake-properties-qtcore +\ingroup cmake-target-properties-qtcore + +\title QT_ANDROID_SYSTEM_LIBS_PREFIX +\target cmake-target-property-QT_ANDROID_SYSTEM_LIBS_PREFIX + +\summary {Specifies the location of Qt libraries on the target device.} + +\preliminarycmakeproperty +\cmakepropertyandroidonly + +This property can be set to provide a path to Qt libraries on the target device, +when those libraries are installed outside app's native (JNI) library directory. +*/ + +/*! +\page cmake-target-property-QT_ANDROID_NO_DEPLOY_QT_LIBS.html +\ingroup cmake-properties-qtcore +\ingroup cmake-target-properties-qtcore + +\title QT_ANDROID_NO_DEPLOY_QT_LIBS +\target cmake-target-property-QT_ANDROID_NO_DEPLOY_QT_LIBS + +\summary {Whether Qt shared libraries are packaged in the APK on Android.} + +\preliminarycmakeproperty +\cmakepropertyandroidonly + +This property can be set to not package Qt shared libraries inside the APK when +deploying the target. Use +\l{cmake-target-property-QT_ANDROID_SYSTEM_LIBS_PREFIX}{QT_ANDROID_SYSTEM_LIBS_PREFIX} +to provide a path to where those libraries will be located on the target device +instead. + +\note Only supported when deploying as an APK. +*/ + /*! \page cmake-target-property-qt_no_entrypoint.html \ingroup cmake-properties-qtcore diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index ca6f55f476..9937e018f6 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -2733,9 +2733,6 @@ QStringList QCoreApplication::libraryPathsLocked() } }; setPathsFromEnv(qEnvironmentVariable("QT_PLUGIN_PATH")); -#ifdef Q_OS_ANDROID - setPathsFromEnv(qEnvironmentVariable("QT_BUNDLED_LIBS_PATH")); -#endif #ifdef Q_OS_DARWIN // Check the main bundle's PlugIns directory as this is a standard location for Apple OSes. // Note that the QLibraryInfo::PluginsPath below will coincidentally be the same as this value -- cgit v1.2.3