summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-07-21 15:53:52 -0700
committerNathan Binkert <nate@binkert.org>2010-07-21 15:53:52 -0700
commit35184169179ad873b96bc99e5c9bdc4d3dd5ead6 (patch)
tree6bb30209570a3f8757c94882cc2a5363e0c1998e /src/sim
parent11bb678a8017bba31c69847ee87212579b6b2f02 (diff)
downloadgem5-35184169179ad873b96bc99e5c9bdc4d3dd5ead6.tar.xz
python: Add mechanism to override code compiled into the exectuable
If the user sets the environment variable M5_OVERRIDE_PY_SOURCE to True, then imports that would normally find python code compiled into the executable will instead first check in the absolute location where the code was found during the build of the executable. This only works for files in the src (or extras) directories, not automatically generated files. This is a developer feature!
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/init.cc3
-rw-r--r--src/sim/init.hh1
2 files changed, 3 insertions, 1 deletions
diff --git a/src/sim/init.cc b/src/sim/init.cc
index 8057c9369..1ec09369d 100644
--- a/src/sim/init.cc
+++ b/src/sim/init.cc
@@ -154,7 +154,8 @@ initM5Python()
while (pymod->filename) {
PyObject *code = getCode(pymod);
PyObject *result = PyObject_CallMethod(module, PyCC("add_module"),
- PyCC("ssO"), pymod->filename, pymod->modpath, code);
+ PyCC("sssO"), pymod->filename, pymod->abspath, pymod->modpath,
+ code);
if (!result) {
PyErr_Print();
return 1;
diff --git a/src/sim/init.hh b/src/sim/init.hh
index b0f29bf30..76cdcb74e 100644
--- a/src/sim/init.hh
+++ b/src/sim/init.hh
@@ -37,6 +37,7 @@
struct EmbeddedPyModule
{
const char *filename;
+ const char *abspath;
const char *modpath;
const char *code;
const char *code_end;