1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/buildtools/wafsamba/samba_python.py
Matthieu Patou 8733738357 build: introduce SAMBA_CHECK_PYTHON_HEADERS
This function is a wrapper around waf's check_python_header.
It avoids searching more than once for the headers bringing a small
speed improvement and a better lisibility of the logs.

But it's mainly to avoid a nasty bug when python libraries are in path
pointed by python_LIBPL (ie. /usr/local/lib/python2.6/config/) instead
of python_LIBDIR (ie. /usr/local/lib).

On the first call waf will correctly find that in order to link with
python libs it needs to add -L$python_LIBPL.

But on the next calls of check_python_headers, waf will use both the
current library path value (ie. -L/usr/local/lib/python2.6/config) and
-L$python_LIBDIR (ie. /usr/local/lib/) which will make him beleive that
python libraries are in $python_LIBDIR which at the end will make the
final link test fails in check_python_headers as it will not use the
good directory.

So by avoiding calling check_python_headers more than once we avoid
making waf fooling itself.
2010-12-10 02:07:18 +03:00

70 lines
2.3 KiB
Python

# waf build tool for building IDL files with pidl
import Build
from samba_utils import *
from samba_autoconf import *
from Configure import conf
@conf
def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True):
if conf.env["python_headers_checked"] == []:
conf.check_python_headers(mandatory)
conf.env["python_headers_checked"] = "yes"
else:
conf.msg("python headers", "using cache")
def SAMBA_PYTHON(bld, name,
source='',
deps='',
public_deps='',
realname=None,
cflags='',
includes='',
init_function_sentinal=None,
local_include=True,
vars=None,
enabled=True):
'''build a python extension for Samba'''
# when we support static python modules we'll need to gather
# the list from all the SAMBA_PYTHON() targets
if init_function_sentinal is not None:
cflags += '-DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinal
source = bld.EXPAND_VARIABLES(source, vars=vars)
if realname is None:
# a SAMBA_PYTHON target without a realname is just a
# library with pyembed=True
bld.SAMBA_LIBRARY(name,
source=source,
deps=deps,
public_deps=public_deps,
includes=includes,
cflags=cflags,
local_include=local_include,
vars=vars,
pyembed=True,
enabled=enabled)
return
link_name = 'python/%s' % realname
bld.SAMBA_LIBRARY(name,
source=source,
deps=deps,
public_deps=public_deps,
includes=includes,
cflags=cflags,
realname=realname,
local_include=local_include,
vars=vars,
link_name=link_name,
pyembed=True,
target_type='PYTHON',
install_path='${PYTHONDIR}',
enabled=enabled)
Build.BuildContext.SAMBA_PYTHON = SAMBA_PYTHON