changeset f73e06bc8765 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=f73e06bc8765
description:
        scons: Require SCons version 0.98.1
        This allows me to clean things up so we are up to date with respect to
        deprecated features.  There are many features scheduled for permanent 
failure
        in scons 2.0 and 0.98.1 provides the most compatability for that.  It
        also paves the way for some nice new features that I will add soon

diffstat:

4 files changed, 250 insertions(+), 284 deletions(-)
SConstruct               |  501 ++++++++++++++++++++++------------------------
ext/libelf/SConscript    |    2 
src/SConscript           |   29 --
src/arch/alpha/SConsopts |    2 

diffs (truncated from 905 to 300 lines):

diff -r 50fb2cb40609 -r f73e06bc8765 SConstruct
--- a/SConstruct        Mon Feb 09 20:10:12 2009 -0800
+++ b/SConstruct        Mon Feb 09 20:10:14 2009 -0800
@@ -27,6 +27,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # Authors: Steve Reinhardt
+#          Nathan Binkert
 
 ###################################################
 #
@@ -63,25 +64,55 @@
 #
 ###################################################
 
-import sys
+# Check for recent-enough Python and SCons versions.
+try:
+    # Really old versions of scons only take two options for the
+    # function, so check once without the revision and once with the
+    # revision, the first instance will fail for stuff other than
+    # 0.98, and the second will fail for 0.98.0
+    EnsureSConsVersion(0, 98)
+    EnsureSConsVersion(0, 98, 1)
+except SystemExit, e:
+    print """
+For more details, see:
+    http://m5sim.org/wiki/index.php/Compiling_M5
+"""
+    raise
+
+# We ensure the python version early because we have stuff that
+# requires python 2.4
+try:
+    EnsurePythonVersion(2, 4)
+except SystemExit, e:
+    print """
+You can use a non-default installation of the Python interpreter by
+either (1) rearranging your PATH so that scons finds the non-default
+'python' first or (2) explicitly invoking an alternative interpreter
+on the scons script.
+
+For more details, see:
+    http://m5sim.org/wiki/index.php/Using_a_non-default_Python_installation
+"""
+    raise
+
 import os
 import re
+import subprocess
+import sys
 
-from os.path import isdir, isfile, join as joinpath
+from os import mkdir, environ
+from os.path import abspath, basename, dirname, expanduser, normpath
+from os.path import exists,  isdir, isfile
+from os.path import join as joinpath, split as splitpath
 
 import SCons
 
-# Check for recent-enough Python and SCons versions.  If your system's
-# default installation of Python is not recent enough, you can use a
-# non-default installation of the Python interpreter by either (1)
-# rearranging your PATH so that scons finds the non-default 'python'
-# first or (2) explicitly invoking an alternative interpreter on the
-# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]".
-EnsurePythonVersion(2,4)
-
-# Import subprocess after we check the version since it doesn't exist in
-# Python < 2.4.
-import subprocess
+def read_command(cmd):
+    """run the command cmd, read the results and return them
+    this is sorta like `cmd` in shell"""
+    from subprocess import Popen, PIPE, STDOUT
+    subp = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, close_fds=True)
+    return subp.communicate()[0]
 
 # helper function: compare arrays or strings of version numbers.
 # E.g., compare_version((1,3,25), (1,4,1)')
@@ -106,46 +137,6 @@
     if len(v1) > len(v2): return  1
     return 0
 
-# SCons version numbers need special processing because they can have
-# charecters and an release date embedded in them. This function does
-# the magic to extract them in a similar way to the SCons internal function
-# function does and then checks that the current version is not contained in
-# a list of version tuples (bad_ver_strs)
-def CheckSCons(bad_ver_strs):
-    def scons_ver(v):
-        num_parts = v.split(' ')[0].split('.')
-        major = int(num_parts[0])
-        minor = int(re.match('\d+', num_parts[1]).group())
-        rev = 0
-        rdate = 0
-        if len(num_parts) > 2:
-            try: rev = int(re.match('\d+', num_parts[2]).group())
-            except: pass
-            rev_parts = num_parts[2].split('d')
-            if len(rev_parts) > 1:
-                rdate = int(re.match('\d+', rev_parts[1]).group())
-
-        return (major, minor, rev, rdate)
-
-    sc_ver = scons_ver(SCons.__version__)
-    for bad_ver in bad_ver_strs:
-        bv = (scons_ver(bad_ver[0]), scons_ver(bad_ver[1]))
-        if  compare_versions(sc_ver, bv[0]) != -1 and\
-            compare_versions(sc_ver, bv[1]) != 1:
-            print "The version of SCons that you have installed: ", 
SCons.__version__
-            print "has a bug that prevents it from working correctly with M5."
-            print "Please install a version NOT contained within the 
following",
-            print "ranges (inclusive):"
-            for bad_ver in bad_ver_strs:
-                print "    %s - %s" % bad_ver
-            Exit(2)
-
-CheckSCons(( 
-    # We need a version that is 0.96.91 or newer
-    ('0.0.0', '0.96.90'), 
-    ))
-
-
 # The absolute path to the current directory (where this file lives).
 ROOT = Dir('.').abspath
 
@@ -155,6 +146,25 @@
 # tell python where to find m5 python code
 sys.path.append(joinpath(ROOT, 'src/python'))
 
+###################################################
+# Mercurial Stuff.
+# 1) Grab repository revision if we know it.
+# 2) Ensure that the style hook is in place.
+###################################################
+
+hg_info = "Unknown"
+try:
+    if not exists(ROOT) or not isdir(ROOT) or \
+           not exists(joinpath(ROOT, ".hg")):
+        raise ValueError(".hg directory not found")
+    hg_info = read_command("cd %s; hg id -n -i -t -b" % ROOT).strip()
+except ImportError, e:
+    print "Mercurial not found"
+except ValueError, e:
+    print e
+except Exception, e:
+    print "Other mercurial exception: %s" % e
+
 def check_style_hook(ui):
     ui.readconfig(joinpath(ROOT, '.hg', 'hgrc'))
     style_hook = ui.config('hooks', 'pretxncommit.style', None)
