Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion pythonforandroid/archs.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

13 changes: 12 additions & 1 deletion pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

5 changes: 4 additions & 1 deletion pythonforandroid/bootstraps/sdl2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('.'):
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion pythonforandroid/bootstraps/sdl2/build/jni/src/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'))
Expand Down
6 changes: 5 additions & 1 deletion pythonforandroid/recipes/cdecimal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
3 changes: 3 additions & 0 deletions pythonforandroid/recipes/cryptography/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
33 changes: 17 additions & 16 deletions pythonforandroid/recipes/libffi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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:
Expand All @@ -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()
13 changes: 12 additions & 1 deletion pythonforandroid/recipes/openssl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 3 additions & 1 deletion pythonforandroid/recipes/sdl2_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
11 changes: 11 additions & 0 deletions pythonforandroid/recipes/sdl2_image/disable-assembler.patch
Original file line number Diff line number Diff line change
@@ -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 \
11 changes: 11 additions & 0 deletions pythonforandroid/recipes/sdl2_image/extra-cflags.patch
Original file line number Diff line number Diff line change
@@ -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)))