python: Ensure that m5.internal.params is available
Add an import to m5.internal.params which became necessary after:
95f9017c2e configs,python: Clean some cruft out of m5.objects.
This import is necessary but also causes problems when scons calls
build_tools/sim_object_param_struct_hh.py to generate
params/SimObject.hh. m5.internal.params itself imports _m5 and _m5 is
unavalailable resulting in an ImportError. This is bening and we can
safely ignore it.
Change-Id: I3809e81284e730fb9c9e0e7e91bd61b801d73f90
Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/67797
Maintainer: Giacomo Travaglini <giacomo.travaglini@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
This commit is contained in:
@@ -445,6 +445,9 @@ class MetaSimObject(type):
|
||||
return cls.__name__
|
||||
|
||||
def getCCClass(cls):
|
||||
# Ensure that m5.internal.params is available.
|
||||
import m5.internal.params
|
||||
|
||||
return getattr(m5.internal.params, cls.pybind_class)
|
||||
|
||||
# See ParamValue.cxx_predecls for description.
|
||||
|
||||
@@ -37,8 +37,17 @@
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import inspect
|
||||
import _m5
|
||||
|
||||
for name, module in inspect.getmembers(_m5):
|
||||
if name.startswith("param_") or name.startswith("enum_"):
|
||||
exec("from _m5.%s import *" % name)
|
||||
try:
|
||||
# Avoid ImportErrors at build time when _m5 is not available
|
||||
import _m5
|
||||
|
||||
in_gem5 = True
|
||||
except ImportError:
|
||||
# The import failed, we're being called from the build system
|
||||
in_gem5 = False
|
||||
|
||||
if in_gem5:
|
||||
for name, module in inspect.getmembers(_m5):
|
||||
if name.startswith("param_") or name.startswith("enum_"):
|
||||
exec("from _m5.%s import *" % name)
|
||||
|
||||
Reference in New Issue
Block a user