diff options
Diffstat (limited to 'python')
-rw-r--r-- | python/SConscript | 7 | ||||
-rw-r--r-- | python/m5/convert.py | 15 |
2 files changed, 14 insertions, 8 deletions
diff --git a/python/SConscript b/python/SConscript index 57b018fea..a34d3f2d5 100644 --- a/python/SConscript +++ b/python/SConscript @@ -151,7 +151,7 @@ def MakeDefinesPyFile(target, source, env): f = file(str(target[0]), 'w') print >>f, "import __main__" print >>f, "__main__.m5_build_env = ", - print >>f, scons_helper.flatten_defines(env['CPPDEFINES']) + print >>f, source[0] f.close() CFileCounter = 0 @@ -196,7 +196,10 @@ for root, dirs, files in os.walk(objpath, topdown=True): embedded_py_files.append(os.path.join(root, f)) embedfile_hh = os.path.join(env['SRCDIR'], 'base/embedfile.hh') -env.Command('defines.py', None, MakeDefinesPyFile) + +optionDict = dict([(opt, env[opt]) for opt in env.ExportOptions]) +env.Command('defines.py', Value(optionDict), MakeDefinesPyFile) + env.Command('embedded_py.py', embedded_py_files, MakeEmbeddedPyFile) env.Depends('embedded_py.cc', embedfile_hh) env.Command('embedded_py.cc', diff --git a/python/m5/convert.py b/python/m5/convert.py index 2551459bd..9d9f4efa7 100644 --- a/python/m5/convert.py +++ b/python/m5/convert.py @@ -105,17 +105,20 @@ def toInteger(value): return result +_bool_dict = { + 'true' : True, 't' : True, 'yes' : True, 'y' : True, '1' : True, + 'false' : False, 'f' : False, 'no' : False, 'n' : False, '0' : False + } + def toBool(value): if not isinstance(value, str): raise TypeError, "wrong type '%s' should be str" % type(value) value = value.lower() - if value == "true" or value == "t" or value == "yes" or value == "y": - return True - elif value == "false" or value == "f" or value == "no" or value == "n": - return False - - raise ValueError, "cannot convert '%s' to bool" % value + result = _bool_dict.get(value, None) + if result == None: + raise ValueError, "cannot convert '%s' to bool" % value + return result def toFrequency(value): if not isinstance(value, str): |