7536250d0d6bf537cce916ee0cf879dd068e7c3d
[nivanova/samba-autobuild/.git] / buildtools / wafsamba / samba_python.py
1 # waf build tool for building IDL files with pidl
2
3 import Build
4 from samba_utils import *
5 from samba_autoconf import *
6
7
8 def SAMBA_PYTHON(bld, name,
9                  source='',
10                  deps='',
11                  public_deps='',
12                  realname=None,
13                  cflags='',
14                  includes='',
15                  init_function_sentinal=None,
16                  local_include=True,
17                  enabled=True):
18     '''build a python extension for Samba'''
19
20     # when we support static python modules we'll need to gather
21     # the list from all the SAMBA_PYTHON() targets
22     if init_function_sentinal is not None:
23         cflags += '-DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinal
24
25     if realname is None:
26         # a SAMBA_PYTHON target without a realname is just a
27         # subsystem with needs_python=True
28         return bld.SAMBA_SUBSYSTEM(name,
29                                    source=source,
30                                    deps=deps,
31                                    public_deps=public_deps,
32                                    cflags=cflags,
33                                    includes=includes,
34                                    init_function_sentinal=init_function_sentinal,
35                                    local_include=local_include,
36                                    needs_python=True,
37                                    enabled=enabled)
38
39     if not enabled:
40         SET_TARGET_TYPE(bld, name, 'DISABLED')
41         return
42
43     if not SET_TARGET_TYPE(bld, name, 'PYTHON'):
44         return
45
46     deps += ' ' + public_deps
47
48     if realname is None:
49         realname = '%s.so' % name
50     link_name = 'python/%s' % realname
51
52     t = bld(
53         features       = 'cc cshlib pyext symlink_lib',
54         source         = source,
55         target         = name,
56         samba_cflags   = CURRENT_CFLAGS(bld, name, cflags),
57         samba_includes = includes,
58         local_include  = local_include,
59         samba_deps     = TO_LIST(deps),
60         link_name      = link_name,
61         name           = name
62         )
63 Build.BuildContext.SAMBA_PYTHON = SAMBA_PYTHON