Bobby R. Bruce has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/39715 )
Change subject: scons,python: Fix `--without-python` flag
......................................................................
scons,python: Fix `--without-python` flag
Even with the `--without-python` flag, checks were still done to ensure
the correct version of Python was being used. This commit fixes this so
these checks are not performed when `--without-python` is enabled.
Change-Id: I2242f2971a49ef28cff229ad0337bce0a998413d
Issue-on: https://gem5.atlassian.net/browse/GEM5-880
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39715
Reviewed-by: Gabe Black <[email protected]>
Reviewed-by: Lukas Steiner <[email protected]>
Maintainer: Gabe Black <[email protected]>
Tested-by: kokoro <[email protected]>
---
M SConstruct
M src/SConscript
2 files changed, 32 insertions(+), 25 deletions(-)
Approvals:
Gabe Black: Looks good to me, approved; Looks good to me, approved
Lukas Steiner: Looks good to me, approved
kokoro: Regressions pass
diff --git a/SConstruct b/SConstruct
index 4cf2f10..f744c77 100755
--- a/SConstruct
+++ b/SConstruct
@@ -709,22 +709,25 @@
if not conf.CheckLib(lib):
error("Can't find library %s required by python." % lib)
-main.Prepend(CPPPATH=Dir('ext/pybind11/include/'))
-# Bare minimum environment that only includes python
-marshal_env = main.Clone()
-marshal_env.Append(CCFLAGS='$MARSHAL_CCFLAGS_EXTRA')
-marshal_env.Append(LINKFLAGS='$MARSHAL_LDFLAGS_EXTRA')
-py_version = conf.CheckPythonLib()
-if not py_version:
- error("Can't find a working Python installation")
+ main.Prepend(CPPPATH=Dir('ext/pybind11/include/'))
-# Found a working Python installation. Check if it meets minimum
-# requirements.
-if py_version[0] < 3 or \
- (py_version[0] == 3 and py_version[1] < 6):
- error('Python version too old. Version 3.6 or newer is required.')
-elif py_version[0] > 3:
- warning('Python version too new. Python 3 expected.')
+ marshal_env = main.Clone()
+
+ # Bare minimum environment that only includes python
+ marshal_env.Append(CCFLAGS='$MARSHAL_CCFLAGS_EXTRA')
+ marshal_env.Append(LINKFLAGS='$MARSHAL_LDFLAGS_EXTRA')
+
+ py_version = conf.CheckPythonLib()
+ if not py_version:
+ error("Can't find a working Python installation")
+
+ # Found a working Python installation. Check if it meets minimum
+ # requirements.
+ if py_version[0] < 3 or \
+ (py_version[0] == 3 and py_version[1] < 6):
+ error('Python version too old. Version 3.6 or newer is required.')
+ elif py_version[0] > 3:
+ warning('Python version too new. Python 3 expected.')
# On Solaris you need to use libsocket for socket ops
if not
conf.CheckLibWithHeader(None, 'sys/socket.h', 'C++', 'accept(0,0,0);'):
@@ -1271,10 +1274,13 @@
env.Append(CCFLAGS='$CCFLAGS_EXTRA')
env.Append(LINKFLAGS='$LDFLAGS_EXTRA')
+ exports=['env']
+ if main['USE_PYTHON']:
+ exports.append('marshal_env')
+
# The src/SConscript file sets up the build rules in 'env' according
# to the configured variables. It returns a list of environments,
# one for each variant build (debug, opt, etc.)
- SConscript('src/SConscript', variant_dir=variant_path,
- exports=['env', 'marshal_env'])
+ SConscript('src/SConscript', variant_dir=variant_path, exports=exports)
atexit.register(summarize_warnings)
diff --git a/src/SConscript b/src/SConscript
index 81a1b4d..74b9516 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -1208,11 +1208,6 @@
Transform("VER TAGS")))
env.AlwaysBuild(tags)
-# Build a small helper that marshals the Python code using the same
-# version of Python as gem5. This is in an unorthodox location to
-# avoid building it for every variant.
-py_marshal = marshal_env.Program('marshal', 'python/marshal.cc')[0]
-
# Embed python files. All .py files that have been indicated by a
# PySource() call in a SConscript need to be embedded into the M5
# library. To do that, we compile the file to byte code, marshal the
@@ -1266,10 +1261,16 @@
''')
code.write(str(target[0]))
-for source in PySource.all:
- marshal_env.Command(source.cpp, [ py_marshal, source.tnode ],
+if main['USE_PYTHON']:
+ # Build a small helper that marshals the Python code using the same
+ # version of Python as gem5. This is in an unorthodox location to
+ # avoid building it for every variant.
+ py_marshal = marshal_env.Program('marshal', 'python/marshal.cc')[0]
+
+ for source in PySource.all:
+ marshal_env.Command(source.cpp, [ py_marshal, source.tnode ],
MakeAction(embedPyFile, Transform("EMBED PY")))
- Source(source.cpp, tags=source.tags, add_tags='python')
+ Source(source.cpp, tags=source.tags, add_tags='python')
########################################################################
#
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/39715
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: I2242f2971a49ef28cff229ad0337bce0a998413d
Gerrit-Change-Number: 39715
Gerrit-PatchSet: 4
Gerrit-Owner: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Lukas Steiner <[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