1
- import os
1
+ import re
2
+ from pythonforandroid .logger import info
2
3
from pythonforandroid .recipe import CompiledComponentsPythonRecipe
3
4
4
5
@@ -7,21 +8,27 @@ class GeventRecipe(CompiledComponentsPythonRecipe):
7
8
url = 'https://pypi.python.org/packages/source/g/gevent/gevent-{version}.tar.gz'
8
9
depends = [('python2' , 'python3crystax' ), 'greenlet' ]
9
10
patches = ["gevent.patch" ]
11
+ call_hostpython_via_targetpython = False
10
12
11
13
def get_recipe_env (self , arch = None , with_flags_in_cc = True ):
14
+ """
15
+ - Moves all -I<inc> -D<macro> from CFLAGS to CPPFLAGS environment.
16
+ - Moves all -l<lib> from LDFLAGS to LIBS environment.
17
+ - Fixes linker name (use cross compiler) and flags (appends LIBS)
18
+ """
12
19
env = super (GeventRecipe , self ).get_recipe_env (arch , with_flags_in_cc )
13
- # sets linker to use the correct gcc (cross compiler)
14
- env ['LDSHARED' ] = env ['CC' ] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
15
20
# CFLAGS may only be used to specify C compiler flags, for macro definitions use CPPFLAGS
16
- env ['CPPFLAGS' ] = env ['CFLAGS' ] + ' -I{}/sources/python/3.5/include/python/' .format (self .ctx .ndk_dir )
17
- env ['CFLAGS' ] = ''
21
+ regex = re .compile ('\s*-[DI][\S]+' )
22
+ env ['CPPFLAGS' ] = '' .join (re .findall (regex , env ['CFLAGS' ])).strip ()
23
+ env ['CFLAGS' ] = re .sub (regex , '' , env ['CFLAGS' ])
24
+ info ('Moved "{}" from CFLAGS to CPPFLAGS.' .format (env ['CPPFLAGS' ]))
18
25
# LDFLAGS may only be used to specify linker flags, for libraries use LIBS
19
- env [ 'LDFLAGS' ] = env [ 'LDFLAGS' ]. replace ( '-lm' , '' ). replace ( '-lcrystax' , ' ' )
20
- env ['LDFLAGS ' ] + = ' -L{}' . format ( os . path . join (self . ctx . bootstrap . build_dir , 'libs' , arch . arch ) )
21
- env ['LIBS ' ] = ' -lm'
22
- if self . ctx . ndk == 'crystax' :
23
- env [ 'LIBS' ] += ' -lcrystax -lpython{}m' . format ( self . ctx . python_recipe . version [ 0 : 3 ])
24
- env ['LDSHARED' ] += env ['LIBS' ]
26
+ regex = re . compile ( '\s*-l[\w\.]+ ' )
27
+ env ['LIBS ' ] = '' . join (re . findall ( regex , env [ 'LDFLAGS' ])). strip ( )
28
+ env ['LDFLAGS ' ] = re . sub ( regex , '' , env [ 'LDFLAGS' ])
29
+ info ( 'Moved "{}" from LDFLAGS to LIBS.' . format ( env [ 'LIBS' ]))
30
+ # linker to use the correct gcc (cross compiler) plus additional libs
31
+ env ['LDSHARED' ] = '{} -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions {}' . format ( env ['CC' ], env [ ' LIBS' ])
25
32
return env
26
33
27
34
0 commit comments