diff --git a/pythonforandroid/archs.py b/pythonforandroid/archs.py index 29471c7963..a9eccdd80a 100644 --- a/pythonforandroid/archs.py +++ b/pythonforandroid/archs.py @@ -1,4 +1,4 @@ -from os.path import (join) +from os.path import (join, dirname) from os import environ, uname import sys from distutils.spawn import find_executable @@ -161,3 +161,22 @@ def get_env(self, with_flags_in_cc=True): ' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel') env['CXXFLAGS'] = env['CFLAGS'] return env + + +class ArchAarch_64(Arch): + arch = 'arm64-v8a' + toolchain_prefix = 'aarch64-linux-android' + command_prefix = 'aarch64-linux-android' + platform_dir = 'arch-arm64' + + def get_env(self, with_flags_in_cc=True): + env = super(ArchAarch_64, self).get_env(with_flags_in_cc) + incpath = ' -I' + join(dirname(__file__), 'includes', 'arm64-v8a') + env['EXTRA_CFLAGS'] = incpath + env['CFLAGS'] += incpath + env['CXXFLAGS'] += incpath + if with_flags_in_cc: + env['CC'] += incpath + env['CXX'] += incpath + return env + diff --git a/pythonforandroid/bootstrap.py b/pythonforandroid/bootstrap.py index 8f4ddf75a6..546199c00e 100644 --- a/pythonforandroid/bootstrap.py +++ b/pythonforandroid/bootstrap.py @@ -1,4 +1,4 @@ -from os.path import (join, dirname, isdir, splitext, basename) +from os.path import (join, dirname, isdir, splitext, basename, realpath) from os import listdir import sh import glob @@ -253,3 +253,14 @@ def strip_libraries(self, arch): strip(filen, _env=env) except sh.ErrorReturnCode_1: logger.debug('Failed to strip ' + filen) + + def fry_eggs(self, sitepackages): + info('Frying eggs in {}'.format(sitepackages)) + for d in listdir(sitepackages): + rd = join(sitepackages, d) + if isdir(rd) and d.endswith('.egg'): + info(' ' + d) + files = [join(rd, f) for f in listdir(rd) if f != 'EGG-INFO'] + shprint(sh.mv, '-t', sitepackages, *files) + shprint(sh.rm, '-rf', d) + diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index 54e17929e4..62ac0a16bb 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -64,7 +64,9 @@ def run_distribute(self): shprint(sh.rm, '-f', join('private', 'lib', 'libpython2.7.so')) shprint(sh.rm, '-rf', join('private', 'lib', 'pkgconfig')) - with current_directory(join(self.dist_dir, 'private', 'lib', 'python2.7')): + libdir = join(self.dist_dir, 'private', 'lib', 'python2.7') + site_packages_dir = join(libdir, 'site-packages') + with current_directory(libdir): # shprint(sh.xargs, 'rm', sh.grep('-E', '*\.(py|pyx|so\.o|so\.a|so\.libs)$', sh.find('.'))) removes = [] for dirname, something, filens in walk('.'): @@ -107,6 +109,7 @@ def run_distribute(self): self.strip_libraries(arch) + self.fry_eggs(site_packages_dir) super(SDL2Bootstrap, self).run_distribute() bootstrap = SDL2Bootstrap() diff --git a/pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk b/pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk index 5d2120f2c0..41d689d688 100644 --- a/pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk +++ b/pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk @@ -12,7 +12,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \ start.c -LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../other_builds/$(PYTHON2_NAME)/$(ARCH)/python2/python-install/include/python2.7 +LOCAL_CFLAGS += -I$(LOCAL_PATH)/../../../../other_builds/$(PYTHON2_NAME)/$(ARCH)/python2/python-install/include/python2.7 $(EXTRA_CFLAGS) LOCAL_SHARED_LIBRARIES := SDL2 python_shared diff --git a/pythonforandroid/build.py b/pythonforandroid/build.py index 4e32741c4e..fa600d5bde 100644 --- a/pythonforandroid/build.py +++ b/pythonforandroid/build.py @@ -14,7 +14,7 @@ from pythonforandroid.logger import (info, warning, error, info_notify, Err_Fore, Err_Style, info_main, shprint) -from pythonforandroid.archs import ArchARM, ArchARMv7_a, Archx86, Archx86_64 +from pythonforandroid.archs import ArchARM, ArchARMv7_a, Archx86, Archx86_64, ArchAarch_64 from pythonforandroid.recipe import Recipe DEFAULT_ANDROID_API = 15 @@ -432,7 +432,8 @@ def __init__(self): self.archs = ( ArchARM(self), ArchARMv7_a(self), - Archx86(self) + Archx86(self), + ArchAarch_64(self), ) ensure_dir(join(self.build_dir, 'bootstrap_builds')) diff --git a/pythonforandroid/recipes/cdecimal/__init__.py b/pythonforandroid/recipes/cdecimal/__init__.py index f37b6b5e63..e08185943b 100644 --- a/pythonforandroid/recipes/cdecimal/__init__.py +++ b/pythonforandroid/recipes/cdecimal/__init__.py @@ -16,7 +16,11 @@ class CdecimalRecipe(CompiledComponentsPythonRecipe): def prebuild_arch(self, arch): super(CdecimalRecipe, self).prebuild_arch(arch) if not is_darwin(): - self.setup_extra_args = ['--with-machine=ansi32'] + if '64' in arch.arch: + machine = 'ansi64' + else: + machine = 'ansi32' + self.setup_extra_args = ['--with-machine=' + machine] recipe = CdecimalRecipe() diff --git a/pythonforandroid/recipes/cryptography/__init__.py b/pythonforandroid/recipes/cryptography/__init__.py index 7ae738559a..5594fe4803 100644 --- a/pythonforandroid/recipes/cryptography/__init__.py +++ b/pythonforandroid/recipes/cryptography/__init__.py @@ -36,5 +36,8 @@ def get_recipe_env(self, arch=None): print env return env + def build_arch(self, arch): + super(CryptographyRecipe, self).build_arch(arch) + recipe = CryptographyRecipe() diff --git a/pythonforandroid/recipes/libffi/__init__.py b/pythonforandroid/recipes/libffi/__init__.py index 016f6c9ec3..b4adf9a391 100644 --- a/pythonforandroid/recipes/libffi/__init__.py +++ b/pythonforandroid/recipes/libffi/__init__.py @@ -13,7 +13,20 @@ class LibffiRecipe(Recipe): patches = ['remove-version-info.patch'] - host = 'arm-unknown-linux-androideabi' + def get_host(self, arch): + with current_directory(self.get_build_dir(arch.arch)): + host = None + with open('Makefile') as f: + for line in f: + if line.startswith('host = '): + host = line.strip()[7:] + break + + if not host or not exists(host): + raise RuntimeError('failed to find build output! ({})' + .format(host)) + + return host def should_build(self, arch): # return not bool(glob.glob(join(self.ctx.get_libs_dir(arch.arch), @@ -27,23 +40,11 @@ def build_arch(self, arch): with current_directory(self.get_build_dir(arch.arch)): if not exists('configure'): shprint(sh.Command('./autogen.sh'), _env=env) - shprint(sh.Command('./configure'), '--host=arm-linux-androideabi', + shprint(sh.Command('./configure'), '--host=' + arch.toolchain_prefix, '--prefix=' + self.ctx.get_python_install_dir(), '--enable-shared', _env=env) shprint(sh.make, '-j5', 'libffi.la', _env=env) - host = None - with open('Makefile') as f: - for line in f: - if line.startswith('host = '): - host = line.strip()[7:] - break - - if not host or not exists(host): - raise RuntimeError('failed to find build output! ({})' - .format(host)) - - self.host = host # dlname = None # with open(join(host, 'libffi.la')) as f: @@ -59,11 +60,11 @@ def build_arch(self, arch): # shprint(sh.sed, '-i', 's/^dlname=.*$/dlname=\'libffi.so\'/', join(host, 'libffi.la')) shprint(sh.cp, '-t', self.ctx.get_libs_dir(arch.arch), - join(host, '.libs', 'libffi.so')) #, + join(self.get_host(arch), '.libs', 'libffi.so')) #, # join(host, 'libffi.la')) def get_include_dirs(self, arch): - return [join(self.get_build_dir(arch.arch), self.host, 'include')] + return [join(self.get_build_dir(arch.arch), self.get_host(arch), 'include')] recipe = LibffiRecipe() diff --git a/pythonforandroid/recipes/openssl/__init__.py b/pythonforandroid/recipes/openssl/__init__.py index e2b08fc896..f3df432a2a 100644 --- a/pythonforandroid/recipes/openssl/__init__.py +++ b/pythonforandroid/recipes/openssl/__init__.py @@ -26,13 +26,24 @@ def get_recipe_env(self, arch=None): env['CC'] += ' ' + env['LDFLAGS'] return env + def select_build_arch(self, arch): + aname = arch.arch + if 'arm64' in aname: + return 'linux-aarch64' + if 'v7a' in aname: + return 'android-armv7' + if 'arm' in aname: + return 'android' + return 'linux-armv4' + def build_arch(self, arch): env = self.get_recipe_env(arch) with current_directory(self.get_build_dir(arch.arch)): # sh fails with code 255 trying to execute ./Configure # so instead we manually run perl passing in Configure perl = sh.Command('perl') - shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', 'linux-armv4', _env=env) + buildarch = self.select_build_arch(arch) + shprint(perl, 'Configure', 'shared', 'no-dso', 'no-krb5', buildarch, _env=env) self.apply_patch('disable-sover.patch', arch.arch) check_crypto = partial(self.check_symbol, env, 'libcrypto.so') diff --git a/pythonforandroid/recipes/sdl2_image/__init__.py b/pythonforandroid/recipes/sdl2_image/__init__.py index 75cd76d672..72f20a7ce3 100644 --- a/pythonforandroid/recipes/sdl2_image/__init__.py +++ b/pythonforandroid/recipes/sdl2_image/__init__.py @@ -8,7 +8,9 @@ class LibSDL2Image(BootstrapNDKRecipe): dir_name = 'SDL2_image' patches = ['disable_webp.patch', - ('disable_jpg.patch', is_arch('x86'))] + ('disable_jpg.patch', is_arch('x86')), + 'extra-cflags.patch', + ('disable-assembler.patch', is_arch('arm64-v8a'))] recipe = LibSDL2Image() diff --git a/pythonforandroid/recipes/sdl2_image/disable-assembler.patch b/pythonforandroid/recipes/sdl2_image/disable-assembler.patch new file mode 100644 index 0000000000..e6c4ea3dfc --- /dev/null +++ b/pythonforandroid/recipes/sdl2_image/disable-assembler.patch @@ -0,0 +1,11 @@ +--- SDL2_image/Android.mk 2016-01-14 14:08:07.989191133 -0600 ++++ b/Android.mk 2016-01-14 14:09:53.439136814 -0600 +@@ -77,7 +77,7 @@ + $(JPG_LIBRARY_PATH)/jfdctfst.c \ + $(JPG_LIBRARY_PATH)/jfdctint.c \ + $(JPG_LIBRARY_PATH)/jidctflt.c \ +- $(JPG_LIBRARY_PATH)/jidctfst.S \ ++ $(JPG_LIBRARY_PATH)/jidctfst.c \ + $(JPG_LIBRARY_PATH)/jidctint.c \ + $(JPG_LIBRARY_PATH)/jquant1.c \ + $(JPG_LIBRARY_PATH)/jquant2.c \ diff --git a/pythonforandroid/recipes/sdl2_image/extra-cflags.patch b/pythonforandroid/recipes/sdl2_image/extra-cflags.patch new file mode 100644 index 0000000000..dd7969381c --- /dev/null +++ b/pythonforandroid/recipes/sdl2_image/extra-cflags.patch @@ -0,0 +1,11 @@ +--- SDL2_image/Android.mk 2016-01-14 13:55:28.195171992 -0600 ++++ b/Android.mk 2016-01-14 13:55:15.038929244 -0600 +@@ -23,7 +23,7 @@ + LOCAL_C_INCLUDES := $(LOCAL_PATH) + LOCAL_CFLAGS := -DLOAD_BMP -DLOAD_GIF -DLOAD_LBM -DLOAD_PCX -DLOAD_PNM \ + -DLOAD_TGA -DLOAD_XCF -DLOAD_XPM -DLOAD_XV +-LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays ++LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays $(EXTRA_CFLAGS) + + LOCAL_SRC_FILES := $(notdir $(filter-out %/showimage.c, $(wildcard $(LOCAL_PATH)/*.c))) +