summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct19
-rw-r--r--configs/test/fs.py1
-rw-r--r--configs/test/test.py1
-rw-r--r--src/SConscript2
-rw-r--r--src/cpu/SConscript2
-rw-r--r--src/python/SConscript6
-rw-r--r--src/python/m5/__init__.py29
-rw-r--r--src/python/m5/config.py6
-rw-r--r--src/sim/main.cc18
9 files changed, 57 insertions, 27 deletions
diff --git a/SConstruct b/SConstruct
index c9ba13679..8ddd07c63 100644
--- a/SConstruct
+++ b/SConstruct
@@ -39,17 +39,20 @@
#
# You can build M5 in a different directory as long as there is a
# 'build/<CONFIG>' somewhere along the target path. The build system
-# expdects that all configs under the same build directory are being
+# expects that all configs under the same build directory are being
# built for the same host system.
#
# Examples:
-# These two commands are equivalent. The '-u' option tells scons to
-# search up the directory tree for this SConstruct file.
+#
+# The following two commands are equivalent. The '-u' option tells
+# scons to search up the directory tree for this SConstruct file.
# % cd <path-to-src>/m5 ; scons build/ALPHA_FS/m5.debug
# % cd <path-to-src>/m5/build/ALPHA_FS; scons -u m5.debug
-# These two commands are equivalent and demonstrate building in a
-# directory outside of the source tree. The '-C' option tells scons
-# to chdir to the specified directory to find this SConstruct file.
+#
+# The following two commands are equivalent and demonstrate building
+# in a directory outside of the source tree. The '-C' option tells
+# scons to chdir to the specified directory to find this SConstruct
+# file.
# % cd <path-to-src>/m5 ; scons /local/foo/build/ALPHA_FS/m5.debug
# % cd /local/foo/build/ALPHA_FS; scons -C <path-to-src>/m5 m5.debug
#
@@ -302,7 +305,7 @@ nonsticky_opts.AddOptions(
BoolOption('update_ref', 'Update test reference outputs', False)
)
-# These options get exported to #defines in config/*.hh (see m5/SConscript).
+# These options get exported to #defines in config/*.hh (see src/SConscript).
env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
'USE_CHECKER']
@@ -488,7 +491,7 @@ for build_path in build_paths:
if env['USE_SSE2']:
env.Append(CCFLAGS='-msse2')
- # The m5/SConscript file sets up the build rules in 'env' according
+ # The src/SConscript file sets up the build rules in 'env' according
# to the configured options. It returns a list of environments,
# one for each variant build (debug, opt, etc.)
envList = SConscript('src/SConscript', build_dir = build_path,
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/SConscript b/src/SConscript
index 933158f5f..157a911ed 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -106,7 +106,7 @@ base_sources = Split('''
sim/eventq.cc
sim/faults.cc
sim/main.cc
- python/swig/main_wrap.cc
+ python/swig/cc_main_wrap.cc
sim/param.cc
sim/profile.cc
sim/root.cc
diff --git a/src/cpu/SConscript b/src/cpu/SConscript
index 608625ed4..f855682a1 100644
--- a/src/cpu/SConscript
+++ b/src/cpu/SConscript
@@ -184,7 +184,7 @@ if 'CheckerCPU' in env['CPU_MODELS']:
Exit(1)
-# FullCPU sources are included from m5/SConscript since they're not
+# FullCPU sources are included from src/SConscript since they're not
# below this point in the file hierarchy.
# Convert file names to SCons File objects. This takes care of the
diff --git a/src/python/SConscript b/src/python/SConscript
index 7b0f591eb..3a9def9a8 100644
--- a/src/python/SConscript
+++ b/src/python/SConscript
@@ -87,12 +87,12 @@ addPkg('m5')
pyzip_files.append('m5/defines.py')
pyzip_files.append(join(env['ROOT'], 'util/pbs/jobfile.py'))
-env.Command(['swig/main_wrap.cc', 'm5/main.py'],
- 'swig/main.i',
+env.Command(['swig/cc_main_wrap.cc', 'm5/cc_main.py'],
+ 'swig/cc_main.i',
'$SWIG $SWIGFLAGS -outdir ${TARGETS[1].dir} '
'-o ${TARGETS[0]} $SOURCES')
-pyzip_dep_files.append('m5/main.py')
+pyzip_dep_files.append('m5/cc_main.py')
# Action function to build the zip archive. Uses the PyZipFile module
# included in the standard Python library.
diff --git a/src/python/m5/__init__.py b/src/python/m5/__init__.py
index c0728120c..ac6904277 100644
--- a/src/python/m5/__init__.py
+++ b/src/python/m5/__init__.py
@@ -30,11 +30,11 @@
import sys, os, time, atexit, optparse
# import the SWIG-wrapped main C++ functions
-import main
+import cc_main
# import a few SWIG-wrapped items (those that are likely to be used
# directly by user scripts) completely into this module for
# convenience
-from main import simulate, SimLoopExitEvent
+from cc_main import simulate, SimLoopExitEvent
# import the m5 compile options
import defines
@@ -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
+ cc_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,14 +202,14 @@ 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
- main.loadIniFile(resolveSimObject) # load config.ini into C++
+ cc_main.loadIniFile(resolveSimObject) # load config.ini into C++
root.createCCObject()
root.connectPorts()
- main.finalInit()
+ cc_main.finalInit()
noDot = True # temporary until we fix dot
if not noDot:
dot = pydot.Dot()
@@ -208,10 +223,10 @@ def instantiate(root):
# Export curTick to user script.
def curTick():
- return main.cvar.curTick
+ return cc_main.cvar.curTick
# register our C++ exit callback function with Python
-atexit.register(main.doExitCleanup)
+atexit.register(cc_main.doExitCleanup)
# This import allows user scripts to reference 'm5.objects.Foo' after
# just doing an 'import m5' (without an 'import m5.objects'). May not
diff --git a/src/python/m5/config.py b/src/python/m5/config.py
index 058e72578..c29477465 100644
--- a/src/python/m5/config.py
+++ b/src/python/m5/config.py
@@ -30,7 +30,7 @@
import os, re, sys, types, inspect, copy
import m5
-from m5 import panic
+from m5 import panic, cc_main
from convert import *
from multidict import multidict
@@ -529,7 +529,7 @@ class SimObject(object):
def getCCObject(self):
if not self._ccObject:
self._ccObject = -1 # flag to catch cycles in recursion
- self._ccObject = m5.main.createSimObject(self.path())
+ self._ccObject = cc_main.createSimObject(self.path())
elif self._ccObject == -1:
raise RuntimeError, "%s: recursive call to getCCObject()" \
% self.path()
@@ -1443,7 +1443,7 @@ class PortRef(object):
if self.ccConnected: # already done this
return
peer = self.peer
- m5.main.connectPorts(self.simobj.getCCObject(), self.name, self.index,
+ cc_main.connectPorts(self.simobj.getCCObject(), self.name, self.index,
peer.simobj.getCCObject(), peer.name, peer.index)
self.ccConnected = True
peer.ccConnected = True
diff --git a/src/sim/main.cc b/src/sim/main.cc
index f63aec9cc..5a99e15b4 100644
--- a/src/sim/main.cc
+++ b/src/sim/main.cc
@@ -135,7 +135,9 @@ showBriefHelp(ostream &out)
" script is executed (just like the -i option to the\n"
" Python interpreter).\n\n"
" -h Prints this help\n\n"
-" <configfile> config file name (ends in .py)\n\n",
+" <configfile> config file name which ends in .py. (Normally you can\n"
+" run <configfile> --help to get help on that config files\n"
+" parameters.\n\n",
prog);
}
@@ -166,7 +168,7 @@ sayHello(ostream &out)
}
-extern "C" { void init_main(); }
+extern "C" { void init_cc_main(); }
int
main(int argc, char **argv)
@@ -258,8 +260,8 @@ main(int argc, char **argv)
Py_Initialize();
PySys_SetArgv(argc, argv);
- // initialize SWIG 'main' module
- init_main();
+ // initialize SWIG 'cc_main' module
+ init_cc_main();
if (argc > 0) {
// extra arg(s): first is script file, remaining ones are args
@@ -297,6 +299,14 @@ main(int argc, char **argv)
Py_Finalize();
}
+
+void
+setOutputDir(const string &dir)
+{
+ simout.setDirectory(dir);
+}
+
+
IniFile inifile;
SimObject *