Skip to content

Commit 4ac34c4

Browse files
committed
Improved pygame_sdl2 recipe
1 parent 3712346 commit 4ac34c4

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed
Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,56 @@
11

2-
from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchAndroid
2+
from pythonforandroid.toolchain import Recipe, shprint, current_directory, ArchAndroid
33
from os.path import exists, join
44
import sh
55
import glob
66

77

8-
class PygameSDL2Recipe(CythonRecipe):
8+
class PygameSDL2Recipe(Recipe):
99
# version = 'stable'
1010
version = 'master'
1111
url = 'https://github.com/renpy/pygame_sdl2/archive/{version}.zip'
1212
name = 'pygame_sdl2'
1313

14-
depends = ['sdl2']
14+
depends = ['sdl2', 'pygame_sdl2_bootstrap_components']
1515
conflicts = ['pygame']
1616

1717
def get_recipe_env(self, arch):
1818
env = super(PygameSDL2Recipe, self).get_recipe_env(arch)
19+
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(
20+
self.ctx.get_libs_dir(arch.arch))
21+
env['LDSHARED'] = join(self.ctx.root_dir, 'tools', 'liblink')
22+
env['LIBLINK'] = 'NOTNONE'
23+
env['NDKPLATFORM'] = self.ctx.ndk_platform
1924
env['CFLAGS'] = (env['CFLAGS'] +
2025
' -I{}'.format(join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include')) +
2126
' -I{}'.format(join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image')) +
2227
' -I{}'.format(join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer')) +
2328
' -I{}'.format(join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf')) +
24-
' -LSDL2 -LSDL2_image -LSDL2_mixer -LSDL2_ttf')
29+
' -I{}'.format(join(self.ctx.bootstrap.build_dir, 'jni', 'jpeg')) +
30+
' -I{}'.format(join(self.ctx.bootstrap.build_dir, 'jni', 'png')) +
31+
' -I{}'.format(join(self.ctx.bootstrap.build_dir, 'jni', 'freetype', 'include'))
32+
)
2533
env['CXXFLAGS'] = env['CFLAGS']
2634
env['PYGAME_SDL2_ANDROID'] = 'yes'
35+
env['PYGAME_SDL2_EXCLUDE'] = 'pygame_sdl2.mixer pygame_sdl2.mixer_music'
36+
env['PYGAME_SDL2_INSTALL_HEADERS'] = '1'
2737
return env
2838

39+
def build_arch(self, arch):
40+
with current_directory(self.get_build_dir(arch.arch)):
41+
try:
42+
sh.rm('-R', 'build/lib.android', 'build/tmp.android')
43+
except:
44+
pass
45+
hostpython = sh.Command(self.ctx.hostpython)
46+
env = self.get_recipe_env(arch)
47+
shprint(hostpython, 'setup.py', 'build_ext', '-b', 'build/lib.android', '-t',
48+
'bluid/tmp.android', 'install',
49+
'--prefix', '"{}"'.format(self.ctx.get_python_install_dir()),
50+
_env=env)
51+
filens = glob.glob('build/lib.android/*')
52+
info('pygame_sdl2 filens to copy are {}'.format(filens))
53+
for filen in filens:
54+
shprint(sh.cp, '-a', filen, self.ctx.get_site_packages_dir() + '/pygame_sdl2')
55+
2956
recipe = PygameSDL2Recipe()

0 commit comments

Comments
 (0)