Added CFLAGS option and exception on dlsym crash.

parent a8765c61
...@@ -47,6 +47,12 @@ PyObject *bisondynlib_run(void *handle, PyObject *parser, void *cb, void *in, in ...@@ -47,6 +47,12 @@ PyObject *bisondynlib_run(void *handle, PyObject *parser, void *cb, void *in, in
//printf("bisondynlib_run: looking up parser\n"); //printf("bisondynlib_run: looking up parser\n");
pparser = bisondynlib_lookup_parser(handle); pparser = bisondynlib_lookup_parser(handle);
//printf("bisondynlib_run: calling parser, py_input=0x%lx\n", in); //printf("bisondynlib_run: calling parser, py_input=0x%lx\n", in);
if (!pparser) {
PyErr_SetString(PyExc_RuntimeError,
"bisondynlib_lookup_parser() returned NULL");
return NULL;
}
(*pparser)(parser, cb, in, debug); (*pparser)(parser, cb, in, debug);
//printf("bisondynlib_run: back from parser\n"); //printf("bisondynlib_run: back from parser\n");
//return result; //return result;
......
...@@ -528,7 +528,9 @@ cdef class ParserEngine: ...@@ -528,7 +528,9 @@ cdef class ParserEngine:
# extra_preargs=['/DWIN32', '/G4', '/Gs', '/Oit', '/MT', '/nologo', '/W3', '/WX', '/Id:\python23\include']) # extra_preargs=['/DWIN32', '/G4', '/Gs', '/Oit', '/MT', '/nologo', '/W3', '/WX', '/Id:\python23\include'])
# link 'em into a shared lib # link 'em into a shared lib
objs = ccompiler.compile([parser.bisonCFile1, parser.flexCFile1]) objs = ccompiler.compile([parser.bisonCFile1, parser.flexCFile1],
extra_preargs=parser.cflags_pre,
extra_postargs=parser.cflags_post)
libFileName = parser.bisonEngineLibName+imp.get_suffixes()[0][0] libFileName = parser.bisonEngineLibName+imp.get_suffixes()[0][0]
if os.path.isfile(libFileName+".bak"): if os.path.isfile(libFileName+".bak"):
try: try:
...@@ -551,7 +553,10 @@ cdef class ParserEngine: ...@@ -551,7 +553,10 @@ cdef class ParserEngine:
'bisonCFile1', 'bisonHFile1', 'flexFile', 'bisonCFile1', 'bisonHFile1', 'flexFile',
'flexCFile', 'flexCFile1', 'flexCFile', 'flexCFile1',
] + objs: ] + objs:
fname = getattr(parser, name, None) if hasattr(parser, name):
fname = getattr(parser, name)
else:
fname = None
#print "want to delete %s" % fname #print "want to delete %s" % fname
if fname and os.path.isfile(fname): if fname and os.path.isfile(fname):
hitlist.append(fname) hitlist.append(fname)
......
...@@ -241,6 +241,9 @@ class BisonParser(object): ...@@ -241,6 +241,9 @@ class BisonParser(object):
flexCFile = "lex.yy.c" flexCFile = "lex.yy.c"
flexCFile1 = "tmp.lex.c" # c output file from lex gets renamed to this flexCFile1 = "tmp.lex.c" # c output file from lex gets renamed to this
cflags_pre = ['-fPIC'] # = CFLAGS added before all arguments.
cflags_post = ['-O3','-g'] # = CFLAGS added after all arguments.
verbose = 0 verbose = 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment