Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/49387 )
Change subject: scons: Eliminate the tnode dict in PySource.
......................................................................
scons: Eliminate the tnode dict in PySource.
Rather than pass these values to the embedPyFile function indirectly
through python, we should pass them through the environment so SCons can
know about them, and also to simplify the PySource class.
Change-Id: I466613c194bfd965a6f5f34e1e92131834fb8b66
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49387
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
Reviewed-by: Hoa Nguyen <[email protected]>
---
M src/SConscript
1 file changed, 14 insertions(+), 13 deletions(-)
Approvals:
Hoa Nguyen: Looks good to me, approved
Gabe Black: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/SConscript b/src/SConscript
index 8c5c2b9..a5b679c 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -88,11 +88,6 @@
# byte code, compress it, and then generate a c++ file that
# inserts the result into an array.
def embedPyFile(target, source, env):
- def c_str(string):
- if string is None:
- return "0"
- return '"%s"' % string
-
'''Action function to compile a .py into a code object, marshal it,
compress it, and stick it into an asm file so the code appears as
just bytes with a label in the data section. The action takes two
@@ -104,12 +99,14 @@
import subprocess
+ marshal_bin, pysource = source
+ modpath = env['PYSOURCE_MODPATH']
+ abspath = env['PYSOURCE_ABSPATH']
marshalled = subprocess.check_output(
- [source[0].abspath, str(source[1])], env=env['ENV'])
+ [marshal_bin.abspath, str(pysource)], env=env['ENV'])
compressed = zlib.compress(marshalled)
data = compressed
- pysource = PySource.tnodes[source[1]]
code = code_formatter()
code('''\
@@ -127,8 +124,8 @@
# into a global list.
code('''
EmbeddedPython embedded_module_info(
- ${{c_str(pysource.abspath)}},
- ${{c_str(pysource.modpath)}},
+ "${abspath}",
+ "${modpath}",
embedded_module_data,
${{len(data)}},
${{len(marshalled)}});
@@ -141,7 +138,6 @@
class PySource(SourceFile):
'''Add a python source file to the named package'''
modules = {}
- tnodes = {}
def __init__(self, package, source, tags=None, add_tags=None):
'''specify the python package, the source file, and any tags'''
@@ -171,10 +167,15 @@
self.cpp = File(self.filename + '.cc')
PySource.modules[modpath] = self
- PySource.tnodes[self.tnode] = self
- marshal_env.Command(self.cpp, [ py_marshal, self.tnode ],
- MakeAction(embedPyFile, Transform("EMBED PY")))
+ overrides = {
+ 'PYSOURCE_MODPATH': modpath,
+ 'PYSOURCE_ABSPATH': abspath,
+ }
+ marshal_env.Command(self.cpp, [ py_marshal, File(source) ],
+ MakeAction(embedPyFile, Transform("EMBED PY"),
+ varlist=overrides.keys()),
+ **overrides)
if main['USE_PYTHON']:
Source(self.cpp, tags=self.tags, add_tags='python')
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49387
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: I466613c194bfd965a6f5f34e1e92131834fb8b66
Gerrit-Change-Number: 49387
Gerrit-PatchSet: 12
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s