source: trunk/python2/SConstruct @ 199

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

reworked part of regfi C API to make python wrappers simpler
continued work on python wrappers
fixed some issues in pyregfi-smoketest. WIP

File size: 1.4 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 = "-ggdb -O0 -pedantic -Wall -std=gnu99")
32    nenv.Append(CPPPATH=['../include', 'include'])
33    nenv.python_cppflags = '-I/usr/include/python2.5_d'
34else:
35    nenv.Append(CFLAGS = "-ggdb -pedantic -Wall")
36    nenv.Append(CPPPATH=['../include', 'include'])
37   
38nenv.Append(LIBPATH="../lib")
39nenv.Append(LINKFLAGS="")
40nenv.Command('regfi/pyregfi.c', BOUND_FILES, partial(build_python_bindings,
41                                                     initialization='pyregfi_init();'))
42nenv.Depends('regfi/pyregfi.c', 'class_parser.py')
43
44nenv.PythonModule("pyregfi", ['regfi/pyregfi.c', 'regfi/regfi.c', 'regfi/class.c', 'regfi/error.c'],
45                  LIBS=['regfi', 'talloc'])
Note: See TracBrowser for help on using the repository browser.