8000 Merge pull request #599 from kived/arm64 · kivy/python-for-android@72c57b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 72c57b1

Browse files
committed
Merge pull request #599 from kived/arm64
add aarch64/arm64-v8a arch
2 parents 0e01214 + 82a7f4f commit 72c57b1

File tree

12 files changed

+102
-25
lines changed

12 files changed

+102
-25
lines changed

pythonforandroid/archs.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from os.path import (join)
1+
from os.path import (join, dirname)
22
from os import environ, uname
33
import sys
44
from distutils.spawn import find_executable
@@ -161,3 +161,22 @@ def get_env(self, with_flags_in_cc=True):
161161
' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel')
162162
env['CXXFLAGS'] = env['CFLAGS']
163163
return env
164+
165+
166+
class ArchAarch_64(Arch):
167+
arch = 'arm64-v8a'
168+
toolchain_prefix = 'aarch64-linux-android'
169+
command_prefix = 'aarch64-linux-android'
170+
platform_dir = 'arch-arm64'
171+
172+
def get_env(self, with_flags_in_cc=True):
173+
env = super(ArchAarch_64, self).get_env(with_flags_in_cc)
174+
incpath = ' -I' + join(dirname(__file__), 'includes', 'arm64-v8a')
175+
env['EXTRA_CFLAGS'] = incpath
176+
env['CFLAGS'] += incpath
177+
env['CXXFLAGS'] += incpath
178+
if with_flags_in_cc:
179+
env['CC'] += incpath
180+
env['CXX'] += incpath
181+
return env
182+

pythonforandroid/bootstrap.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from os.path import (join, dirname, isdir, splitext, basename)
1+
from os.path import (join, dirname, isdir, splitext, basename, realpath)
22
from os import listdir
33
import sh
44
import glob
@@ -253,3 +253,14 @@ def strip_libraries(self, arch):
253253
strip(filen, _env=env)
254254
except sh.ErrorReturnCode_1:
255255
logger.debug('Failed to strip ' + filen)
256+
257+
def fry_eggs(self, sitepackages):
258+
info('Frying eggs in {}'.format(sitepackages))
259+
for d in listdir(sitepackages):
260+
rd = join(sitepackages, d)
261+
if isdir(rd) and d.endswith('.egg'):
262+
info(' ' + d)
263+
files = [join(rd, f) for f in listdir(rd) if f != 'EGG-INFO']
264+
shprint(sh.mv, '-t', sitepackages, *files)
265+
shprint(sh.rm, '-rf', d)
266+

pythonforandroid/bootstraps/sdl2/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ def run_distribute(self):
6464
shprint(sh.rm, '-f', join('private', 'lib', 'libpython2.7.so'))
6565
shprint(sh.rm, '-rf', join('private', 'lib', 'pkgconfig'))
6666

67-
with current_directory(join(self.dist_dir, 'private', 'lib', 'python2.7')):
67+
libdir = join(self.dist_dir, 'private', 'lib', 'python2.7')
68+
site_packages_dir = join(libdir, 'site-packages')
69+
with current_directory(libdir):
6870
# shprint(sh.xargs, 'rm', sh.grep('-E', '*\.(py|pyx|so\.o|so\.a|so\.libs)$', sh.find('.')))
6971
removes = []
7072
for dirname, something, filens in walk('.'):
@@ -107,6 +109,7 @@ def run_distribute(self):
107109

108110

109111
self.strip_libraries(arch)
112+
self.fry_eggs(site_packages_dir)
110113
super(SDL2Bootstrap, self).run_distribute()
111114

112115
bootstrap = SDL2Bootstrap()

pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include
1212
LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
1313
start.c
1414

15-
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../other_builds/$(PYTHON2_NAME)/$(ARCH)/python2/python-install/include/python2.7
15+
LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../other_builds/$(PYTHON2_NAME)/$(ARCH)/python2/python-install/include/python2.7 $(EXTRA_CFLAGS)
1616

1717
LOCAL_SHARED_LIBRARIES := SDL2 python_shared
1818

pythonforandroid/build.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from pythonforandroid.logger import (info, warning, error, info_notify,
1515
Err_Fore, Err_Style, info_main,
1616
shprint)
17-
from pythonforandroid.archs import ArchARM, ArchARMv7_a, Archx86, Archx86_64
17+
from pythonforandroid.archs import ArchARM, ArchARMv7_a, Archx86, Archx86_64, ArchAarch_64
1818
from pythonforandroid.recipe import Recipe
1919

2020
DEFAULT_ANDROID_API = 15
@@ -432,7 +432,8 @@ def __init__(self):
432432
self.archs = (
433433
ArchARM(self),
434434
ArchARMv7_a(self),
435-
Archx86(self)
435+
Archx86(self),
436+
ArchAarch_64(self),
436437
)
437438

438439
ensure_dir(join(self.build_dir, 'bootstrap_builds'))