@@ -183,6 +193,7 @@
     except ImportError:
         pass
 
+
 ###################################################
 #
 # Figure out which configurations to set up based on the path(s) of
@@ -191,7 +202,7 @@
 ###################################################
 
 # Find default configuration & binary.
-Default(os.environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug'))
+Default(environ.get('M5_DEFAULT_BINARY', 'build/ALPHA_SE/m5.debug'))
 
 # helper function: find last occurrence of element in list
 def rfind(l, elt, offs = -1):
@@ -211,17 +222,17 @@
     # Ask SCons which directory it was invoked from
     launch_dir = GetLaunchDir()
     # Make targets relative to invocation directory
-    abs_targets = map(lambda x: os.path.normpath(joinpath(launch_dir, str(x))),
-                      COMMAND_LINE_TARGETS)
+    abs_targets = [ normpath(joinpath(launch_dir, str(x))) for x in \
+                    COMMAND_LINE_TARGETS]
 else:
     # Default targets are relative to root of tree
-    abs_targets = map(lambda x: os.path.normpath(joinpath(ROOT, str(x))),
-                      DEFAULT_TARGETS)
+    abs_targets = [ normpath(joinpath(ROOT, str(x))) for x in \
+                    DEFAULT_TARGETS]
 
 
 # Generate a list of the unique build roots and configs that the
 # collected targets reference.
-build_paths = []
+variant_paths = []
 build_root = None
 for t in abs_targets:
     path_dirs = t.split('/')
@@ -238,13 +249,13 @@
             print "Error: build targets not under same build root\n"\
                   "  %s\n  %s" % (build_root, this_build_root)
             Exit(1)
-    build_path = joinpath('/',*path_dirs[:build_top+2])
-    if build_path not in build_paths:
-        build_paths.append(build_path)
+    variant_path = joinpath('/',*path_dirs[:build_top+2])
+    if variant_path not in variant_paths:
+        variant_paths.append(variant_path)
 
 # Make sure build_root exists (might not if this is the first build there)
 if not isdir(build_root):
-    os.mkdir(build_root)
+    mkdir(build_root)
 
 ###################################################
 #
@@ -253,13 +264,14 @@
 #
 ###################################################
 
-env = Environment(ENV = os.environ,  # inherit user's environment vars
+env = Environment(ENV = environ,  # inherit user's environment vars
                   ROOT = ROOT,
-                  SRCDIR = SRCDIR)
+                  SRCDIR = SRCDIR,
+                  HG_INFO = hg_info)
 
 Export('env')
 
-env.SConsignFile(joinpath(build_root,"sconsign"))
+env.SConsignFile(joinpath(build_root, "sconsign"))
 
 # Default duplicate option is to use hard links, but this messes up
 # when you use emacs to edit a file in the target dir, as emacs moves
@@ -267,22 +279,16 @@
 # (soft) links work better.
 env.SetOption('duplicate', 'soft-copy')
 
-# 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')
-
 #
-# Set up global sticky options... these are common to an entire build
+# Set up global sticky variables... these are common to an entire build
 # tree (not specific to a particular build like ALPHA_SE)
 #
 
-# Option validators & converters for global sticky options
+# Variable validators & converters for global sticky variables
 def PathListMakeAbsolute(val):
     if not val:
         return val
-    f = lambda p: os.path.abspath(os.path.expanduser(p))
+    f = lambda p: abspath(expanduser(p))
     return ':'.join(map(f, val.split(':')))
 
 def PathListAllExist(key, val, env):
@@ -293,36 +299,35 @@
         if not isdir(path):
             raise SCons.Errors.UserError("Path does not exist: '%s'" % path)
 
-global_sticky_opts_file = joinpath(build_root, 'options.global')
+global_sticky_vars_file = joinpath(build_root, 'variables.global')
 
-global_sticky_opts = Options(global_sticky_opts_file, args=ARGUMENTS)
+global_sticky_vars = Variables(global_sticky_vars_file, args=ARGUMENTS)
 
-global_sticky_opts.AddOptions(
-    ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
-    ('CXX', 'C++ compiler', os.environ.get('CXX', env['CXX'])),
+global_sticky_vars.AddVariables(
+    ('CC', 'C compiler', environ.get('CC', env['CC'])),
+    ('CXX', 'C++ compiler', environ.get('CXX', env['CXX'])),
     ('BATCH', 'Use batch pool for build and tests', False),
     ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
     ('EXTRAS', 'Add Extra directories to the compilation', '',
      PathListAllExist, PathListMakeAbsolute)
     )    
 
-
 # base help text
 help_text = '''
 Usage: scons [scons options] [build options] [target(s)]
 
+Global sticky options:
 '''
 
-help_text += "Global sticky options:\n" \
-             + global_sticky_opts.GenerateHelpText(env)
+help_text += global_sticky_vars.GenerateHelpText(env)
 
-# Update env with values from ARGUMENTS & file global_sticky_opts_file
-global_sticky_opts.Update(env)
+# Update env with values from ARGUMENTS & file global_sticky_vars_file
+global_sticky_vars.Update(env)
 
-# Save sticky option settings back to current options file
-global_sticky_opts.Save(global_sticky_opts_file, env)
+# Save sticky variable settings back to current variables file
+global_sticky_vars.Save(global_sticky_vars_file, env)
 
-# Parse EXTRAS option to build list of all directories where we're
_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to