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:
Nikos Nikoleris
2023-02-09 09:33:17 +00:00
parent 109c327209
commit df0bed6858
2 changed files with 16 additions and 4 deletions

View File

@@ -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.

View File

@@ -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)