SConscript (7065:cf0422cb8555) SConscript (7502:3ef7ff12c788)
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 915 unchanged lines hidden (view full) ---

924# structs that describe the embedded python code. One such struct
925# contains information about the importer that python uses to get at
926# the embedded files, and then there's a list of all of the rest that
927# the importer uses to load the rest on demand.
928def pythonInit(target, source, env):
929 dst = file(str(target[0]), 'w')
930
931 def dump_mod(sym, endchar=','):
1# -*- mode:python -*-
2
3# Copyright (c) 2004-2005 The Regents of The University of Michigan
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met: redistributions of source code must retain the above copyright

--- 915 unchanged lines hidden (view full) ---

924# structs that describe the embedded python code. One such struct
925# contains information about the importer that python uses to get at
926# the embedded files, and then there's a list of all of the rest that
927# the importer uses to load the rest on demand.
928def pythonInit(target, source, env):
929 dst = file(str(target[0]), 'w')
930
931 def dump_mod(sym, endchar=','):
932 def c_str(string):
933 if string is None:
934 return "0"
935 return '"%s"' % string
932 pysource = PySource.symnames[sym]
936 pysource = PySource.symnames[sym]
933 print >>dst, ' { "%s",' % pysource.arcname
934 print >>dst, ' "%s",' % pysource.modpath
935 print >>dst, ' %s_beg, %s_end,' % (sym, sym)
936 print >>dst, ' %s_end - %s_beg,' % (sym, sym)
937 print >>dst, ' *(int *)%s_end }%s' % (sym, endchar)
937 print >>dst, ' { %s,' % c_str(pysource.arcname)
938 print >>dst, ' %s,' % c_str(pysource.abspath)
939 print >>dst, ' %s,' % c_str(pysource.modpath)
940 print >>dst, ' %s_beg, %s_end,' % (sym, sym)
941 print >>dst, ' %s_end - %s_beg,' % (sym, sym)
942 print >>dst, ' *(int *)%s_end }%s' % (sym, endchar)
938
939 print >>dst, '#include "sim/init.hh"'
940
941 for sym in source:
942 sym = sym.get_contents()
943 print >>dst, "extern const char %s_beg[], %s_end[];" % (sym, sym)
944
945 print >>dst, "const EmbeddedPyModule embeddedPyImporter = "
946 dump_mod("PyEMB_importer", endchar=';');
947 print >>dst
948
949 print >>dst, "const EmbeddedPyModule embeddedPyModules[] = {"
950 for i,sym in enumerate(source):
951 sym = sym.get_contents()
952 if sym == "PyEMB_importer":
953 # Skip the importer since we've already exported it
954 continue
955 dump_mod(sym)
943
944 print >>dst, '#include "sim/init.hh"'
945
946 for sym in source:
947 sym = sym.get_contents()
948 print >>dst, "extern const char %s_beg[], %s_end[];" % (sym, sym)
949
950 print >>dst, "const EmbeddedPyModule embeddedPyImporter = "
951 dump_mod("PyEMB_importer", endchar=';');
952 print >>dst
953
954 print >>dst, "const EmbeddedPyModule embeddedPyModules[] = {"
955 for i,sym in enumerate(source):
956 sym = sym.get_contents()
957 if sym == "PyEMB_importer":
958 # Skip the importer since we've already exported it
959 continue
960 dump_mod(sym)
956 print >>dst, " { 0, 0, 0, 0, 0, 0 }"
961 print >>dst, " { 0, 0, 0, 0, 0, 0, 0 }"
957 print >>dst, "};"
958
959
960env.Command('sim/init_python.cc',
961 map(Value, (s.symname for s in PySource.all)),
962 pythonInit)
963Source('sim/init_python.cc')
964

--- 138 unchanged lines hidden ---
962 print >>dst, "};"
963
964
965env.Command('sim/init_python.cc',
966 map(Value, (s.symname for s in PySource.all)),
967 pythonInit)
968Source('sim/init_python.cc')
969

--- 138 unchanged lines hidden ---