2019-03-30 21:58:45 +01:00
|
|
|
import os
|
2017-08-13 03:24:00 +02:00
|
|
|
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
|
|
|
|
|
|
|
|
|
|
|
|
class CffiRecipe(CompiledComponentsPythonRecipe):
|
2019-03-30 21:58:45 +01:00
|
|
|
"""
|
|
|
|
Extra system dependencies: autoconf, automake and libtool.
|
|
|
|
"""
|
|
|
|
name = 'cffi'
|
2022-12-02 21:15:34 +01:00
|
|
|
version = '1.13.2'
|
2019-03-30 21:58:45 +01:00
|
|
|
url = 'https://pypi.python.org/packages/source/c/cffi/cffi-{version}.tar.gz'
|
|
|
|
|
|
|
|
depends = ['setuptools', 'pycparser', 'libffi']
|
|
|
|
|
|
|
|
patches = ['disable-pkg-config.patch']
|
|
|
|
|
|
|
|
# call_hostpython_via_targetpython = False
|
|
|
|
install_in_hostpython = True
|
|
|
|
|
|
|
|
def get_hostrecipe_env(self, arch=None):
|
|
|
|
# fixes missing ffi.h on some host systems (e.g. gentoo)
|
2022-12-02 21:15:34 +01:00
|
|
|
env = super().get_hostrecipe_env(arch)
|
2019-03-30 21:58:45 +01:00
|
|
|
libffi = self.get_recipe('libffi', self.ctx)
|
|
|
|
includes = libffi.get_include_dirs(arch)
|
|
|
|
env['FFI_INC'] = ",".join(includes)
|
|
|
|
return env
|
|
|
|
|
|
|
|
def get_recipe_env(self, arch=None):
|
2022-12-02 21:15:34 +01:00
|
|
|
env = super().get_recipe_env(arch)
|
2019-03-30 21:58:45 +01:00
|
|
|
libffi = self.get_recipe('libffi', self.ctx)
|
|
|
|
includes = libffi.get_include_dirs(arch)
|
|
|
|
env['CFLAGS'] = ' -I'.join([env.get('CFLAGS', '')] + includes)
|
|
|
|
env['CFLAGS'] += ' -I{}'.format(self.ctx.python_recipe.include_root(arch.arch))
|
|
|
|
env['LDFLAGS'] = (env.get('CFLAGS', '') + ' -L' +
|
|
|
|
self.ctx.get_libs_dir(arch.arch))
|
|
|
|
env['LDFLAGS'] += ' -L{}'.format(os.path.join(self.ctx.bootstrap.build_dir, 'libs', arch.arch))
|
|
|
|
# required for libc and libdl
|
2022-12-02 21:15:34 +01:00
|
|
|
env['LDFLAGS'] += ' -L{}'.format(arch.ndk_lib_dir_versioned)
|
2019-03-30 21:58:45 +01:00
|
|
|
env['PYTHONPATH'] = ':'.join([
|
2022-12-02 21:15:34 +01:00
|
|
|
self.ctx.get_site_packages_dir(arch),
|
2019-03-30 21:58:45 +01:00
|
|
|
env['BUILDLIB_PATH'],
|
|
|
|
])
|
|
|
|
env['LDFLAGS'] += ' -L{}'.format(self.ctx.python_recipe.link_root(arch.arch))
|
2022-12-02 21:15:34 +01:00
|
|
|
env['LDFLAGS'] += ' -lpython{}'.format(self.ctx.python_recipe.link_version)
|
2019-03-30 21:58:45 +01:00
|
|
|
return env
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
recipe = CffiRecipe()
|