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
This commit is contained in:
Nathan Binkert 2005-03-08 23:06:54 -05:00
parent 689f6d1b02
commit d191b14ff7

View file

@ -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)