1
1
from os .path import exists , join
2
2
from pythonforandroid .recipe import Recipe
3
- from pythonforandroid .logger import info , shprint
3
+ from pythonforandroid .logger import shprint
4
4
from pythonforandroid .util import current_directory , ensure_dir
5
- from glob import glob
6
5
import sh
7
6
8
7
@@ -14,14 +13,11 @@ class LibffiRecipe(Recipe):
14
13
- `libltdl-dev` which defines the `LT_SYS_SYMBOL_USCORE` macro
15
14
"""
16
15
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'
19
19
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' ]
25
21
26
22
def should_build (self , arch ):
27
23
return not exists (join (self .ctx .get_libs_dir (arch .arch ), 'libffi.so' ))
@@ -37,50 +33,11 @@ def build_arch(self, arch):
37
33
'--prefix=' + self .get_build_dir (arch .arch ),
38
34
'--disable-builddir' ,
39
35
'--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 )
80
37
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
+ )
84
41
85
42
def get_include_dirs (self , arch ):
86
43
return [join (self .get_build_dir (arch .arch ), 'include' )]
0 commit comments