pythonforandroid/recipes/cdecimal/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ class CdecimalRecipe(CompiledComponentsPythonRecipe):
1616
def prebuild_arch(self, arch):
1717
super(CdecimalRecipe, self).prebuild_arch(arch)
1818
if not is_darwin():
19-
self.setup_extra_args = ['--with-machine=ansi32']
19+
if '64' in arch.arch:
20+
machine = 'ansi64'
21+
else:
22+
machine = 'ansi32'
23+
self.setup_extra_args = ['--with-machine=' + machine]
2024

2125

2226
recipe = CdecimalRecipe()

pythonforandroid/recipes/cryptography/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ def get_recipe_env(self, arch=None):
3636
print env
3737
return env
3838

39+
def build_arch(self, arch):
40+
super(CryptographyRecipe, self).build_arch(arch)
41+
3942

4043
recipe = CryptographyRecipe()

pythonforandroid/recipes/libffi/__init__.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,20 @@ class LibffiRecipe(Recipe):
1313

1414
patches = ['remove-version-info.patch']
1515

16-
host = 'arm-unknown-linux-androideabi'
16+
def get_host(self, arch):
17+
with current_directory(self.get_build_dir(arch.arch)):
18+
host = None
19+
with open('Makefile') as f:
20+
for line in f:
21+
if line.startswith('host = '):
22+
host = line.strip()[7:]
23+
break
24+
25+
if not host or not exists(host):
26+
raise RuntimeError('failed to find build output! ({})'
27+
.format(host))
28+
29+
return host
1730

1831
def should_build(self, arch):
1932
# return not bool(glob.glob(join(self.ctx.get_libs_dir(arch.arch),
@@ -27,23 +40,11 @@ def build_arch(self, arch):
2740
with current_directory(self.get_build_dir(arch.arch)):
2841
if not exists('configure'):
2942
shprint(sh.Command('./autogen.sh'), _env=env)
30-
shprint(sh.Command('./configure'), '--host=arm-linux-androideabi',
43+
shprint(sh.Command('./configure'), '--host=' + arch.toolchain_prefix,
3144
'--prefix=' + self.ctx.get_python_install_dir(),
3245
'--enable-shared', _env=env)
3346
shprint(sh.make, '-j5', 'libffi.la', _env=env)
3447

35-
host = None
36-
with open('Makefile') as f:
37-
for line in f:
38-
if line.startswith('host = '):
39-
host = line.strip()[7:]
40-
break
41-
42-
if not host or not exists(host):
43-
raise RuntimeError('failed to find build output! ({})'
44-
.format(host))
45-
46-
self.host = host
4748

4849
# dlname = None
4950
# with open(join(host, 'libffi.la')) as f:
@@ -59,11 +60,11 @@ def build_arch(self, arch):
5960
# shprint(sh.sed, '-i', 's/^dlname=.*$/dlname=\'libffi.so\'/', join(host, 'libffi.la'))
6061

6162
shprint(sh.cp, '-t', self.ctx.get_libs_dir(arch.arch),
62-
join(host, '.libs', 'libffi.so')) #,
63+
join(self.get_host(arch), '.libs', 'libffi.so')) #,
6364
# join(host, 'libffi.la'))
6465

6566
def get_include_dirs(self, arch):
66-
return [join(self.get_build_dir(arch.arch), self.host, 'include')]
67+
return [join(self.get_build_dir(arch.arch), self.get_host(arch), 'include')]
6768

6869

6970
recipe = LibffiRecipe()

pythonforandroid/recipes/openssl/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,24 @@ def get_recipe_env(self, arch=None):
2626
env['CC'] += ' ' + env['LDFLAGS']
2727
return env
2828

29+
def select_build_arch(self, arch):
30+
aname = arch.arch
31+
if 'arm64' in aname:
32+
return 'linux-aarch64'
33+
if 'v7a' in aname:
34+
return 'android-armv7'
35+
if 'arm' in aname:
36+
return 'android'
37+
return 'linux-armv4'
38+
2939
def build_arch(self, arch):
3040
env = self.get_recipe_env(arch)
3141
with current_directory(self.get_build_dir(arch.arch)):
3242
# sh fails with code 255 trying to execute ./Configure
3343
# so instead we manually run perl passing in Configure
3444
perl = sh.Command('perl')
35-
shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', 'linux-armv4', _env=env)
45+
buildarch = self.select_build_arch(arch)
46+
shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', buildarch, _env=env)
3647
self.apply_patch('disable-sover.patch', arch.arch)
3748

3849
check_crypto = partial(self.check_symbol, env, 'libcrypto.so')

pythonforandroid/recipes/sdl2_image/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ class LibSDL2Image(BootstrapNDKRecipe):
88
dir_name = 'SDL2_image'
99

1010
patches = ['disable_webp.patch',
11-
('disable_jpg.patch', is_arch('x86'))]
11+
('disable_jpg.patch', is_arch('x86')),
12+
'extra-cflags.patch',
13+
('disable-assembler.patch', is_arch('arm64-v8a'))]
1214

1315

1416
recipe = LibSDL2Image()

0 commit comments

Comments
 (0)
0