Skip to content

Commit 200fa23

Browse files
committed
Made android recipe work
1 parent 6c1c06a commit 200fa23

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

recipes/android/__init__.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

2-
from toolchain import PythonRecipe, shprint, ensure_dir
2+
from toolchain import PythonRecipe, shprint, ensure_dir, current_directory, ArchAndroid
33
import sh
4+
from os.path import exists, join
45

56

67
class AndroidRecipe(PythonRecipe):
@@ -12,6 +13,26 @@ class AndroidRecipe(PythonRecipe):
1213
def prebuild_armeabi(self):
1314
shprint(sh.cp, '-a', self.get_recipe_dir() + '/src', self.get_build_dir('armeabi'))
1415

16+
def build_armeabi(self):
17+
18+
with current_directory(join(self.get_build_dir('armeabi'), 'src')):
19+
if exists('.done'):
20+
print('android module already compiled, exiting')
21+
return
22+
23+
env = ArchAndroid(self.ctx).get_env()
24+
25+
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{}'.format(self.ctx.libs_dir)
26+
env['LDSHARED'] = env['LIBLINK']
27+
28+
shprint(sh.find, '.', '-iname', '*.pyx', '-exec', self.ctx.cython, '{}', ';')
29+
30+
hostpython = sh.Command(self.ctx.hostpython)
31+
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env)
32+
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env)
33+
34+
shprint(sh.touch, '.done')
35+
1536

1637

1738
recipe = AndroidRecipe()

recipes/pygame/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def build_armeabi(self):
4949
build_lib = glob.glob('./build/lib*')
5050
assert len(build_lib) == 1
5151
print('stripping pygame')
52-
shprint(sh.find, build_lib[0], '-name', '"*.o"', '-exec',
52+
shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
5353
env['STRIP'], '{}', ';')
5454

5555
python_install_path = join(self.ctx.build_dir, 'python-install')

recipes/pyjnius/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from toolchain import CythonRecipe, shprint, ArchAndroid, current_directory
33
import sh
44
import glob
5-
from os.path import join
5+
from os.path import join, exists
66

77

88
class PyjniusRecipe(CythonRecipe):
@@ -20,7 +20,15 @@ def build_armeabi(self):
2020
# AND: Hack to make pyjnius setup.py detect android build
2121
env['NDKPLATFORM'] = 'NOTNONE'
2222

23+
24+
# AND: Don't forget to add a check whether pyjnius has already
25+
# been compiled. Currently it redoes it every time.
26+
2327
with current_directory(self.get_actual_build_dir('armeabi')):
28+
if exists('.done'):
29+
print('android module already compiled, exiting')
30+
return
31+
2432
hostpython = sh.Command(self.ctx.hostpython)
2533

2634
# First build is fake in order to generate files that will be cythonized
@@ -41,14 +49,16 @@ def build_armeabi(self):
4149

4250
shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env)
4351

52+
4453
build_lib = glob.glob('./build/lib*')
45-
shprint(sh.find, build_lib[0], '-name', '"*.o"', '-exec',
54+
shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
4655
env['STRIP'], '{}', ';', _env=env)
4756

4857
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env)
4958

5059
shprint(sh.cp, '-a', join('jnius', 'src', 'org'), self.ctx.javaclass_dir)
5160

61+
shprint(sh.touch, '.done')
5262

5363

5464

0 commit comments

Comments
 (0)