diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-08-17 16:25:03 +0200 |
---|---|---|
committer | Alexey Edelev <alexey.edelev@qt.io> | 2021-09-09 21:49:37 +0200 |
commit | d20f4ae706559fb7de8db9dd4845f7ce3936061a (patch) | |
tree | cd2729521d7aaf72be595de5be0be35f2473b7a5 /src/tools | |
parent | 2b8a6d026d2a9fed48847d9759a1b07ec34418a1 (diff) |
Support deploying of libraries from a build tree when building android apk
If the project consists of an executable and multiple libraries that
are linked to the executable, currently you need to specify them
manually using QT_ANDROID_EXTRA_LIBS target property.
This automates deploying of the libraries that are a part of the
project build tree. _qt_internal_collect_target_apk_dependencies
collects all the known non-imported shared libraries from the project
build tree. When running androiddeployqt we specify extra library
directories that point to the collected library locations in build
tree, to help androiddeployqt resolve shared libraries that are build
as a part of the project.
The described procedure is running automatically if CMake version is
greater than or equal to 3.18 is. For the CMake versions less than
3.18 users need to call a new public qt_finalize_project function at
the end of project's top-level CMakeLists.txt
Task-number: QTBUG-94714
Change-Id: I400ca4e49e940cfc25ae90d65372e79825bee55a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/androiddeployqt/main.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index bc280dc107..75db7bab25 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -166,6 +166,9 @@ struct Options // Build paths QString qtInstallDirectory; std::vector<QString> extraPrefixDirs; + // Unlike 'extraPrefixDirs', the 'extraLibraryDirs' key doesn't expect the 'lib' subfolder + // when looking for dependencies. + std::vector<QString> extraLibraryDirs; QString androidSourceDirectory; QString outputDirectory; QString inputFileName; @@ -922,6 +925,14 @@ bool readInputFile(Options *options) } { + const auto extraLibraryDirs = jsonObject.value(QLatin1String("extraLibraryDirs")).toArray(); + options->extraLibraryDirs.reserve(extraLibraryDirs.size()); + for (const QJsonValue path : extraLibraryDirs) { + options->extraLibraryDirs.push_back(path.toString()); + } + } + + { const QJsonValue androidSourcesDirectory = jsonObject.value(QLatin1String("android-package-source-directory")); if (!androidSourcesDirectory.isUndefined()) options->androidSourceDirectory = androidSourcesDirectory.toString(); @@ -1607,6 +1618,17 @@ bool updateAndroidFiles(Options &options) static QString absoluteFilePath(const Options *options, const QString &relativeFileName) { + // Use extraLibraryDirs as the extra library lookup folder if it is expected to find a file in + // any $prefix/lib folder. + // Library directories from a build tree(extraLibraryDirs) have the higher priority. + if (relativeFileName.startsWith(QLatin1String("lib/"))) { + for (const auto &dir : options->extraLibraryDirs) { + const QString path = dir + QLatin1Char('/') + relativeFileName.mid(sizeof("lib/") - 1); + if (QFile::exists(path)) + return path; + } + } + for (const auto &prefix : options->extraPrefixDirs) { const QString path = prefix + QLatin1Char('/') + relativeFileName; if (QFile::exists(path)) |