2022-12-02 21:15:34 +01:00
|
|
|
from os.path import exists, join
|
|
|
|
|
2019-03-30 21:58:45 +01:00
|
|
|
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']
|
|
|
|
|
2019-03-30 21:58:45 +01:00
|
|
|
depends = ['sdl2_image', 'sdl2_mixer', 'sdl2_ttf']
|
2017-08-13 03:24:00 +02:00
|
|
|
|
2019-03-30 21:58:45 +01: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(
|
2019-03-30 21:58:45 +01:00
|
|
|
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()
|