|
1 | 1 |
|
2 |
| -from pythonforandroid.toolchain import CythonRecipe, shprint, current_directory, ArchAndroid |
| 2 | +from pythonforandroid.toolchain import Recipe, shprint, current_directory, ArchAndroid |
3 | 3 | from os.path import exists, join
|
4 | 4 | import sh
|
5 | 5 | import glob
|
6 | 6 |
|
7 | 7 |
|
8 |
| -class PygameSDL2Recipe(CythonRecipe): |
| 8 | +class PygameSDL2Recipe(Recipe): |
9 | 9 | # version = 'stable'
|
10 | 10 | version = 'master'
|
11 | 11 | url = 'https://github.com/renpy/pygame_sdl2/archive/{version}.zip'
|
12 | 12 | name = 'pygame_sdl2'
|
13 | 13 |
|
14 |
| - depends = ['sdl2'] |
| 14 | + depends = ['sdl2', 'pygame_sdl2_bootstrap_components'] |
15 | 15 | conflicts = ['pygame']
|
16 | 16 |
|
17 | 17 | def get_recipe_env(self, arch):
|
18 | 18 | 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 |
19 | 24 | env['CFLAGS'] = (env['CFLAGS'] +
|
20 | 25 | ' -I{}'.format(join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include')) +
|
21 | 26 | ' -I{}'.format(join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image')) +
|
22 | 27 | ' -I{}'.format(join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_mixer')) +
|
23 | 28 | ' -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 | + ) |
25 | 33 | env['CXXFLAGS'] = env['CFLAGS']
|
26 | 34 | env['PYGAME_SDL2_ANDROID'] = 'yes'
|
| 35 | + env['PYGAME_SDL2_EXCLUDE'] = 'pygame_sdl2.mixer pygame_sdl2.mixer_music' |
| 36 | + env['PYGAME_SDL2_INSTALL_HEADERS'] = '1' |
27 | 37 | return env
|
28 | 38 |
|
| 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 | + |
29 | 56 | recipe = PygameSDL2Recipe()
|
0 commit comments