Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pythonforandroid/recipes/gevent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ 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.
- Copies all -l<lib> from LDLIBS to LIBS environment.
- Fixes linker name (use cross compiler) and flags (appends LIBS)
"""
env = super(GeventRecipe, self).get_recipe_env(arch, with_flags_in_cc)
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()
Expand All @@ -24,6 +25,7 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
# 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()
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
Expand Down
6 changes: 5 additions & 1 deletion tests/recipes/test_gevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ def test_get_recipe_env(self):
# checks the regex doesn't parse `python3-libffi-openssl` as a `-libffi`
'-L/path/to/python3-libffi-openssl/library3 '
)
mocked_ldlibs = ' -lm'
mocked_env = {
'CFLAGS': mocked_cflags,
'LDFLAGS': mocked_ldflags,
'LDLIBS': mocked_ldlibs,
}
with patch('pythonforandroid.recipe.CythonRecipe.get_recipe_env') as m_get_recipe_env:
m_get_recipe_env.return_value = mocked_env
Expand All @@ -53,11 +55,13 @@ def test_get_recipe_env(self):
' -L/path/to/library2'
' -L/path/to/python3-libffi-openssl/library3 '
)
expected_libs = '-lm -lpython3.7m'
expected_ldlibs = mocked_ldlibs
expected_libs = '-lm -lpython3.7m -lm'
expected_env = {
'CFLAGS': expected_cflags,
'CPPFLAGS': expected_cppflags,
'LDFLAGS': expected_ldflags,
'LDLIBS': expected_ldlibs,
'LIBS': expected_libs,
}
self.assertEqual(expected_env, env)