changeset e4257cde2d79 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=e4257cde2d79
description:
        SCons: Turn some scons variables into command line options.

diffstat:

 SConstruct       |  99 +++++++++++++++++++++++++++++++++++--------------------
 tests/SConscript |   4 +-
 util/regress     |   2 +-
 3 files changed, 66 insertions(+), 39 deletions(-)

diffs (193 lines):

diff -r 5e5efbb37e6f -r e4257cde2d79 SConstruct
--- a/SConstruct        Thu Mar 03 23:01:38 2011 -0800
+++ b/SConstruct        Thu Mar 03 23:54:31 2011 -0800
@@ -121,10 +121,43 @@
 
 from m5.util import compareVersions, readCommand
 
-AddOption('--colors', dest='use_colors', action='store_true')
-AddOption('--no-colors', dest='use_colors', action='store_false')
+help_texts = {
+    "options" : "",
+    "global_vars" : "",
+    "local_vars" : ""
+}
+
+Export("help_texts")
+
+def AddM5Option(*args, **kwargs):
+    col_width = 30
+
+    help = "  " + ", ".join(args)
+    if "help" in kwargs:
+        length = len(help)
+        if length >= col_width:
+            help += "\n" + " " * col_width
+        else:
+            help += " " * (col_width - length)
+        help += kwargs["help"]
+    help_texts["options"] += help + "\n"
+
+    AddOption(*args, **kwargs)
+
+AddM5Option('--colors', dest='use_colors', action='store_true',
+            help="Add color to abbreviated scons output")
+AddM5Option('--no-colors', dest='use_colors', action='store_false',
+            help="Don't add color to abbreviated scons output")
+AddM5Option('--default', dest='default', type='string', action='store',
+            help='Override which build_opts file to use for defaults')
+AddM5Option('--ignore-style', dest='ignore_style', action='store_true',
+            help='Disable style checking hooks')
+AddM5Option('--update-ref', dest='update_ref', action='store_true',
+            help='Update test reference outputs')
+AddM5Option('--verbose', dest='verbose', action='store_true',
+            help='Print full tool command lines')
+
 use_colors = GetOption('use_colors')
-
 if use_colors:
     from m5.util.terminal import termcap
 elif use_colors is None:
@@ -206,7 +239,7 @@
     # 2) Ensure that the style hook is in place.
     try:
         ui = None
-        if ARGUMENTS.get('IGNORE_STYLE') != 'True':
+        if GetOption('ignore_style'):
             from mercurial import ui
             ui = ui.ui()
     except ImportError:
@@ -318,12 +351,11 @@
         if not isdir(path):
             raise SCons.Errors.UserError("Path does not exist: '%s'" % path)
 
-global_sticky_vars_file = joinpath(build_root, 'variables.global')
+global_vars_file = joinpath(build_root, 'variables.global')
 
-global_sticky_vars = Variables(global_sticky_vars_file, args=ARGUMENTS)
-global_nonsticky_vars = Variables(args=ARGUMENTS)
+global_vars = Variables(global_vars_file, args=ARGUMENTS)
 
-global_sticky_vars.AddVariables(
+global_vars.AddVariables(
     ('CC', 'C compiler', environ.get('CC', main['CC'])),
     ('CXX', 'C++ compiler', environ.get('CXX', main['CXX'])),
     ('BATCH', 'Use batch pool for build and tests', False),
@@ -333,31 +365,12 @@
      PathListAllExist, PathListMakeAbsolute),
     )
 
