diff options
Diffstat (limited to 'src/python/SConscript')
-rw-r--r-- | src/python/SConscript | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/src/python/SConscript b/src/python/SConscript index df1464809..6662c8a45 100644 --- a/src/python/SConscript +++ b/src/python/SConscript @@ -29,14 +29,14 @@ # Authors: Steve Reinhardt # Nathan Binkert -import os, os.path, re, sys -from zipfile import PyZipFile +import os +import zipfile # handy function for path joins def join(*args): return os.path.normpath(os.path.join(*args)) -Import('env') +Import('*') # This SConscript is in charge of collecting .py files and generating # a zip archive that is appended to the m5 binary. @@ -97,22 +97,59 @@ addPkg('m5') pyzip_files.append('m5/defines.py') pyzip_files.append('m5/info.py') pyzip_files.append(join(env['ROOT'], 'util/pbs/jobfile.py')) +pyzip_files.append(join(env['ROOT'], 'src/base/traceflags.py')) -def swig_it(basename): - env.Command(['swig/%s_wrap.cc' % basename, 'm5/internal/%s.py' % basename], - 'swig/%s.i' % basename, +swig_modules = [] +def swig_it(module): + env.Command(['swig/%s_wrap.cc' % module, 'm5/internal/%s.py' % module], + 'swig/%s.i' % module, '$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} ' '-o ${TARGETS[0]} $SOURCES') - pyzip_dep_files.append('m5/internal/%s.py' % basename) + swig_modules.append(module) + Source('swig/%s_wrap.cc' % module) -swig_it('main') +Source('swig/init.cc') +Source('swig/pyevent.cc') +Source('swig/pyobject.cc') + +swig_it('core') swig_it('debug') swig_it('event') +swig_it('random') +swig_it('sim_object') +swig_it('stats') +swig_it('trace') + +# Automatically generate m5/internals/__init__.py +def MakeInternalsInit(target, source, env): + f = file(str(target[0]), 'w') + for m in swig_modules: + print >>f, 'import %s' % m + f.close() + +swig_py_files = [ 'm5/internal/%s.py' % m for m in swig_modules ] +env.Command('m5/internal/__init__.py', swig_py_files, MakeInternalsInit) +pyzip_dep_files.append('m5/internal/__init__.py') + +def MakeSwigInit(target, source, env): + f = file(str(target[0]), 'w') + print >>f, 'extern "C" {' + for m in swig_modules: + print >>f, ' void init_%s();' % m + print >>f, '}' + print >>f, 'void init_swig() {' + for m in swig_modules: + print >>f, ' init_%s();' % m + print >>f, '}' + f.close() + +swig_cc_files = [ 'swig/%s_wrap.cc' % m for m in swig_modules ] +env.Command('swig/init.cc', swig_cc_files, MakeSwigInit) # Action function to build the zip archive. Uses the PyZipFile module # included in the standard Python library. def buildPyZip(target, source, env): - pzf = PyZipFile(str(target[0]), 'w') + pzf = zipfile.PyZipFile(str(target[0]), 'w') for s in source: pzf.writepy(str(s)) |