|
| 1 | +import re |
| 2 | + |
| 3 | +from pythonforandroid.logger import info |
| 4 | +from pythonforandroid.recipe import CythonRecipe |
| 5 | + |
| 6 | + |
| 7 | +class GeventRecipe(CythonRecipe): |
| 8 | + version = '1.4.0' |
| 9 | + url = ( |
| 10 | + 'https://pypi.python.org/packages/source/g/gevent/' |
| 11 | + 'gevent-{version}.tar.gz' |
| 12 | + ) |
| 13 | + depends = ['librt', 'greenlet'] |
| 14 | + patches = ["cross_compiling.patch"] |
| 15 | + |
| 16 | + def get_recipe_env(self, arch=None, with_flags_in_cc=True): |
| 17 | + """ |
| 18 | + - Moves all -I<inc> -D<macro> from CFLAGS to CPPFLAGS environment. |
| 19 | + - Moves all -l<lib> from LDFLAGS to LIBS environment. |
| 20 | + - Copies all -l<lib> from LDLIBS to LIBS environment. |
| 21 | + - Fixes linker name (use cross compiler) and flags (appends LIBS) |
| 22 | + """ |
| 23 | + env = super().get_recipe_env(arch, with_flags_in_cc) |
| 24 | + # CFLAGS may only be used to specify C compiler flags, |
| 25 | + # for macro definitions use CPPFLAGS |
| 26 | + regex = re.compile(r'(?:\s|^)-[DI][\S]+') |
| 27 | + env['CPPFLAGS'] = ''.join(re.findall(regex, env['CFLAGS'])).strip() |
| 28 | + env['CFLAGS'] = re.sub(regex, '', env['CFLAGS']) |
| 29 | + info('Moved "{}" from CFLAGS to CPPFLAGS.'.format(env['CPPFLAGS'])) |
| 30 | + # LDFLAGS may only be used to specify linker flags, |
| 31 | + # for libraries use LIBS |
| 32 | + regex = re.compile(r'(?:\s|^)-l[\w\.]+') |
| 33 | + env['LIBS'] = ''.join(re.findall(regex, env['LDFLAGS'])).strip() |
| 34 | + env['LIBS'] += ' {}'.format( |
| 35 | + ''.join(re.findall(regex, env['LDLIBS'])).strip()) |
| 36 | + env['LDFLAGS'] = re.sub(regex, '', env['LDFLAGS']) |
| 37 | + info('Moved "{}" from LDFLAGS to LIBS.'.format(env['LIBS'])) |
| 38 | + return env |
| 39 | + |
| 40 | + |
| 41 | +recipe = GeventRecipe() |
0 commit comments