From 689f6d1b02f788ecd2a44ff4ca010acc38d14954 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 8 Mar 2005 22:07:26 -0500 Subject: Split the string importer from the rest of the mpy parsing and importing stuff to avoid some confusion. sim/pyconfig/SConscript: Split the string importer from the rest of the importer code. The importer.py code can be embedded like m5config.py sim/pyconfig/m5config.py: import what we need from importer --HG-- extra : convert_revision : 9d57f43381b55e717b5b10adfb8f0a522280ac57 --- sim/pyconfig/SConscript | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sim/pyconfig/SConscript') diff --git a/sim/pyconfig/SConscript b/sim/pyconfig/SConscript index 9154d3b99..c8671b50f 100644 --- a/sim/pyconfig/SConscript +++ b/sim/pyconfig/SConscript @@ -170,7 +170,7 @@ EmbedMap %(name)s("%(fname)s", /* namespace */ } ''' -embedded_py_files = ['m5config.py', '../../util/pbs/jobfile.py'] +embedded_py_files = ['m5config.py', 'importer.py', '../../util/pbs/jobfile.py'] objpath = os.path.join(env['SRCDIR'], 'objects') for root, dirs, files in os.walk(objpath, topdown=True): for i,dir in enumerate(dirs): @@ -184,7 +184,7 @@ 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.Depends('embedded_py.cc', embedfile_hh) env.Command('embedded_py.py', embedded_py_files, MakeEmbeddedPyFile) -env.Command('embedded_py.cc', ['importer.py', 'embedded_py.py'], +env.Depends('embedded_py.cc', embedfile_hh) +env.Command('embedded_py.cc', ['string_importer.py', 'embedded_py.py'], MakePythonCFile) -- cgit v1.2.3 From d191b14ff71f8b7af2098a29c2914d7332acd9be Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 8 Mar 2005 23:06:54 -0500 Subject: Pass all scons defined pre-processor macro variables to the python configuration stuff as environment variables. sim/pyconfig/SConscript: generate a python file that updates the env dict with all variables in the CPPDEFINES so the python code can use those variables in configuration scripts. --HG-- extra : convert_revision : 50b0719b044f7adc87ce6ae1571d156ca0c5644c --- sim/pyconfig/SConscript | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'sim/pyconfig/SConscript') diff --git a/sim/pyconfig/SConscript b/sim/pyconfig/SConscript index c8671b50f..95785d372 100644 --- a/sim/pyconfig/SConscript +++ b/sim/pyconfig/SConscript @@ -144,6 +144,28 @@ def MakeEmbeddedPyFile(target, source, env): for pyfile, path, name, ext, filename in files: WriteEmbeddedPyFile(target, pyfile, path, name, ext, filename) +def MakeDefinesPyFile(target, source, env): + target = file(str(target[0]), 'w') + + 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, "env['%s'] = '%s'" % (key, val) + + elif isinstance(defines, dict): + for key,val in defines.iteritems(): + print >>target, "env['%s'] = '%s'" % (key, val) + else: + panic("invalid type for defines: %s" % type(defines)) + CFileCounter = 0 def MakePythonCFile(target, source, env): global CFileCounter @@ -184,7 +206,9 @@ 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) env.Command('embedded_py.py', embedded_py_files, MakeEmbeddedPyFile) env.Depends('embedded_py.cc', embedfile_hh) -env.Command('embedded_py.cc', ['string_importer.py', 'embedded_py.py'], +env.Command('embedded_py.cc', + ['string_importer.py', 'defines.py', 'embedded_py.py'], MakePythonCFile) -- cgit v1.2.3 From 4a3ad218e1a41a9fa655471b999e2540e4e78448 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 9 Mar 2005 14:39:35 -0500 Subject: We should import m5config *after* we do the CPPDEFINES stuff, otherwise m5config and the object descriptions cannot take advantage of them. sim/pyconfig/SConscript: We should import m5config *after* we do the CPPDEFINES stuff, otherwise m5config and the object descriptions cannot take advantage of them. This means that we can't use the env dict alias. We should instead use os.environ. --HG-- extra : convert_revision : 392f99a3c15cfba74a5cde79a709ecfad3820e63 --- sim/pyconfig/SConscript | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sim/pyconfig/SConscript') diff --git a/sim/pyconfig/SConscript b/sim/pyconfig/SConscript index 95785d372..2799ef64f 100644 --- a/sim/pyconfig/SConscript +++ b/sim/pyconfig/SConscript @@ -147,6 +147,7 @@ def MakeEmbeddedPyFile(target, source, env): 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: @@ -158,11 +159,11 @@ def MakeDefinesPyFile(target, source, env): if not isinstance(key, basestring): panic("invalid type for define: %s" % type(key)) - print >>target, "env['%s'] = '%s'" % (key, val) + print >>target, "os.environ['%s'] = '%s'" % (key, val) elif isinstance(defines, dict): for key,val in defines.iteritems(): - print >>target, "env['%s'] = '%s'" % (key, val) + print >>target, "os.environ['%s'] = '%s'" % (key, val) else: panic("invalid type for defines: %s" % type(defines)) -- cgit v1.2.3