mirror of
https://github.com/samba-team/samba.git
synced 2025-01-22 22:04:08 +03:00
buildtools: Add a helper to iterate through Python environments
This prevents code duplication to ensure the "extrapython" build is the same as the normal one. Signed-off-by: Petr Viktorin <pviktori@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
This commit is contained in:
parent
fb5d9c3db1
commit
6f490000c6
@ -74,6 +74,9 @@ def SAMBA_PYTHON(bld, name,
|
||||
enabled=True):
|
||||
'''build a python extension for Samba'''
|
||||
|
||||
if bld.env['IS_EXTRA_PYTHON']:
|
||||
name = 'extra-' + name
|
||||
|
||||
# when we support static python modules we'll need to gather
|
||||
# the list from all the SAMBA_PYTHON() targets
|
||||
if init_function_sentinel is not None:
|
||||
@ -111,3 +114,25 @@ def pyembed_libname(bld, name, extrapython=False):
|
||||
return name + bld.env['PYTHON_SO_ABI_FLAG']
|
||||
|
||||
Build.BuildContext.pyembed_libname = pyembed_libname
|
||||
|
||||
|
||||
def gen_python_environments(bld, extra_env_vars=()):
|
||||
"""Generate all Python environments
|
||||
|
||||
To be used in a for loop. Normally, the loop body will be executed once.
|
||||
|
||||
When --extra-python is used, the body will additionaly be executed
|
||||
with the extra-python environment active.
|
||||
"""
|
||||
yield
|
||||
|
||||
if bld.env['EXTRA_PYTHON']:
|
||||
copied = ('GLOBAL_DEPENDENCIES', 'TARGET_TYPE') + tuple(extra_env_vars)
|
||||
for name in copied:
|
||||
bld.all_envs['extrapython'][name] = bld.all_envs['default'][name]
|
||||
default_env = bld.all_envs['default']
|
||||
bld.all_envs['default'] = bld.all_envs['extrapython']
|
||||
yield
|
||||
bld.all_envs['default'] = default_env
|
||||
|
||||
Build.BuildContext.gen_python_environments = gen_python_environments
|
||||
|
@ -143,6 +143,9 @@ def SAMBA_LIBRARY(bld, libname, source,
|
||||
enabled=True):
|
||||
'''define a Samba library'''
|
||||
|
||||
if pyembed and bld.env['IS_EXTRA_PYTHON']:
|
||||
public_headers = pc_files = None
|
||||
|
||||
if LIB_MUST_BE_PRIVATE(bld, libname):
|
||||
private_library=True
|
||||
|
||||
|
@ -116,68 +116,33 @@ def build(bld):
|
||||
manpages='man/talloc.3')
|
||||
|
||||
if not bld.CONFIG_SET('USING_SYSTEM_PYTALLOC_UTIL') and not bld.env.disable_python:
|
||||
name = bld.pyembed_libname('pytalloc-util')
|
||||
for env in bld.gen_python_environments(['PKGCONFIGDIR']):
|
||||
name = bld.pyembed_libname('pytalloc-util')
|
||||
|
||||
bld.SAMBA_LIBRARY(name,
|
||||
source='pytalloc_util.c',
|
||||
public_deps='talloc',
|
||||
pyembed=True,
|
||||
vnum=VERSION,
|
||||
hide_symbols=True,
|
||||
abi_directory='ABI',
|
||||
abi_match='pytalloc_*',
|
||||
private_library=private_library,
|
||||
public_headers='pytalloc.h',
|
||||
pc_files='pytalloc-util.pc'
|
||||
)
|
||||
bld.SAMBA_PYTHON('pytalloc',
|
||||
'pytalloc.c',
|
||||
deps='talloc ' + name,
|
||||
enabled=True,
|
||||
realname='talloc.so')
|
||||
bld.SAMBA_LIBRARY(name,
|
||||
source='pytalloc_util.c',
|
||||
public_deps='talloc',
|
||||
pyembed=True,
|
||||
vnum=VERSION,
|
||||
hide_symbols=True,
|
||||
abi_directory='ABI',
|
||||
abi_match='pytalloc_*',
|
||||
private_library=private_library,
|
||||
public_headers='pytalloc.h',
|
||||
pc_files='pytalloc-util.pc'
|
||||
)
|
||||
bld.SAMBA_PYTHON('pytalloc',
|
||||
'pytalloc.c',
|
||||
deps='talloc ' + name,
|
||||
enabled=True,
|
||||
realname='talloc.so')
|
||||
|
||||
bld.SAMBA_PYTHON('test_pytalloc',
|
||||
'test_pytalloc.c',
|
||||
deps='pytalloc',
|
||||
enabled=True,
|
||||
realname='_test_pytalloc.so',
|
||||
install=False)
|
||||
|
||||
if bld.env['EXTRA_PYTHON']:
|
||||
for var_name in ('GLOBAL_DEPENDENCIES', 'TARGET_TYPE', 'PKGCONFIGDIR'):
|
||||
bld.all_envs['extrapython'][var_name] = bld.all_envs['default'][var_name]
|
||||
bak = bld.all_envs['default']
|
||||
bld.all_envs['default'] = bld.all_envs['extrapython']
|
||||
|
||||
name = bld.pyembed_libname('pytalloc-util')
|
||||
|
||||
bld.SAMBA_LIBRARY(name,
|
||||
source='pytalloc_util.c',
|
||||
public_deps='talloc',
|
||||
pyembed=True,
|
||||
vnum=VERSION,
|
||||
hide_symbols=True,
|
||||
abi_directory='ABI',
|
||||
abi_match='pytalloc_*',
|
||||
private_library=private_library,
|
||||
#public_headers='pytalloc.h',
|
||||
#pc_files='pytalloc-util.pc'
|
||||
)
|
||||
|
||||
bld.SAMBA_PYTHON('extra-pytalloc',
|
||||
'pytalloc.c',
|
||||
deps='talloc ' + name,
|
||||
enabled=True,
|
||||
realname='talloc.so')
|
||||
|
||||
bld.SAMBA_PYTHON('extra-test_pytalloc',
|
||||
'test_pytalloc.c',
|
||||
deps='pytalloc',
|
||||
enabled=True,
|
||||
realname='_test_pytalloc.so',
|
||||
install=False)
|
||||
|
||||
bld.all_envs['default'] = bak
|
||||
bld.SAMBA_PYTHON('test_pytalloc',
|
||||
'test_pytalloc.c',
|
||||
deps='pytalloc',
|
||||
enabled=True,
|
||||
realname='_test_pytalloc.so',
|
||||
install=False)
|
||||
|
||||
|
||||
def test(ctx):
|
||||
|
Loading…
x
Reference in New Issue
Block a user