From 95c3d2066471cb698523b10cf54efb2ccea885b1 Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Sun, 1 Apr 2018 21:34:22 +0000 Subject: [PATCH] Greenlet Crystax/Python3 support, fixes #1245 Fixes CFLAGS, LDSHARED and LDFLAGS to point to Crystax. --- pythonforandroid/archs.py | 2 ++ pythonforandroid/recipes/greenlet/__init__.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/pythonforandroid/archs.py b/pythonforandroid/archs.py index e16db00961..1dba8a8c49 100644 --- a/pythonforandroid/archs.py +++ b/pythonforandroid/archs.py @@ -62,6 +62,8 @@ def get_env(self, with_flags_in_cc=True): if self.ctx.ndk == 'crystax': env['LDFLAGS'] += ' -L{}/sources/crystax/libs/{} -lcrystax'.format(self.ctx.ndk_dir, self.arch) + env['CFLAGS'] += ' -I{}/sources/python/{}/include/python/'.format( + self.ctx.ndk_dir, self.ctx.python_recipe.version[0:3]) py_platform = sys.platform if py_platform in ['linux2', 'linux3']: diff --git a/pythonforandroid/recipes/greenlet/__init__.py b/pythonforandroid/recipes/greenlet/__init__.py index a12758142f..0e26c10793 100644 --- a/pythonforandroid/recipes/greenlet/__init__.py +++ b/pythonforandroid/recipes/greenlet/__init__.py @@ -1,3 +1,4 @@ +import os from pythonforandroid.toolchain import PythonRecipe @@ -6,4 +7,15 @@ class GreenletRecipe(PythonRecipe): url = 'https://pypi.python.org/packages/source/g/greenlet/greenlet-{version}.tar.gz' depends = [('python2', 'python3crystax')] + def get_recipe_env(self, arch=None, with_flags_in_cc=True): + env = super(GreenletRecipe, self).get_recipe_env(arch, with_flags_in_cc) + # sets linker to use the correct gcc (cross compiler) + env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' + # required additional library and path for Crystax + if self.ctx.ndk == 'crystax': + env['LDFLAGS'] += ' -L{}'.format(os.path.join(self.ctx.bootstrap.build_dir, 'libs', arch.arch)) + env['LDFLAGS'] += ' -lpython{}m'.format(self.ctx.python_recipe.version[0:3]) + return env + + recipe = GreenletRecipe()