lbry-android-sdk/p4a/pythonforandroid/recipes/sdl2/__init__.py

43 lines
1.4 KiB
Python
Raw Normal View History

2022-12-02 21:15:34 +01:00
from os.path import exists, join
from pythonforandroid.recipe import BootstrapNDKRecipe
from pythonforandroid.toolchain import current_directory, shprint
2017-08-13 03:24:00 +02:00
import sh
class LibSDL2Recipe(BootstrapNDKRecipe):
2022-12-02 21:15:34 +01:00
version = "2.26.0"
url = "https://github.com/libsdl-org/SDL/releases/download/release-{version}/SDL2-{version}.tar.gz"
md5sum = '35bc58cfe41b8fb6c8e6646be26fa47e'
2017-08-13 03:24:00 +02:00
dir_name = 'SDL'
2022-12-02 21:15:34 +01:00
patches = ['remove-extra-include.patch']
depends = ['sdl2_image', 'sdl2_mixer', 'sdl2_ttf']
2017-08-13 03:24:00 +02:00
def get_recipe_env(self, arch=None, with_flags_in_cc=True, with_python=True):
2022-12-02 21:15:34 +01:00
env = super().get_recipe_env(
arch=arch, with_flags_in_cc=with_flags_in_cc, with_python=with_python)
env['APP_ALLOW_MISSING_DEPS'] = 'true'
2017-08-13 03:24:00 +02:00
return env
2022-12-02 21:15:34 +01:00
def should_build(self, arch):
libdir = join(self.get_build_dir(arch.arch), "../..", "libs", arch.arch)
libs = ['libmain.so', 'libSDL2.so', 'libSDL2_image.so', 'libSDL2_mixer.so', 'libSDL2_ttf.so']
return not all(exists(join(libdir, x)) for x in libs)
2017-08-13 03:24:00 +02:00
def build_arch(self, arch):
env = self.get_recipe_env(arch)
with current_directory(self.get_jni_dir()):
2022-12-02 21:15:34 +01:00
shprint(
sh.Command(join(self.ctx.ndk_dir, "ndk-build")),
"V=1",
"NDK_DEBUG=" + ("1" if self.ctx.build_as_debuggable else "0"),
_env=env
)
2017-08-13 03:24:00 +02:00
recipe = LibSDL2Recipe()