1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#line 206 "interscript/src/compilers.ipk"
import os
import sys
import string
import interscript.compilers.cconfig
class python_module:
def __init__(self,**kwds):
self.config = compilers.cconfig.config()
self.config.append_dict(kwds)
def configure(self,**kwds):
self.config.append_dict(kwds)
def compile(self,filename, **kwds):
config = self.config.copy()
config.append_dict(kwds)
base = string.join(string.split(filename,'.')[:-1],'.')
obj = base+'.o'
cc ='g++ -g -O2 -fhandle-exceptions -fpic -fPIC -pedantic '
inc = '-I' + sys.prefix + '/include/python1.5 '
if sys.prefix != sys.exec_prefix:
inc = inc + '-I' + sys.exec_prefix + '/include/python1.5 '
cstr = str(config)+' '
arg = cc + cstr + inc + '-c '+filename + ' -o '+ obj
print 'system',repr(arg)
result = os.system(arg)
if result != 0:
raise 'Compiler Error'
return obj
def link(self,modname, filenames, **kwds):
config = self.config.copy()
config.append_dict(kwds)
cc ='g++ -shared -Xlinker -export-dynamic '
cstr = str(config) + ' '
lib = '-L' + sys.exec_prefix + '/lib/python1.5 '
dll = modname +'.so'
files = string.join(filenames) + ' '
arg = cc + cstr + lib + files + '-o '+dll
print 'system',repr(arg)
result = os.system(arg)
if result != 0:
raise 'Linker Error'
return dll
class application:
def __init__(self,**kwds):
self.config = interscript.compilers.cconfig.config()
self.config.append_dict(kwds)
def configure(self,**kwds):
self.config.append_dict(kwds)
def compile(self,filename, **kwds):
config = self.config.copy()
config.append_dict(kwds)
base = string.join(string.split(filename,'.')[:-1],'.')
obj = base+'.o'
cc ='g++ -g -O2 -fhandle-exceptions -fpic -fPIC -pedantic '
inc = '-I' + sys.prefix + '/include/python1.5 '
if sys.prefix != sys.exec_prefix:
inc = inc + '-I' + sys.exec_prefix + '/include/python1.5 '
cstr = str(config)+' '
arg = cc + cstr + inc + '-c '+filename + ' -o '+ obj
print 'system',repr(arg)
result = os.system(arg)
if result != 0:
raise 'Compiler Error'
return obj
def link(self,appname, filenames, **kwds):
config = self.config.copy()
config.append_dict(kwds)
cc ='g++ '
cstr = str(config) + ' '
lib = '-L' + sys.exec_prefix + '/lib/python1.5 '
files = string.join(filenames) + ' '
arg = cc + cstr + lib + files + '-o '+appname
print 'system',repr(arg)
result = os.system(arg)
if result != 0:
raise 'Linker Error'
return appname
|