scons: Rearrange functions to be next to the code that uses them.

The code which generated SimObject related param wrappers, cxx wrappers,
enum headers, etc was organized strangely. All the functions which
were used as SCons Actions were listed next to each other, and then all
the code which would set up each of those types of files and actually
use the Actions were next to each other.

This change rearranges that code so that the Action function is
immediately before the code which applies it. Or in other words, this
section of the SConscript is now grouped by the files being created,
rather than the type of the piece of machinery being defined to do that.

Change-Id: Ideee7bd44dac89c51840ec5970d95f6ccbbd1c8f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49402
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
This commit is contained in:
Gabe Black
2021-08-15 00:42:22 -07:00
parent 3f9b493982
commit 9844b9e8cb

View File

@@ -645,6 +645,8 @@ PySource('m5', 'python/m5/info.py')
# Create all of the SimObject param headers and enum headers
#
# Generate all of the SimObject param C++ struct header files
def createSimObjectParamStruct(target, source, env):
assert len(target) == 1 and len(source) == 1
@@ -655,54 +657,6 @@ def createSimObjectParamStruct(target, source, env):
obj.cxx_param_decl(code)
code.write(target[0].abspath)
def createSimObjectCxxConfig(is_header):
def body(target, source, env):
assert len(target) == 1 and len(source) == 1
name = source[0].get_contents().decode('utf-8')
obj = sim_objects[name]
code = code_formatter()
obj.cxx_config_param_file(code, is_header)
code.write(target[0].abspath)
return body
def createEnumStrings(target, source, env):
assert len(target) == 1 and len(source) == 2
name = source[0].get_text_contents()
use_python = source[1].read()
obj = all_enums[name]
code = code_formatter()
obj.cxx_def(code)
if use_python:
obj.pybind_def(code)
code.write(target[0].abspath)
def createEnumDecls(target, source, env):
assert len(target) == 1 and len(source) == 1
name = source[0].get_text_contents()
obj = all_enums[name]
code = code_formatter()
obj.cxx_decl(code)
code.write(target[0].abspath)
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)
# Generate all of the SimObject param C++ struct header files
params_hh_files = []
for name,simobj in sorted(sim_objects.items()):
# If this simobject's source changes, we need to regenerate the header.
@@ -724,6 +678,18 @@ for name,simobj in sorted(sim_objects.items()):
# C++ parameter description files
if GetOption('with_cxx_config'):
def createSimObjectCxxConfig(is_header):
def body(target, source, env):
assert len(target) == 1 and len(source) == 1
name = source[0].get_contents().decode('utf-8')
obj = sim_objects[name]
code = code_formatter()
obj.cxx_config_param_file(code, is_header)
code.write(target[0].abspath)
return body
for name,simobj in sorted(sim_objects.items()):
py_source = PySource.modules[simobj.__module__]
extra_deps = [ py_source.tnode ]
@@ -783,6 +749,29 @@ if GetOption('with_cxx_config'):
Source(cxx_config_init_cc_file)
# Generate all enum header files
def createEnumStrings(target, source, env):
assert len(target) == 1 and len(source) == 2
name = source[0].get_text_contents()
use_python = source[1].read()
obj = all_enums[name]
code = code_formatter()
obj.cxx_def(code)
if use_python:
obj.pybind_def(code)
code.write(target[0].abspath)
def createEnumDecls(target, source, env):
assert len(target) == 1 and len(source) == 1
name = source[0].get_text_contents()
obj = all_enums[name]
code = code_formatter()
obj.cxx_decl(code)
code.write(target[0].abspath)
for name,enum in sorted(all_enums.items()):
py_source = PySource.modules[enum.__module__]
extra_deps = [ py_source.tnode ]
@@ -799,6 +788,18 @@ for name,enum in sorted(all_enums.items()):
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 ]