summaryrefslogtreecommitdiff
path: root/build/SConstruct
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2005-09-05 16:31:27 -0400
committerSteve Reinhardt <stever@eecs.umich.edu>2005-09-05 16:31:27 -0400
commit845bdb0d8edf3c8e5f8871eba984933bfca6a743 (patch)
treef4a39ba980264772c503ad25c0298cac909f5770 /build/SConstruct
parent9196fbfe5e2246a4f9086a8692a0569d25fd84d9 (diff)
downloadgem5-845bdb0d8edf3c8e5f8871eba984933bfca6a743.tar.xz
Regression tests now run under scons!
For example, 'scons ALPHA_SE/test/opt/quick' will build ALPHA_SE/m5.opt if necessary and run all the self-identified "quick" tests on it. Other possibilities: - Run just test1: scons ALPHA_SE/test/opt/test1 - Run all tests: scons ALPHA_SE/test/opt - Run all tests on debug build: scons ALPHA_SE/test/debug - Update test1 reference outputs in m5-test: scons update_ref=y ALPHA_SE/test/opt/test1 The proper tests will be selected based on the setting of FULL_SYSTEM, ALPHA_TLASER, etc. README: Update directions to use scons-based test invocation. SConscript: Return list of generated build environments to SConstruct so it can associate tests with each of them. Set 'M5Binary' attribute on each env to record name of generated binary to be tested. build/SConstruct: - Support invoking m5-test tests via scons. - Add new non-sticky option category, for 'update_ref'. - Move existing "sticky" option definitions out of build_dir loop. Someday we can generate help text from these. - Make 'CC' and 'CXX' sticky options; use environment vars as defaults if available. - Make config builder more scons-y. python/m5/__init__.py: Make AddToPath() correctly handle relative path arguments. Assumes that sys.path[0] has the directory where the current Python file lives; new m5execfile() function sets this up properly for exec'd files. --HG-- extra : convert_revision : 48896688592e210d8e63f96c34e57474853d0e66
Diffstat (limited to 'build/SConstruct')
-rw-r--r--build/SConstruct148
1 files changed, 102 insertions, 46 deletions
diff --git a/build/SConstruct b/build/SConstruct
index b7e769e15..03401b04e 100644
--- a/build/SConstruct
+++ b/build/SConstruct
@@ -160,11 +160,11 @@ env = Environment(ENV = os.environ, # inherit user's environment vars
env.SConsignFile("sconsign")
-if os.environ.has_key('CC'):
- env.Replace(CC=os.environ['CC'])
-
-if os.environ.has_key('CXX'):
- env.Replace(CXX=os.environ['CXX'])
+# I waffle on this setting... it does avoid a few painful but
+# unnecessary builds, but it also seems to make trivial builds take
+# noticeably longer.
+if False:
+ env.TargetSignatures('content')
# M5_EXT is used by isa_parser.py to find the PLY package.
env.Append(ENV = { 'M5_EXT' : EXT_SRCDIR })
@@ -220,26 +220,90 @@ if have_mysql:
env = conf.Finish()
-# The source operand is a Value node containing the value of the option.
-def build_config_file(target, source, env, option):
+# Sticky options get saved in the options file so they persist from
+# one invocation to the next (unless overridden, in which case the new
+# value becomes sticky).
+sticky_opts = Options(args=ARGUMENTS)
+sticky_opts.AddOptions(
+ EnumOption('TARGET_ISA', 'Target ISA', 'alpha', ('alpha')),
+ BoolOption('FULL_SYSTEM', 'Full-system support', False),
+ BoolOption('ALPHA_TLASER',
+ 'Model Alpha TurboLaser platform (vs. Tsunami)', False),
+ BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
+ BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
+ False),
+ BoolOption('SS_COMPATIBLE_FP',
+ 'Make floating-point results compatible with SimpleScalar',
+ False),
+ BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql),
+ BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
+ BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
+ ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
+ ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX']))
+ )
+
+# Non-sticky options only apply to the current build.
+nonsticky_opts = Options(args=ARGUMENTS)
+nonsticky_opts.AddOptions(
+ BoolOption('update_ref', 'Update test reference outputs', False)
+ )
+
+# These options get exported to #defines in config/*.hh (see m5/SConscript).
+env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
+ 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
+ 'STATS_BINNING']
+
+# Define a handy 'no-op' action
+def no_action(target, source, env):
+ return 0
+
+env.NoAction = Action(no_action, None)
+
+# libelf build is described in its own SConscript file.
+# SConscript-global is the build in build/libelf shared among all
+# configs.
+env.SConscript('m5/libelf/SConscript-global', exports = 'env')
+
+###################################################
+#
+# Define a SCons builder for configuration flag headers.
+#
+###################################################
+
+# This function generates a config header file that #defines the
+# option symbol to the current option setting (0 or 1). The source
+# operands are the name of the option and a Value node containing the
+# value of the option.
+def build_config_file(target, source, env):
+ (option, value) = [s.get_contents() for s in source]
f = file(str(target[0]), 'w')
- print >> f, '#define', option, int(eval(str(source[0])))
+ print >> f, '#define', option, value
f.close()
return None
-def config_builder(env, option):
+# Generate the message to be printed when building the config file.
+def build_config_file_string(target, source, env):
+ (option, value) = [s.get_contents() for s in source]
+ return "Defining %s as %s in %s." % (option, value, target[0])
+
+# Combine the two functions into a scons Action object.
+config_action = Action(build_config_file, build_config_file_string)
+
+# The emitter munges the source & target node lists to reflect what
+# we're really doing.
+def config_emitter(target, source, env):
+ # extract option name from Builder arg
+ option = str(target[0])
+ # True target is config header file
target = os.path.join('config', option.lower() + '.hh')
- source = Value(env[option])
- def my_build_config_file(target, source, env):
- build_config_file(target, source, env, option)
- env.Command(target, source, my_build_config_file)
+ # Force value to 0/1 even if it's a Python bool
+ val = int(eval(str(env[option])))
+ # Sources are option name & value (packaged in SCons Value nodes)
+ return ([target], [Value(option), Value(val)])
-env.Append(BUILDERS = { 'ConfigFile' : config_builder })
+config_builder = Builder(emitter = config_emitter, action = config_action)
-# libelf build is described in its own SConscript file.
-# SConscript-global is the build in build/libelf shared among all
-# configs.
-env.SConscript('m5/libelf/SConscript-global', exports = 'env')
+env.Append(BUILDERS = { 'ConfigFile' : config_builder })
###################################################
#
@@ -255,31 +319,13 @@ for build_dir in build_dirs:
env = base_env.Copy()
# Set env according to the build directory config.
options_file = os.path.join('build_options', build_dir)
- if not os.path.isfile(options_file):
+ if os.path.isfile(options_file):
+ sticky_opts.files = [options_file]
+ else:
print "Options file %s not found, using defaults." % options_file
- opts = Options(options_file, ARGUMENTS)
- opts.AddOptions(
- EnumOption('TARGET_ISA', 'Target ISA', 'alpha', ('alpha')),
- BoolOption('FULL_SYSTEM', 'Full-system support', False),
- BoolOption('ALPHA_TLASER',
- 'Model Alpha TurboLaser platform (vs. Tsunami)', False),
- BoolOption('NO_FAST_ALLOC', 'Disable fast object allocator', False),
- BoolOption('EFENCE', 'Link with Electric Fence malloc debugger',
- False),
- BoolOption('SS_COMPATIBLE_FP',
- 'Make floating-point results compatible with SimpleScalar',
- False),
- BoolOption('STATS_BINNING', 'Bin statistics by CPU mode', have_mysql),
- BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
- BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv)
- )
-
- opts.Update(env)
- opts.Save(options_file, env)
-
- env.ExportOptions = ['FULL_SYSTEM', 'ALPHA_TLASER', 'USE_FENV', \
- 'USE_MYSQL', 'NO_FAST_ALLOC', 'SS_COMPATIBLE_FP', \
- 'STATS_BINNING']
+
+ sticky_opts.Update(env)
+ nonsticky_opts.Update(env)
# Process option settings.
@@ -305,11 +351,21 @@ for build_dir in build_dirs:
print "Compiling in", build_dir, "with MySQL support."
env.ParseConfig(mysql_config_libs)
env.ParseConfig(mysql_config_include)
-
+
+ # Save sticky option settings back to file
+ sticky_opts.Save(options_file, env)
+
# The m5/SConscript file sets up the build rules in 'env' according
- # to the configured options.
- SConscript('m5/SConscript', build_dir = build_dir, exports = 'env',
- duplicate=0)
+ # to the configured options. It returns a list of environments,
+ # one for each variant build (debug, opt, etc.)
+ envList = SConscript('m5/SConscript', build_dir = build_dir,
+ exports = 'env', duplicate = False)
+
+ # Set up the regression tests for each build.
+ for e in envList:
+ SConscript('m5-test/SConscript',
+ build_dir = os.path.join(build_dir, 'test', e.Label),
+ exports = { 'env' : e }, duplicate = False)
###################################################
#