Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions pythonforandroid/recipes/sdl2_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -20,10 +19,26 @@ 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 .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(),
line_split[-1].strip()
)
# Clone if needed
if not os.path.exists(clone_path) or not os.listdir(clone_path):
shprint(
sh.git, "clone", url,
"--depth", "1", "-b",
branch, clone_path, "--recursive"
)
Comment on lines +23 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have commented that before, but when it's not that obvious what the code is doing, a comment is always helpful.
Maybe we could have added a block comment or method docstring saying:

# Prevents downloading commit history of all submodules, to improve cloning reliability on slow internet connection


super().prebuild_arch(arch)


Expand Down
Loading