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

Change subject: python,scons: Add a gem5py_m5 program which supports the m5 module.
......................................................................

python,scons: Add a gem5py_m5 program which supports the m5 module.

Like gem5py which uses the same main source file, this program will run
arbitrary python scripts. Unlike the other program, it will include
support for the m5 module. That will make it capable of generating
SimObject param, enum, etc c++ files.

Change-Id: I15fd7545f6b1ea6559cbe27cef30c778867ebe70
---
M src/SConscript
M src/python/SConscript
2 files changed, 15 insertions(+), 4 deletions(-)



diff --git a/src/SConscript b/src/SConscript
index c042c67..bcce695 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -79,8 +79,11 @@
# Build a small helper that runs Python code using the same version of Python
 # as gem5. This is in an unorthodox location to avoid building it for every
 # variant.
-gem5py = gem5py_env.Program('gem5py', 'python/gem5py.cc')[0]
+gem5py = gem5py_env.File('gem5py')
+gem5py_m5 = gem5py_env.File('gem5py_m5')
 gem5py_env['GEM5PY'] = gem5py
+gem5py_env['GEM5PY_M5'] = gem5py_m5
+gem5py_env['OBJSUFFIX'] = '.pyo'
 # Inject util/bld into PYTHONPATH for when we run gem5py.
 pythonpath = gem5py_env['ENV'].get('PYTHONPATH', '').split(':')
 pythonpath.append(util_bld.abspath)
@@ -132,7 +135,7 @@
                        '"${PYSOURCE_ABSPATH}"',
                        Transform("EMBED PY", max_sources=1)),
             **overrides)
-        Source(cpp, tags=self.tags, add_tags='python')
+        Source(cpp, tags=self.tags, add_tags=['python', 'm5_module'])

 class SimObject(PySource):
     '''Add a SimObject python file as a python source object and add
@@ -629,6 +632,14 @@
             INFOPY_PY=util_bld.File('infopy.py'))
 PySource('m5', 'python/m5/info.py')

+gem5py_m5_env = gem5py_env.Clone()
+gem5py_env.Append(CPPPATH=env['CPPPATH'])
+gem5py_env.Append(LIBS='z')
+gem5py_env.Program(gem5py, 'python/gem5py.cc')[0]
+m5_module_source = Source.all.with_tag(gem5py_env, 'm5_module')
+m5_module_static = list(map(lambda s: s.static(gem5py_env), m5_module_source))
+gem5py_env.Program(gem5py_m5, [ 'python/gem5py.cc' ] + m5_module_static)
+
 ########################################################################
 #
 # Create all of the SimObject param headers and enum headers
diff --git a/src/python/SConscript b/src/python/SConscript
index b7eb01e..6f44fc5 100644
--- a/src/python/SConscript
+++ b/src/python/SConscript
@@ -70,8 +70,8 @@
 PySource('m5.ext.pystats', 'm5/ext/pystats/jsonloader.py')
 PySource('m5.stats', 'm5/stats/gem5stats.py')

-Source('importer.cc', add_tags='python')
-Source('embedded.cc', add_tags='python')
+Source('importer.cc', add_tags=['python', 'm5_module'])
+Source('embedded.cc', add_tags=['python', 'm5_module'])

 Source('pybind11/core.cc', add_tags='python')
 Source('pybind11/debug.cc', add_tags='python')

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49421
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: I15fd7545f6b1ea6559cbe27cef30c778867ebe70
Gerrit-Change-Number: 49421
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to