lbry-android-sdk/p4a/pythonforandroid/recipes/gevent/__init__.py

35 lines
1.5 KiB
Python
Raw Normal View History

import re
from pythonforandroid.logger import info
from pythonforandroid.recipe import CythonRecipe
2017-08-13 03:24:00 +02:00
class GeventRecipe(CythonRecipe):
version = '1.4.0'
2017-08-13 03:24:00 +02:00
url = 'https://pypi.python.org/packages/source/g/gevent/gevent-{version}.tar.gz'
2022-12-02 21:15:34 +01:00
depends = ['librt', 'setuptools']
patches = ["cross_compiling.patch"]
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
"""
- Moves all -I<inc> -D<macro> from CFLAGS to CPPFLAGS environment.
- Moves all -l<lib> from LDFLAGS to LIBS environment.
2022-12-02 21:15:34 +01:00
- Copies all -l<lib> from LDLIBS to LIBS environment.
- Fixes linker name (use cross compiler) and flags (appends LIBS)
"""
2022-12-02 21:15:34 +01:00
env = super().get_recipe_env(arch, with_flags_in_cc)
# CFLAGS may only be used to specify C compiler flags, for macro definitions use CPPFLAGS
regex = re.compile(r'(?:\s|^)-[DI][\S]+')
env['CPPFLAGS'] = ''.join(re.findall(regex, env['CFLAGS'])).strip()
env['CFLAGS'] = re.sub(regex, '', env['CFLAGS'])
info('Moved "{}" from CFLAGS to CPPFLAGS.'.format(env['CPPFLAGS']))
# LDFLAGS may only be used to specify linker flags, for libraries use LIBS
regex = re.compile(r'(?:\s|^)-l[\w\.]+')
env['LIBS'] = ''.join(re.findall(regex, env['LDFLAGS'])).strip()
2022-12-02 21:15:34 +01:00
env['LIBS'] += ' {}'.format(''.join(re.findall(regex, env['LDLIBS'])).strip())
env['LDFLAGS'] = re.sub(regex, '', env['LDFLAGS'])
info('Moved "{}" from LDFLAGS to LIBS.'.format(env['LIBS']))
return env
2017-08-13 03:24:00 +02:00
recipe = GeventRecipe()