sim: Clean up and simplify main().
Use pybind11 to simplify the python parts, update some inaccurate comments, rename m5Main to gem5Main, remove code which supported python versions less than 3. Change-Id: I139af7d3d1052cfbce779a87e34d7ce997876a60 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49414 Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -29,10 +29,13 @@
|
||||
#include "pybind11/pybind11.h"
|
||||
#include "python/m5ImporterCode.hh"
|
||||
|
||||
#include "sim/init.hh"
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
PYBIND11_EMBEDDED_MODULE(importer, m)
|
||||
{
|
||||
m.def("_init_all_embedded", gem5::EmbeddedPython::initAll);
|
||||
py::str importer_code(
|
||||
reinterpret_cast<const char *>(gem5::Blobs::m5ImporterCode),
|
||||
gem5::Blobs::m5ImporterCode_len);
|
||||
|
||||
@@ -74,7 +74,12 @@ class CodeImporter(object):
|
||||
# Create an importer and add it to the meta_path so future imports can
|
||||
# use it. There's currently nothing in the importer, but calls to
|
||||
# add_module can be used to add code.
|
||||
import sys
|
||||
importer = CodeImporter()
|
||||
add_module = importer.add_module
|
||||
sys.meta_path.insert(0, importer)
|
||||
def install():
|
||||
importer = CodeImporter()
|
||||
global add_module
|
||||
add_module = importer.add_module
|
||||
import sys
|
||||
sys.meta_path.insert(0, importer)
|
||||
|
||||
# Injected into this module's namespace by the c++ code that loads it.
|
||||
_init_all_embedded()
|
||||
|
||||
Reference in New Issue
Block a user