python,scons: Only generate pybind if using python
This reimplements the previously reverted change: Always generate default create() methods. The pybind code should only be generated when python is enabled. This change passes whether python is enabled into the SimObject code creation method. Then, the params code is optionally included. Note: Due to some problems in GCC's linker (or something else...) we need to have a single file with all of the generated code for the SimObject. Change-Id: I0f93b3d787d47f26db2de6c4447730f7df87a0dc Issue-on: https://gem5.atlassian.net/browse/GEM5-1003 Signed-off-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/46820 Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Bobby R. Bruce
parent
e1aaf8218e
commit
c05e086814
@@ -1021,12 +1021,16 @@ def createEnumDecls(target, source, env):
|
||||
obj.cxx_decl(code)
|
||||
code.write(target[0].abspath)
|
||||
|
||||
def createSimObjectPyBindWrapper(target, source, env):
|
||||
def createSimObjectWrappers(target, source, env):
|
||||
name = source[0].get_text_contents()
|
||||
obj = sim_objects[name]
|
||||
|
||||
code = code_formatter()
|
||||
obj.pybind_decl(code)
|
||||
# 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
|
||||
@@ -1120,17 +1124,16 @@ for name,enum in sorted(all_enums.items()):
|
||||
MakeAction(createEnumDecls, Transform("ENUMDECL")))
|
||||
env.Depends(hh_file, depends + extra_deps)
|
||||
|
||||
# Generate SimObject Python bindings wrapper files
|
||||
if env['USE_PYTHON']:
|
||||
for name,simobj in sorted(sim_objects.items()):
|
||||
py_source = PySource.modules[simobj.__module__]
|
||||
extra_deps = [ py_source.tnode ]
|
||||
cc_file = File('python/_m5/param_%s.cc' % name)
|
||||
env.Command(cc_file, Value(name),
|
||||
MakeAction(createSimObjectPyBindWrapper,
|
||||
Transform("SO PyBind")))
|
||||
env.Depends(cc_file, depends + extra_deps)
|
||||
Source(cc_file)
|
||||
# Generate SimObject Python bindings and create method wrapper files
|
||||
for name,simobj in sorted(sim_objects.items()):
|
||||
py_source = PySource.modules[simobj.__module__]
|
||||
extra_deps = [ py_source.tnode ]
|
||||
cc_file = File('python/_m5/param_%s.cc' % name)
|
||||
env.Command(cc_file, Value(name),
|
||||
MakeAction(createSimObjectWrappers,
|
||||
Transform("SO PyB/C")))
|
||||
env.Depends(cc_file, depends + extra_deps)
|
||||
Source(cc_file)
|
||||
|
||||
#
|
||||
# Handle debug flags
|
||||
|
||||
Reference in New Issue
Block a user