From d9ded99b193c51f4d5fd0ac269bc8da48a778914 Mon Sep 17 00:00:00 2001 From: Ansh Dadwal Date: Wed, 26 Mar 2025 09:52:12 +0530 Subject: [PATCH 1/4] `sdl2_image`: fix downloading --- .../recipes/sdl2_image/__init__.py | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/pythonforandroid/recipes/sdl2_image/__init__.py b/pythonforandroid/recipes/sdl2_image/__init__.py index b3ac504fbf..8cea604e59 100644 --- a/pythonforandroid/recipes/sdl2_image/__init__.py +++ b/pythonforandroid/recipes/sdl2_image/__init__.py @@ -2,11 +2,10 @@ import sh from pythonforandroid.logger import shprint from pythonforandroid.recipe import BootstrapNDKRecipe -from pythonforandroid.util import current_directory class LibSDL2Image(BootstrapNDKRecipe): - version = '2.8.0' + version = '2.8.2' url = 'https://github.com/libsdl-org/SDL_image/releases/download/release-{version}/SDL2_image-{version}.tar.gz' dir_name = 'SDL2_image' @@ -20,10 +19,27 @@ def get_include_dirs(self, arch): def prebuild_arch(self, arch): # We do not have a folder for each arch on BootstrapNDKRecipe, so we # need to skip the external deps download if we already have done it. - external_deps_dir = os.path.join(self.get_build_dir(arch.arch), "external") - if not os.path.exists(os.path.join(external_deps_dir, "libwebp")): - with current_directory(external_deps_dir): - shprint(sh.Command("./download.sh")) + + build_dir = self.get_build_dir(arch.arch) + + with open(os.path.join(build_dir, ".gitmodules"), "r") as file: + for section in file.read().split('[submodule "')[1:]: + line_split = section.split(" = ") + # Parse .gitmoulde section + clone_path, url, branch = ( + os.path.join(build_dir, line_split[1].split("\n")[0].strip()), + line_split[2].split("\n")[0].strip(), + line_split[-1].strip() + ) + # Clone if needed + if not os.path.exists(clone_path) or os.listdir(clone_path) == 0: + shprint( + sh.git, "clone", url, + "--depth", "1", "-b", + branch, clone_path, "--recursive" + ) + file.close() + super().prebuild_arch(arch) From 5a844e7248ea195f40e1d01c21db3614f7ce89f1 Mon Sep 17 00:00:00 2001 From: clayote Date: Tue, 13 May 2025 04:48:57 +1200 Subject: [PATCH 2/4] Fix typo in comment --- pythonforandroid/recipes/sdl2_image/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/recipes/sdl2_image/__init__.py b/pythonforandroid/recipes/sdl2_image/__init__.py index 8cea604e59..fe2e258e16 100644 --- a/pythonforandroid/recipes/sdl2_image/__init__.py +++ b/pythonforandroid/recipes/sdl2_image/__init__.py @@ -25,7 +25,7 @@ def prebuild_arch(self, arch): with open(os.path.join(build_dir, ".gitmodules"), "r") as file: for section in file.read().split('[submodule "')[1:]: line_split = section.split(" = ") - # Parse .gitmoulde section + # Parse .gitmodule section clone_path, url, branch = ( os.path.join(build_dir, line_split[1].split("\n")[0].strip()), line_split[2].split("\n")[0].strip(), From 2d5ef7f54af54b46e9913cdce74a4bb917a32260 Mon Sep 17 00:00:00 2001 From: clayote Date: Tue, 13 May 2025 04:50:34 +1200 Subject: [PATCH 3/4] Remove redundant `file.close()` The end of a `with` block already does that. --- pythonforandroid/recipes/sdl2_image/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pythonforandroid/recipes/sdl2_image/__init__.py b/pythonforandroid/recipes/sdl2_image/__init__.py index fe2e258e16..340e688315 100644 --- a/pythonforandroid/recipes/sdl2_image/__init__.py +++ b/pythonforandroid/recipes/sdl2_image/__init__.py @@ -38,7 +38,6 @@ def prebuild_arch(self, arch): "--depth", "1", "-b", branch, clone_path, "--recursive" ) - file.close() super().prebuild_arch(arch) From d2911a7b25bf95f258d194466a56245782f067ee Mon Sep 17 00:00:00 2001 From: clayote Date: Tue, 13 May 2025 05:01:20 +1200 Subject: [PATCH 4/4] Fix bad empty-directory check --- pythonforandroid/recipes/sdl2_image/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/recipes/sdl2_image/__init__.py b/pythonforandroid/recipes/sdl2_image/__init__.py index 340e688315..39411a740f 100644 --- a/pythonforandroid/recipes/sdl2_image/__init__.py +++ b/pythonforandroid/recipes/sdl2_image/__init__.py @@ -32,7 +32,7 @@ def prebuild_arch(self, arch): line_split[-1].strip() ) # Clone if needed - if not os.path.exists(clone_path) or os.listdir(clone_path) == 0: + if not os.path.exists(clone_path) or not os.listdir(clone_path): shprint( sh.git, "clone", url, "--depth", "1", "-b",