summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2006-06-17 09:58:10 -0400
committerSteve Reinhardt <stever@eecs.umich.edu>2006-06-17 09:58:10 -0400
commit4a9c0a7dfc8aa1fcd70ec2b194691adec9ce424e (patch)
treecfda0fa61771fbe622dba67a1b424488d1af6d86
parent7efd0eafd8e5bb7a9ff088d56f1de3bd871b5a2b (diff)
downloadgem5-4a9c0a7dfc8aa1fcd70ec2b194691adec9ce424e.tar.xz
Add --outdir option. Didn't call it "-d" since
that's already being used for "detailed cpu". Needed to add extra function for user script to pass parsed options back to m5 module. configs/test/fs.py: configs/test/test.py: Call setStandardOptions(). src/python/m5/__init__.py: Add --outdir option. Add setStandardOptions() so user script can pass parsed options back to m5 module. src/sim/main.cc: Add SWIG-wrappable function to set output dir. --HG-- extra : convert_revision : 1323bee69ca920c699a1cd1218e15b7b0875c1e5
-rw-r--r--configs/test/fs.py1
-rw-r--r--configs/test/test.py1
-rw-r--r--src/python/m5/__init__.py17
-rw-r--r--src/sim/main.cc8
4 files changed, 26 insertions, 1 deletions
diff --git a/configs/test/fs.py b/configs/test/fs.py
index c742e916c..aa530dd55 100644
--- a/configs/test/fs.py
+++ b/configs/test/fs.py
@@ -8,6 +8,7 @@ parser = optparse.OptionParser(option_list=m5.standardOptions)
parser.add_option("-t", "--timing", action="store_true")
(options, args) = parser.parse_args()
+m5.setStandardOptions(options)
if args:
print "Error: script doesn't take any positional arguments"
diff --git a/configs/test/test.py b/configs/test/test.py
index 2b5a6769f..a570c1a08 100644
--- a/configs/test/test.py
+++ b/configs/test/test.py
@@ -17,6 +17,7 @@ parser.add_option("-d", "--detailed", action="store_true")
parser.add_option("-m", "--maxtick", type="int")
(options, args) = parser.parse_args()
+m5.setStandardOptions(options)
if args:
print "Error: script doesn't take any positional arguments"
diff --git a/src/python/m5/__init__.py b/src/python/m5/__init__.py
index c0728120c..19af24e6f 100644
--- a/src/python/m5/__init__.py
+++ b/src/python/m5/__init__.py
@@ -58,6 +58,20 @@ def AddToPath(path):
sys.path.insert(1, path)
+# The m5 module's pointer to the parsed options object
+options = None
+
+
+# User should call this function after calling parse_args() to pass
+# parsed standard option values back into the m5 module for
+# processing.
+def setStandardOptions(_options):
+ # Set module global var
+ global options
+ options = _options
+ # tell C++ about output directory
+ main.setOutputDir(options.outdir)
+
# Callback to set trace flags. Not necessarily the best way to do
# things in the long run (particularly if we change how these global
# options are handled).
@@ -110,6 +124,7 @@ TorF = "True | False"
# Standard optparse options. Need to be explicitly included by the
# user script when it calls optparse.OptionParser().
standardOptions = [
+ optparse.make_option("--outdir", type="string", default="."),
optparse.make_option("--traceflags", type="string", action="callback",
callback=setTraceFlags),
optparse.make_option("--tracestart", type="int", action="callback",
@@ -187,7 +202,7 @@ def resolveSimObject(name):
def instantiate(root):
config.ticks_per_sec = float(root.clock.frequency)
# ugly temporary hack to get output to config.ini
- sys.stdout = file('config.ini', 'w')
+ sys.stdout = file(os.path.join(options.outdir, 'config.ini'), 'w')
root.print_ini()
sys.stdout.close() # close config.ini
sys.stdout = sys.__stdout__ # restore to original
diff --git a/src/sim/main.cc b/src/sim/main.cc
index f63aec9cc..fc057ea6f 100644
--- a/src/sim/main.cc
+++ b/src/sim/main.cc
@@ -297,6 +297,14 @@ main(int argc, char **argv)
Py_Finalize();
}
+
+void
+setOutputDir(const string &dir)
+{
+ simout.setDirectory(dir);
+}
+
+
IniFile inifile;
SimObject *