diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-05-10 17:04:01 +0200 |
---|---|---|
committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-09-06 12:35:41 +0200 |
commit | 9b3d266aab68e28cd230b1587f233d74af84e629 (patch) | |
tree | f10ed90dc5e04fbdef353e7cb3143ef2f26c379c /sources/pyside-tools | |
parent | 7da5e8f0da921788d1159ebe4d4759b5c4736e5c (diff) |
Android Deployment - Add local libs
- local libs refer to those binary dependencies like plugins
which might be required for a certain Qt module. This is normally
listed in the xml dependency file for the module. One mandatory local
lib dependency that every module has is the platform plugin named as
libplugins_platforms_qtforandroid_x86_64.so for x86_64 and
correspondingly for other platforms as well.
- These libraries/plugins are called local_libs to align with libs.xml
generated by androideployqt which calls them as local_libs.
Task-number: PYSIDE-1612
Change-Id: I103d1691071936f191d867d8a20ddf8b019c38cb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools')
-rw-r--r-- | sources/pyside-tools/deploy_lib/android/buildozer.py | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/sources/pyside-tools/deploy_lib/android/buildozer.py b/sources/pyside-tools/deploy_lib/android/buildozer.py index 11f3936fb..45c62075c 100644 --- a/sources/pyside-tools/deploy_lib/android/buildozer.py +++ b/sources/pyside-tools/deploy_lib/android/buildozer.py @@ -1,6 +1,7 @@ # Copyright (C) 2023 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +import re import logging import xml.etree.ElementTree as ET import zipfile @@ -46,13 +47,21 @@ class BuildozerConfig(BaseConfig): self.set_value('app', "p4a.local_recipes", str(pysidedeploy_config.recipe_dir)) self.set_value("app", "p4a.bootstrap", "qt") + # gets the xml dependency files from Qt installation path + dependency_files = self.__get_dependency_files(pysidedeploy_config) + modules = ",".join(pysidedeploy_config.modules) + local_libs = self.__find_local_libs(dependency_files) + pysidedeploy_config.local_libs += local_libs + + if local_libs: + pysidedeploy_config.update_config() + local_libs = ",".join(pysidedeploy_config.local_libs) + extra_args = (f"--qt-libs={modules} --load-local-libs={local_libs}") self.set_value("app", "p4a.extra_args", extra_args) - dependency_files = self.__get_dependency_files(pysidedeploy_config) - # add permissions permissions = self.__find_permissions(dependency_files) permissions = ", ".join(permissions) @@ -140,6 +149,37 @@ class BuildozerConfig(BaseConfig): return jars + def __find_local_libs(self, dependency_files: List[zipfile.Path]): + local_libs = set() + lib_pattern = re.compile(f"lib(?P<lib_name>.*)_{self.arch}") + for dependency_file in dependency_files: + xml_content = dependency_file.read_text() + root = ET.fromstring(xml_content) + for local_lib in root.iter("lib"): + + if 'file' not in local_lib.attrib: + continue + + file = local_lib.attrib['file'] + if file.endswith(".so"): + # file_name starts with lib and ends with the platform name + # eg: lib<lib_name>_x86_64.so + file_name = Path(file).stem + + if file_name.startswith("libplugins_platforms_qtforandroid"): + # the platform library is a requisite and is already added from the + # configuration file + continue + + # we only need lib_name, because lib and arch gets re-added by + # python-for-android + match = lib_pattern.search(file_name) + if match: + lib_name = match.group("lib_name") + local_libs.add(lib_name) + + return list(local_libs) + class Buildozer: dry_run = False |