Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/49402 )

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

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
---
M src/SConscript
1 file changed, 49 insertions(+), 48 deletions(-)



diff --git a/src/SConscript b/src/SConscript
index 540db3d..c10b3c4 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -642,6 +642,8 @@
 # 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

@@ -652,54 +654,6 @@
     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.
@@ -721,6 +675,18 @@

 # 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 ]
@@ -780,6 +746,29 @@
     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 ]
@@ -796,6 +785,18 @@
     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 ]

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49402
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ideee7bd44dac89c51840ec5970d95f6ccbbd1c8f
Gerrit-Change-Number: 49402
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to