Last change
on this file since 196 was 196, checked in by tim, 15 years ago |
experimental python bindings generator as provided by Michael Cohen
|
File size:
1.2 KB
|
Rev | Line | |
---|
[196] | 1 | import os, os.path, pdb
|
---|
| 2 | from functools import partial
|
---|
| 3 | import utils
|
---|
| 4 | import config
|
---|
| 5 | import class_parser
|
---|
| 6 |
|
---|
| 7 | def 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 |
|
---|
| 22 | nenv = utils.ExtendedEnvironment()
|
---|
| 23 |
|
---|
| 24 | BOUND_FILES = Split("""
|
---|
| 25 | ../include/regfi.h
|
---|
| 26 | regfi/pyregfi.h
|
---|
| 27 | """)
|
---|
| 28 |
|
---|
| 29 | nenv.config = config
|
---|
| 30 | nenv.Append(CFLAGS = "-I../include/ -Iinclude")
|
---|
| 31 | nenv.Append(LIBPATH="../lib")
|
---|
| 32 | nenv.Append(LINKFLAGS="")
|
---|
| 33 | nenv.Command('regfi/pyregfi.c', BOUND_FILES, partial(build_python_bindings,
|
---|
| 34 | initialization='pyregfi_init();'))
|
---|
| 35 | nenv.Depends('regfi/pyregfi.c', 'class_parser.py')
|
---|
| 36 |
|
---|
| 37 | nenv.PythonModule("pyregfi", ['regfi/pyregfi.c', 'regfi/regfi.c', 'regfi/class.c', 'regfi/error.c'],
|
---|
| 38 | LIBS=['regfi', 'talloc'])
|
---|
Note:
See
TracBrowser
for help on using the repository browser.