Skip to content

Commit 6ad131c

Browse files
committed
Made pygame build work (including other fixes)
1 parent a6d0fc1 commit 6ad131c

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

recipes/pygame/__init__.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
from toolchain import PythonRecipe, shprint
2+
from toolchain import PythonRecipe, shprint, ArchAndroid, current_directory
33
from os.path import exists, join
44
import sh
55

@@ -13,10 +13,39 @@ def prebuild_armeabi(self):
1313
if exists(join(self.get_build_dir('armeabi'), '.patched')):
1414
print('Pygame already patched, skipping.')
1515
return
16+
shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'),
17+
join(self.get_actual_build_dir('armeabi'), 'Setup'))
1618
self.apply_patch(join('patches', 'fix-surface-access.patch'))
1719
self.apply_patch(join('patches', 'fix-array-surface.patch'))
1820
shprint(sh.touch, join(self.get_build_dir('armeabi'), '.patched'))
1921

22+
def build_armeabi(self):
23+
# AND: I'm going to ignore any extra pythonrecipe or cythonrecipe behaviour for now
24+
25+
env = ArchAndroid(self.ctx).get_env()
26+
27+
env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format(
28+
jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
29+
env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl/include -I{jni_path}/sdl_mixer'.format(
30+
jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
31+
env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/sdl_ttf -I{jni_path}/sdl_image'.format(
32+
jni_path=join(self.ctx.bootstrap.build_dir, 'jni'))
33+
print('pygame cflags', env['CFLAGS'])
34+
35+
36+
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{libs_path} -L{src_path}/obj/local/{arch} -lm -lz'.format(
37+
libs_path=self.ctx.libs_dir, src_path=self.ctx.bootstrap.build_dir, arch=env['ARCH'])
38+
print('pygame ldflags', env['LDFLAGS'])
39+
40+
env['LDSHARED'] = env['LIBLINK']
41+
42+
with current_directory(self.get_actual_build_dir('armeabi')):
43+
print('hostpython is', self.ctx.hostpython)
44+
hostpython = sh.Command(self.ctx.hostpython)
45+
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env)
46+
47+
print('strip is', env['STRIP'])
48+
exit(1)
2049

2150

2251
recipe = PygameRecipe()

recipes/python2/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def build_armeabi(self):
4040
print('sqlite or openssl support not yet enabled in python recipe')
4141
exit(1)
4242

43+
self.ctx.hostpython = join(self.ctx.build_dir, 'python-install',
44+
'bin', 'python.host')
45+
4346
if exists(join(self.ctx.libs_dir, 'libpython2.7.so')):
4447
print('libpython2.7.so already exists, skipping python build.')
4548
return
@@ -96,6 +99,14 @@ def build_armeabi(self):
9699

97100
print('Ready to copy .so for python arm')
98101
shprint(sh.cp, 'libpython2.7.so', self.ctx.libs_dir)
102+
103+
print('Copying hostpython binary to targetpython folder')
104+
shprint(sh.cp, self.ctx.hostpython,
105+
join(self.ctx.build_dir, 'python-install', 'bin',
106+
'python.host'))
107+
self.ctx.hostpython = join(self.ctx.build_dir, 'python-install',
108+
'bin', 'python.host')
109+
99110

100111
# reduce python?
101112
for dir_name in ('test', join('json', 'tests'), 'lib-tk',

toolchain.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,12 @@ def get_env(self):
258258
env['BUILDLIB_PATH'] = join(hostpython_recipe.get_actual_build_dir('armeabi'),
259259
'build', 'lib.linux-{}-2.7'.format(uname()[-1]))
260260

261+
262+
# AND: This stuff is set elsewhere in distribute.sh. Does that matter?
261263
env['ARCH'] = self.arch
264+
env['LIBLINK_PATH'] = join(self.ctx.build_dir, 'other_builds')
265+
env['LIBLINK'] = join(self.ctx.bootstrap.build_dir, 'tools', 'liblink')
266+
env['BIGLINK'] = join(self.ctx.bootstrap.build_dir, 'tools', 'biglink')
262267

263268
return env
264269

0 commit comments

Comments
 (0)