summaryrefslogtreecommitdiff
path: root/python/SConscript
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2005-03-14 07:46:26 -0500
committerSteve Reinhardt <stever@eecs.umich.edu>2005-03-14 07:46:26 -0500
commit1b841a871ecd717dd8705d12ff7311c6fc97fc63 (patch)
tree48db77cabaae797478b9ee84c03ebe64fbe34f94 /python/SConscript
parent82964b2705b892f5d36522f7b7c5472975a5d873 (diff)
downloadgem5-1b841a871ecd717dd8705d12ff7311c6fc97fc63.tar.xz
- Add capability to auto-generate Param structs from
.mpy SimObject descriptions. Structs are defined in simobj/param/ObjectName.hh. - Move compile-time python params (from CPPDEFINES) to separate dict from run-time params (from os.environ). The former are needed to generate proper param structs. This also helps prevent users from messing things up by setting the wrong environment vars (which could have overridden compile-time settings in the old system). - Other misc cleanup of m5 python package. SConscript: Include simobj/SConscript build/SConstruct: Fix type in comment python/SConscript: Move CPPDEFINES dict-generating code to m5scons.flatten_defines python/m5/__init__.py: - Generate a build_env SmartDict here to hold compile-time params (passed in via __main__.m5_build_env). - Move panic and env here from config.py. python/m5/config.py: Move panic, env to top level (m5/__init__.py) python/m5/objects/BaseCPU.mpy: Use build_env instead of env for compile-time params python/m5/smartdict.py: Add some comments. sim/sim_object.hh: Include auto-generated Param struct. Not used yet, just here as proof of concept. test/genini.py: Put -E arguments in build_env as well as os.environ --HG-- extra : convert_revision : cf6f4a2565b230c495b33b18612d6030988adac5
Diffstat (limited to 'python/SConscript')
-rw-r--r--python/SConscript36
1 files changed, 13 insertions, 23 deletions
diff --git a/python/SConscript b/python/SConscript
index 81bc52286..a50903964 100644
--- a/python/SConscript
+++ b/python/SConscript
@@ -26,7 +26,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import os, os.path, re
+import os, os.path, re, sys
+
+Import('env')
+
+# tell python where to find m5 python code
+sys.path.append(os.path.join(env['SRCDIR'], 'python'))
+
+import m5scons
def WriteEmbeddedPyFile(target, source, path, name, ext, filename):
if isinstance(source, str):
@@ -89,7 +96,6 @@ def splitpath(path):
path.insert(0, base)
return path, file
-Import('env')
def MakeEmbeddedPyFile(target, source, env):
target = file(str(target[0]), 'w')
@@ -145,27 +151,11 @@ def MakeEmbeddedPyFile(target, source, env):
WriteEmbeddedPyFile(target, pyfile, path, name, ext, filename)
def MakeDefinesPyFile(target, source, env):
- target = file(str(target[0]), 'w')
-
- print >>target, "import os"
- defines = env['CPPDEFINES']
- if isinstance(defines, list):
- for var in defines:
- if isinstance(var, tuple):
- key,val = var
- else:
- key,val = var,'True'
-
- if not isinstance(key, basestring):
- panic("invalid type for define: %s" % type(key))
-
- print >>target, "os.environ['%s'] = '%s'" % (key, val)
-
- elif isinstance(defines, dict):
- for key,val in defines.iteritems():
- print >>target, "os.environ['%s'] = '%s'" % (key, val)
- else:
- panic("invalid type for defines: %s" % type(defines))
+ f = file(str(target[0]), 'w')
+ print >>f, "import __main__"
+ print >>f, "__main__.m5_build_env = ",
+ print >>f, m5scons.flatten_defines(env['CPPDEFINES'])
+ f.close()
CFileCounter = 0
def MakePythonCFile(target, source, env):