diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-05-04 16:56:49 +0200 |
---|---|---|
committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2023-09-05 14:14:09 +0200 |
commit | 0c3a3cd7923a9903b2d482594f27dd27e04b0c42 (patch) | |
tree | fa3d8120b402c294edc8c63c5711d933577a702b /sources/pyside-tools/deploy_lib | |
parent | 9c292a60196fc4ab0c87995d42d5416c32c667a9 (diff) |
Android Deployment: Add only required Qt jars
- Earlier all the jar files were bundled together with the app.
This is now changed so that only the required jars, obtained from
inspecting the dependent Qt module's xml dependency files are added.
These files are included in the PySide Android wheel.
Task-number: PYSIDE-1612
Change-Id: If1efb67a3a6f5815f14247e70a4c48a0b780585b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside-tools/deploy_lib')
-rw-r--r-- | sources/pyside-tools/deploy_lib/android/buildozer.py | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/sources/pyside-tools/deploy_lib/android/buildozer.py b/sources/pyside-tools/deploy_lib/android/buildozer.py index e49bbe80f..11f3936fb 100644 --- a/sources/pyside-tools/deploy_lib/android/buildozer.py +++ b/sources/pyside-tools/deploy_lib/android/buildozer.py @@ -31,8 +31,6 @@ class BuildozerConfig(BaseConfig): if pysidedeploy_config.sdk_path: self.set_value("app", "android.sdk_path", str(pysidedeploy_config.sdk_path)) - self.set_value("app", "android.add_jars", f"{str(pysidedeploy_config.jars_dir)}/*.jar") - platform_map = {"aarch64": "arm64-v8a", "armv7a": "armeabi-v7a", "i686": "x86", @@ -54,10 +52,16 @@ class BuildozerConfig(BaseConfig): 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) self.set_value("app", "android.permissions", permissions) + # add jars + jars = self.__find_jars(dependency_files, pysidedeploy_config.jars_dir) + self.set_value("app", "android.add_jars", ",".join(jars)) + # TODO: does not work atm. Seems like a bug with buildozer # change buildozer build_dir # self.set_value("buildozer", "build_dir", str(build_dir.relative_to(Path.cwd()))) @@ -108,6 +112,34 @@ class BuildozerConfig(BaseConfig): permissions.add(permission.attrib['name']) return permissions + def __find_jars(self, dependency_files: List[zipfile.Path], jars_dir: Path): + jars = set() + for dependency_file in dependency_files: + xml_content = dependency_file.read_text() + root = ET.fromstring(xml_content) + for jar in root.iter("jar"): + jar_file = jar.attrib['file'] + if jar_file.startswith("jar/"): + jar_file_name = jar_file[4:] + if (jars_dir / jar_file_name).exists(): + jars.add(str(jars_dir / jar_file_name)) + else: + logging.warning(f"[DEPLOY] Unable to include {jar_file}. " + f"{jar_file} does not exist in {jars_dir}") + else: + logging.warning(f"[DEPLOY] Unable to include {jar_file}. " + "All jar file paths should begin with 'jar/'") + + # add the jar with all the activity and service java files + # this is created from Qt for Python instead of Qt + android_bindings_jar = jars_dir / "Qt6AndroidBindings.jar" + if android_bindings_jar.exists(): + jars.add(str(android_bindings_jar)) + else: + raise FileNotFoundError(f"{android_bindings_jar} not found in wheel") + + return jars + class Buildozer: dry_run = False |