-global_nonsticky_vars.AddVariables(
-    ('VERBOSE', 'Print full tool command lines', False),
-    ('update_ref', 'Update test reference outputs', False)
-    )
-
-# Update main environment with values from ARGUMENTS & global_sticky_vars_file
-global_sticky_vars.Update(main)
-global_nonsticky_vars.Update(main)
-global_help_texts = {
-    "global_sticky" : global_sticky_vars.GenerateHelpText(main),
-    "global_nonsticky" : global_nonsticky_vars.GenerateHelpText(main)
-}
-
-# base help text
-help_text = '''
-Usage: scons [scons options] [build options] [target(s)]
-
-Global sticky options:
-%(global_sticky)s
-Global nonsticky options:
-%(global_nonsticky)s
-''' % global_help_texts
+# Update main environment with values from ARGUMENTS & global_vars_file
+global_vars.Update(main)
+help_texts["global_vars"] += global_vars.GenerateHelpText(main)
 
 # Save sticky variable settings back to current variables file
-global_sticky_vars.Save(global_sticky_vars_file, main)
+global_vars.Save(global_vars_file, main)
 
 # Parse EXTRAS variable to build list of all directories where we're
 # look for sources etc.  This list is exported as base_dir_list.
@@ -455,7 +468,7 @@
 Export('Transform')
 
 
-if main['VERBOSE']:
+if GetOption('verbose'):
     def MakeAction(action, string, *args, **kwargs):
         return Action(action, *args, **kwargs)
 else:
@@ -965,8 +978,10 @@
         # Get default build variables from source tree.  Variables are
         # normally determined by name of $VARIANT_DIR, but can be
         # overriden by 'default=' arg on command line.
-        default_vars_file = joinpath('build_opts',
-                                     ARGUMENTS.get('default', variant_dir))
+        default = GetOption('default')
+        if not default:
+            default = variant_dir
+        default_vars_file = joinpath('build_opts', default)
         if isfile(default_vars_file):
             sticky_vars.files.append(default_vars_file)
             print "Variables file %s not found,\n  using defaults in %s" \
@@ -979,7 +994,8 @@
     # Apply current variable settings to env
     sticky_vars.Update(env)
 
-    help_text += "\nSticky variables for %s:\n" % variant_dir \
+    help_texts["local_vars"] += \
+        "Build variables for %s:\n" % variant_dir \
                  + sticky_vars.GenerateHelpText(env)
 
     # Process variable settings.
@@ -1024,4 +1040,15 @@
                    variant_dir = joinpath(variant_path, 'tests', e.Label),
                    exports = { 'env' : e }, duplicate = False)
 
-Help(help_text)
+# base help text
+Help('''
+Usage: scons [scons options] [build variables] [target(s)]
+
+Extra scons options:
+%(options)s
+
+Global build variables:
+%(global_vars)s
+
+%(local_vars)s
+''' % help_texts)
diff -r 5e5efbb37e6f -r e4257cde2d79 tests/SConscript
--- a/tests/SConscript  Thu Mar 03 23:01:38 2011 -0800
+++ b/tests/SConscript  Thu Mar 03 23:54:31 2011 -0800
@@ -178,7 +178,7 @@
 # - long-winded message about ignored sources
 ignore_msg = '''
 Note: The following file(s) will not be copied.  New non-standard
-      output files must be copied manually once before update_ref will
+      output files must be copied manually once before --update-ref will
       recognize them as outputs.  Otherwise they are assumed to be
       inputs and are ignored.
 '''
@@ -251,7 +251,7 @@
                 testAction)
 
     # phony target to echo status
-    if env['update_ref']:
+    if GetOption('update_ref'):
         p = env.Command(tgt('_update'),
                         [ref_stats, new_stats, status_file],
                         updateAction)
diff -r 5e5efbb37e6f -r e4257cde2d79 util/regress
--- a/util/regress      Thu Mar 03 23:01:38 2011 -0800
+++ b/util/regress      Thu Mar 03 23:54:31 2011 -0800
@@ -133,7 +133,7 @@
 if options.keep_going:
     scons_opts += ' -k'
 
-cmd = 'scons IGNORE_STYLE=True %s %s' % (scons_opts, ' '.join(targets))
+cmd = 'scons --ignore-style %s %s' % (scons_opts, ' '.join(targets))
 if options.no_exec:
     print cmd
 else:
_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to