source: trunk/python/experimental/SConstruct @ 278

Last change on this file since 278 was 204, checked in by tim, 14 years ago

reorganizing wrappers

File size: 1.6 KB
Line 
1import os, os.path, pdb
2from functools import partial
3import utils
4import config
5import class_parser
6
7def build_python_bindings(target, source, env, initialization=''):
8    """ A command to generate python bindings """
9    module_name = os.path.splitext(os.path.basename(target[0].name))[0]
10    utils.warn("Generating automatic python bindings for module %s" % module_name)
11
12    p = class_parser.HeaderParser(module_name, verbose=config.V)
13    p.module.init_string = initialization
14    p.parse_filenames([s.get_abspath() for s in source])
15
16    fd = open(target[0].get_abspath(), 'w')
17    p.write(fd)
18    fd.close()
19
20
21
22nenv = utils.ExtendedEnvironment()
23
24BOUND_FILES = Split("""
25    ../include/regfi.h
26    regfi/pyregfi.h
27    """)
28
29nenv.config = config
30if config.DEBUG:
31    nenv.Append(CFLAGS = "-std=gnu99 -pedantic -Wall -fPIC -ggdb -O0")
32    nenv.Append(CPPPATH=['../include', 'include'])
33    nenv.python_cppflags = '-I/usr/include/python2.5_d'
34else:
35    nenv.Append(CFLAGS = "-std=gnu99 -pedantic -Wall -fPIC")
36    nenv.Append(CPPPATH=['../include', 'include'])
37   
38nenv.Append(LIBPATH="../lib")
39nenv.Append(LINKFLAGS="")
40# XXX: why should I need to call regfi_init() when it should be called only once automatically?
41nenv.Command('regfi/pyregfi.c', BOUND_FILES, partial(build_python_bindings,
42                                                     initialization='pyregfi_init();regfi_init();'))
43nenv.Depends('regfi/pyregfi.c', 'class_parser.py')
44
45nenv.PythonModule("pyregfi", ['regfi/pyregfi.c', 'regfi/regfi.c', 'regfi/class.c', 'regfi/error.c'],
46                  LIBS=['regfi', 'talloc'])
Note: See TracBrowser for help on using the repository browser.