def do_work(): cmd = compiler.format(libname=lib_file, csource=source_file) try: result = check_output(cmd.split(), stderr=STDOUT) except CalledProcessError as e: raise Exception('Module did not compile!\n\n' 'Command:\n' + ' '.join(e.cmd) + '\n\n' 'Error:\n' + e.output + '\n') #csim, ffi = gen_cppsim ( lib_file, cdef ) #sim = CSimWrapper( csim, ffi ) create_cpp_py_wrapper(model_inst, cdef, lib_file, wrapper_file)
def do_work(): cmd = compiler.format( libname = lib_file, csource = source_file ) try: result = check_output( cmd.split() , stderr=STDOUT ) except CalledProcessError as e: raise Exception( 'Module did not compile!\n\n' 'Command:\n' + ' '.join(e.cmd) + '\n\n' 'Error:\n' + e.output + '\n' ) #csim, ffi = gen_cppsim ( lib_file, cdef ) #sim = CSimWrapper( csim, ffi ) create_cpp_py_wrapper( model_inst, cdef, lib_file, wrapper_file )
def translate( model ): model.elaborate() with tempfile.NamedTemporaryFile(suffix='.cpp') as output: cdef, CSimWrapper = CLogicTransl( model, output ) output.flush() # NOTE: if we don't create a unique name for each .so, things get # inconsisten (stale data?) clib = os.getcwd() + '/' + model.class_name+'.so' cmd = compiler.format( libname = clib, csource = output.name ) try: result = check_output( cmd.split() , stderr=STDOUT ) output.seek(0) source = output.read() csim, ffi = gen_cppsim ( clib, cdef ) sim = CSimWrapper( csim, ffi ) #print() #print( source ) #print() return sim except CalledProcessError as e: output.seek(0) source = output.read() raise Exception( 'Module did not compile!\n\n' 'Command:\n' + ' '.join(e.cmd) + '\n\n' 'Error:\n' + e.output + '\n' 'Source:\n \x1b[31m' + source + '\x1b[0m' )