Skip to content

Commit 5f05a70

Browse files
committed
Update libffi to version post v3.3RC0 and adapt it to be NDK 19 compatible
1 parent 6488f3c commit 5f05a70

File tree

3 files changed

+18
-96
lines changed

3 files changed

+18
-96
lines changed

pythonforandroid/recipes/libffi/__init__.py

Lines changed: 9 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from os.path import exists, join
22
from pythonforandroid.recipe import Recipe
3-
from pythonforandroid.logger import info, shprint
3+
from pythonforandroid.logger import shprint
44
from pythonforandroid.util import current_directory, ensure_dir
5-
from glob import glob
65
import sh
76

87

@@ -14,14 +13,11 @@ class LibffiRecipe(Recipe):
1413
- `libltdl-dev` which defines the `LT_SYS_SYMBOL_USCORE` macro
1514
"""
1615
name = 'libffi'
17-
version = '3.2.1'
18-
url = 'https://github.com/libffi/libffi/archive/v{version}.tar.gz'
16+
# Version pinned to post `v3.3RC0`
17+
version = '8fa8837'
18+
url = 'https://github.com/libffi/libffi/archive/{version}.tar.gz'
1919

20-
patches = ['remove-version-info.patch',
21-
# This patch below is already included into libffi's master
22-
# branch and included in the pre-release 3.3rc0...so we should
23-
# remove this when we update the version number for libffi
24-
'fix-includedir.patch']
20+
patches = ['remove-version-info.patch']
2521

2622
def should_build(self, arch):
2723
return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libffi.so'))
@@ -37,50 +33,11 @@ def build_arch(self, arch):
3733
'--prefix=' + self.get_build_dir(arch.arch),
3834
'--disable-builddir',
3935
'--enable-shared', _env=env)
40-
# '--with-sysroot={}'.format(self.ctx.ndk_platform),
41-
# '--target={}'.format(arch.toolchain_prefix),
42-
43-
# ndk 15 introduces unified headers required --sysroot and
44-
# -isysroot for libraries and headers. libtool's head explodes
45-
# trying to weave them into it's own magic. The result is a link
46-
# failure trying to link libc. We call make to compile the bits
47-
# and manually link...
48-
49-
try:
50-
shprint(sh.make, '-j5', 'libffi.la', _env=env)
51-
except sh.ErrorReturnCode_2:
52-
info("make libffi.la failed as expected")
53-
cc = sh.Command(env['CC'].split()[0])
54-
cflags = env['CC'].split()[1:]
55-
host_build = self.get_build_dir(arch.arch)
56-
57-
arch_flags = ''
58-
if '-march=' in env['CFLAGS']:
59-
arch_flags = '-march={}'.format(env['CFLAGS'].split('-march=')[1])
60-
61-
src_arch = arch.command_prefix.split('-')[0]
62-
if src_arch == 'x86_64':
63-
# libffi has not specific arch files for x86_64...so...using
64-
# the ones from x86 which seems to build fine...
65-
src_arch = 'x86'
66-
67-
cflags.extend(arch_flags.split())
68-
cflags.extend(['-shared', '-fPIC', '-DPIC'])
69-
cflags.extend(glob(join(host_build, 'src/.libs/*.o')))
70-
cflags.extend(glob(join(host_build, 'src', src_arch, '.libs/*.o')))
71-
72-
ldflags = env['LDFLAGS'].split()
73-
cflags.extend(ldflags)
74-
cflags.extend(['-Wl,-soname', '-Wl,libffi.so', '-o',
75-
'.libs/libffi.so'])
76-
77-
with current_directory(host_build):
78-
shprint(cc, *cflags, _env=env)
79-
36+
shprint(sh.make, '-j5', 'libffi.la', _env=env)
8037
ensure_dir(self.ctx.get_libs_dir(arch.arch))
81-
shprint(sh.cp,
82-
join(host_build, '.libs', 'libffi.so'),
83-
self.ctx.get_libs_dir(arch.arch))
38+
self.install_libs(
39+
arch, join(self.get_build_dir(arch.arch), '.libs', 'libffi.so')
40+
)
8441

8542
def get_include_dirs(self, arch):
8643
return [join(self.get_build_dir(arch.arch), 'include')]

pythonforandroid/recipes/libffi/fix-includedir.patch

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
diff -Naur libffi/Makefile.am b/Makefile.am
2-
--- libffi/Makefile.am 2014-11-12 06:00:59.000000000 -0600
3-
+++ b/Makefile.am 2015-12-23 15:57:10.363148806 -0600
4-
@@ -249,7 +249,7 @@
5-
AM_CFLAGS += -DFFI_DEBUG
6-
endif
7-
8-
-libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS)
1+
--- libffi/Makefile.am.orig 2018-12-21 16:11:26.159181262 +0100
2+
+++ libffi/Makefile.am 2018-12-21 16:14:44.075179374 +0100
3+
@@ -156,7 +156,7 @@
4+
libffi.map: $(top_srcdir)/libffi.map.in
5+
$(COMPILE) -D$(TARGET) -E -x assembler-with-cpp -o $@ $<
6+
7+
-libffi_la_LDFLAGS = -no-undefined $(libffi_version_info) $(libffi_version_script) $(LTLDFLAGS) $(AM_LTLDFLAGS)
98
+libffi_la_LDFLAGS = -no-undefined -avoid-version $(LTLDFLAGS) $(AM_LTLDFLAGS)
10-
9+
libffi_la_DEPENDENCIES = $(libffi_la_LIBADD) $(libffi_version_dep)
10+
1111
AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src
12-
AM_CCASFLAGS = $(AM_CPPFLAGS)

0 commit comments

Comments
 (0)