scons: Also build param struct .cc files using a helper script.
There was a comment in the SConscript talking about building a single .cc file for all the param structs, but that's not what the code was actually doing. This change drops that misleading comment. Change-Id: I3a5e4424e1021d6dfbdeafcef7709dae988747a4 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49425 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -147,6 +147,7 @@ class SimObject(PySource):
|
||||
|
||||
sim_objects = dict()
|
||||
enums = dict()
|
||||
tags = dict()
|
||||
|
||||
def __init__(self, source, *, sim_objects=[], enums=[],
|
||||
tags=None, add_tags=None):
|
||||
@@ -158,6 +159,7 @@ class SimObject(PySource):
|
||||
|
||||
SimObject.sim_objects[self.modpath] = sim_objects
|
||||
SimObject.enums[self.modpath] = enums
|
||||
SimObject.tags[self.modpath] = self.tags
|
||||
|
||||
# This regular expression is simplistic and assumes that the import takes up
|
||||
# the entire line, doesn't have the keyword "public", uses double quotes, has
|
||||
@@ -665,16 +667,33 @@ gem5py_env.Program(gem5py_m5, [ 'python/gem5py.cc' ] + m5_module_static)
|
||||
# Generate all of the SimObject param C++ struct header files
|
||||
|
||||
for module, simobjs in sorted(SimObject.sim_objects.items()):
|
||||
tags = SimObject.tags[module]
|
||||
for simobj in simobjs:
|
||||
gem5py_env.Command(f'params/{simobj}.hh',
|
||||
gem5py_env.Command([ "${PARAMS_HH}" ],
|
||||
[ Value(module), Value(simobj),
|
||||
"${GEM5PY_M5}", "${PARAMSTRUCT_PY}" ],
|
||||
MakeAction('"${GEM5PY_M5}" "${PARAMSTRUCT_PY}" "${MODULE}" ' \
|
||||
'"${TARGET}"',
|
||||
'"${PARAMS_HH}"',
|
||||
Transform("SO Param", 2)),
|
||||
MODULE=module,
|
||||
SIMOBJ=simobj,
|
||||
PARAMSTRUCT_PY=build_tools.File(
|
||||
'sim_object_param_struct_hh.py'),
|
||||
MODULE=module)
|
||||
PARAMS_HH=File(f'params/{simobj}.hh'))
|
||||
cc_file = File(f'python/_m5/param_{simobj}.cc')
|
||||
gem5py_env.Command([ "${PARAMS_CC}" ],
|
||||
[ Value(module), Value(simobj),
|
||||
"${GEM5PY_M5}", "${PARAMSTRUCT_PY}" ],
|
||||
MakeAction('"${GEM5PY_M5}" "${PARAMSTRUCT_PY}" "${MODULE}" ' \
|
||||
'"${PARAMS_CC}" "${USE_PYTHON}"',
|
||||
Transform("SO Param", 2)),
|
||||
PARAMSTRUCT_PY=build_tools.File(
|
||||
'sim_object_param_struct_cc.py'),
|
||||
MODULE=module,
|
||||
SIMOBJ=simobj,
|
||||
PARAMS_CC=cc_file,
|
||||
USE_PYTHON=env['USE_PYTHON'])
|
||||
Source(cc_file, tags=tags, add_tags='python')
|
||||
|
||||
# C++ parameter description files
|
||||
if GetOption('with_cxx_config'):
|
||||
@@ -778,28 +797,6 @@ for name,enum in sorted(all_enums.items()):
|
||||
MakeAction(createEnumDecls, Transform("ENUMDECL")))
|
||||
env.Depends(hh_file, depends + extra_deps)
|
||||
|
||||
# Generate SimObject Python bindings and create method wrapper files
|
||||
def createSimObjectWrappers(target, source, env):
|
||||
name = source[0].get_text_contents()
|
||||
obj = sim_objects[name]
|
||||
|
||||
code = code_formatter()
|
||||
# We want to generate a single .cc file which contains most of the
|
||||
# SimObject autogenerated code to reduce the number of files to compile and
|
||||
# link. We need to pass in whether python is enabled so that the pybind
|
||||
# wrappers are only generated when python is enabled
|
||||
obj.params_create_decl(code, env['USE_PYTHON'])
|
||||
code.write(target[0].abspath)
|
||||
|
||||
for name,simobj in sorted(sim_objects.items()):
|
||||
py_source = PySource.modules[simobj.__module__]
|
||||
extra_deps = [ py_source.tnode ]
|
||||
cc_file = File('python/_m5/param_%s.cc' % name)
|
||||
env.Command(cc_file, Value(name),
|
||||
MakeAction(createSimObjectWrappers,
|
||||
Transform("SO PyB/C")))
|
||||
env.Depends(cc_file, depends + extra_deps)
|
||||
Source(cc_file, add_tags='python')
|
||||
|
||||
# version tags
|
||||
tags = \
|
||||
|
||||
Reference in New Issue
Block a user