diff options
author | Steve Reinhardt <stever@eecs.umich.edu> | 2004-08-05 02:03:47 -0700 |
---|---|---|
committer | Steve Reinhardt <stever@eecs.umich.edu> | 2004-08-05 02:03:47 -0700 |
commit | d7dfe51faed84ba2b06c32a302597c0226ea239c (patch) | |
tree | 52898afd02df6502cc35b75510eb48930df277fb /sim/main.cc | |
parent | 1939370c96b48a1f635799b6017d5f5f11799353 (diff) | |
download | gem5-d7dfe51faed84ba2b06c32a302597c0226ea239c.tar.xz |
Integrate Python configuration script parsing into m5 itself.
SConscript:
Add pyconfig/{pyconfig,code}.cc
Add list of object description (.od) files.
Include pyconfig/SConscript.
base/inifile.cc:
Get rid of CPP_PIPE... it never really worked anyway.
base/inifile.hh:
Make load(ifstream&) method public so pyconfig
code can call it.
sim/main.cc:
Handle Python config scripts (end in '.py' instead of '.ini').
sim/pyconfig/m5configbase.py:
Add license.
Fix minor __setattr__ problem (2.3 related?)
--HG--
rename : util/config/m5configbase.py => sim/pyconfig/m5configbase.py
extra : convert_revision : 5e004922f950bfdefced333285584b80ad7ffb83
Diffstat (limited to 'sim/main.cc')
-rw-r--r-- | sim/main.cc | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/sim/main.cc b/sim/main.cc index 54c74fd1a..2a0427303 100644 --- a/sim/main.cc +++ b/sim/main.cc @@ -56,6 +56,7 @@ #include "sim/stat_control.hh" #include "sim/stats.hh" #include "sim/universe.hh" +#include "sim/pyconfig/pyconfig.hh" using namespace std; @@ -340,15 +341,35 @@ main(int argc, char **argv) else { // no '-', treat as config file name - // If we haven't loaded default.ini yet, and we want to, - // now is the time. Can't do it sooner because we need to - // look for '-n', can't do it later since we want - // default.ini loaded first (so that any other settings - // override it). - handleDefaultIni(loadDefaultIni, cppArgs); + // make STL string out of file name + string filename(arg_str); - if (!simConfigDB.loadCPP(arg_str, cppArgs)) { - cprintf("Error processing file %s\n", arg_str); + int ext_loc = filename.rfind("."); + + string ext = + (ext_loc != string::npos) ? filename.substr(ext_loc) : ""; + + if (ext == ".ini") { + // If we haven't loaded default.ini yet, and we want to, + // now is the time. Can't do it sooner because we need to + // look for '-n', can't do it later since we want + // default.ini loaded first (so that any other settings + // override it). + handleDefaultIni(loadDefaultIni, cppArgs); + + if (!simConfigDB.loadCPP(filename, cppArgs)) { + cprintf("Error processing file %s\n", filename); + exit(1); + } + } else if (ext == ".py") { + if (!loadPythonConfig(filename, &simConfigDB)) { + cprintf("Error processing file %s\n", filename); + exit(1); + } + } + else { + cprintf("Config file name '%s' must end in '.py' or '.ini'.\n", + filename); exit(1); } } |