2018-10-07 16:59:03 +02:00
|
|
|
from os.path import exists, join
|
2019-07-10 22:34:52 +02:00
|
|
|
from multiprocessing import cpu_count
|
2018-10-07 16:59:03 +02:00
|
|
|
from pythonforandroid.recipe import Recipe
|
2019-07-10 22:34:52 +02:00
|
|
|
from pythonforandroid.logger import shprint
|
|
|
|
from pythonforandroid.util import current_directory, ensure_dir
|
2018-10-07 16:59:03 +02:00
|
|
|
import sh
|
|
|
|
|
|
|
|
|
|
|
|
class LibffiRecipe(Recipe):
|
2019-07-10 22:34:52 +02:00
|
|
|
"""
|
|
|
|
Requires additional system dependencies on Ubuntu:
|
|
|
|
- `automake` for the `aclocal` binary
|
|
|
|
- `autoconf` for the `autoreconf` binary
|
|
|
|
- `libltdl-dev` which defines the `LT_SYS_SYMBOL_USCORE` macro
|
|
|
|
"""
|
2018-10-07 16:59:03 +02:00
|
|
|
name = 'libffi'
|
2019-07-10 22:34:52 +02:00
|
|
|
version = '3.2.1'
|
|
|
|
url = 'https://github.com/libffi/libffi/archive/v{version}.tar.gz'
|
2018-10-07 16:59:03 +02:00
|
|
|
|
2019-07-10 22:34:52 +02:00
|
|
|
patches = ['remove-version-info.patch',
|
|
|
|
# This patch below is already included into libffi's master
|
|
|
|
# branch and included in the pre-release 3.3rc0...so we should
|
|
|
|
# remove this when we update the version number for libffi
|
|
|
|
'fix-includedir.patch']
|
2018-10-07 16:59:03 +02:00
|
|
|
|
|
|
|
def should_build(self, arch):
|
|
|
|
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libffi.so'))
|
|
|
|
|
|
|
|
def build_arch(self, arch):
|
|
|
|
env = self.get_recipe_env(arch)
|
|
|
|
with current_directory(self.get_build_dir(arch.arch)):
|
|
|
|
if not exists('configure'):
|
|
|
|
shprint(sh.Command('./autogen.sh'), _env=env)
|
|
|
|
shprint(sh.Command('autoreconf'), '-vif', _env=env)
|
|
|
|
shprint(sh.Command('./configure'),
|
2019-07-10 22:34:52 +02:00
|
|
|
'--host=' + arch.command_prefix,
|
|
|
|
'--prefix=' + self.get_build_dir(arch.arch),
|
|
|
|
'--disable-builddir',
|
2018-10-07 16:59:03 +02:00
|
|
|
'--enable-shared', _env=env)
|
|
|
|
|
2019-07-10 22:34:52 +02:00
|
|
|
shprint(sh.make, '-j', str(cpu_count()), 'libffi.la', _env=env)
|
2018-10-07 16:59:03 +02:00
|
|
|
|
2019-07-10 22:34:52 +02:00
|
|
|
host_build = self.get_build_dir(arch.arch)
|
|
|
|
ensure_dir(self.ctx.get_libs_dir(arch.arch))
|
|
|
|
shprint(sh.cp,
|
|
|
|
join(host_build, '.libs', 'libffi.so'),
|
|
|
|
self.ctx.get_libs_dir(arch.arch))
|
2018-10-07 16:59:03 +02:00
|
|
|
|
|
|
|
def get_include_dirs(self, arch):
|
2019-07-10 22:34:52 +02:00
|
|
|
return [join(self.get_build_dir(arch.arch), 'include')]
|
2018-10-07 16:59:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
recipe = LibffiRecipe()
|