changeset 39011f361164 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=39011f361164
summary: SCons: Add check for SCons version since the latest are broken.

changeset 2f1be3353f78 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=2f1be3353f78
summary: SCons: Make BATCH options global sticky so libelf is built 
appropriately.

diffstat:

2 files changed, 121 insertions(+), 89 deletions(-)
SConstruct            |  197 +++++++++++++++++++++++++++++--------------------
ext/libelf/SConscript |   13 ---

diffs (281 lines):

diff -r eca80b56f4fd -r 2f1be3353f78 SConstruct
--- a/SConstruct        Tue Mar 25 15:58:54 2008 -0400
+++ b/SConstruct        Mon Apr 07 23:40:24 2008 -0400
@@ -65,6 +65,7 @@
 
 import sys
 import os
+import re
 
 from os.path import isdir, isfile, join as joinpath
 
@@ -82,78 +83,20 @@ EnsurePythonVersion(2,4)
 # Python < 2.4.
 import subprocess
 
-# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a
-# 3-element version number.
-min_scons_version = (0,96,91)
-try:
-    EnsureSConsVersion(*min_scons_version)
-except:
-    print "Error checking current SCons version."
-    print "SCons", ".".join(map(str,min_scons_version)), "or greater required."
-    Exit(2)
-
-
-# The absolute path to the current directory (where this file lives).
-ROOT = Dir('.').abspath
-
-# Path to the M5 source tree.
-SRCDIR = joinpath(ROOT, 'src')
-
-# tell python where to find m5 python code
-sys.path.append(joinpath(ROOT, 'src/python'))
-
-def check_style_hook(ui):
-    ui.readconfig(joinpath(ROOT, '.hg', 'hgrc'))
-    style_hook = ui.config('hooks', 'pretxncommit.style', None)
-
-    if not style_hook:
-        print """\
-You're missing the M5 style hook.
-Please install the hook so we can ensure that all code fits a common style.
-
-All you'd need to do is add the following lines to your repository .hg/hgrc
-or your personal .hgrc
-----------------
-
-[extensions]
-style = %s/util/style.py
-
-[hooks]
-pretxncommit.style = python:style.check_whitespace
-""" % (ROOT)
-        sys.exit(1)
-
-if ARGUMENTS.get('IGNORE_STYLE') != 'True' and isdir(joinpath(ROOT, '.hg')):
-    try:
-        from mercurial import ui
-        check_style_hook(ui.ui())
-    except ImportError:
-        pass
-
-###################################################
-#
-# Figure out which configurations to set up based on the path(s) of
-# the target(s).
-#
-###################################################
-
-# Find default configuration & binary.
-Default(os.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):
-    for i in range(len(l)+offs, 0, -1):
-        if l[i] == elt:
-            return i
-    raise ValueError, "element not found"
-
-# helper function: compare dotted version numbers.
-# E.g., compare_version('1.3.25', '1.4.1')
+# helper function: compare arrays or strings of version numbers.
+# E.g., compare_version((1,3,25), (1,4,1)')
 # returns -1, 0, 1 if v1 is <, ==, > v2
 def compare_versions(v1, v2):
-    # Convert dotted strings to lists
-    v1 = map(int, v1.split('.'))
-    v2 = map(int, v2.split('.'))
+    def make_version_list(v):
+        if isinstance(v, (list,tuple)):
+            return v
+        elif isinstance(v, str):
+            return map(int, v.split('.'))
+        else:
+            raise TypeError
+
+    v1 = make_version_list(v1)
+    v2 = make_version_list(v2)
     # Compare corresponding elements of lists
     for n1,n2 in zip(v1, v2):
         if n1 < n2: return -1
@@ -162,6 +105,103 @@ def compare_versions(v1, v2):
     if len(v1) < len(v2): return -1
     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'), 
+    # This range has a bug with linking directories into the build dir
+    # that only have header files in them 
+    ('0.97.0d20071212', '0.98.0')
+    ))
+
+
+# The absolute path to the current directory (where this file lives).
+ROOT = Dir('.').abspath
+
+# Path to the M5 source tree.
+SRCDIR = joinpath(ROOT, 'src')
+
+# tell python where to find m5 python code
+sys.path.append(joinpath(ROOT, 'src/python'))
+
+def check_style_hook(ui):
+    ui.readconfig(joinpath(ROOT, '.hg', 'hgrc'))
+    style_hook = ui.config('hooks', 'pretxncommit.style', None)
+
+    if not style_hook:
+        print """\
+You're missing the M5 style hook.
+Please install the hook so we can ensure that all code fits a common style.
+
+All you'd need to do is add the following lines to your repository .hg/hgrc
+or your personal .hgrc
+----------------
+
+[extensions]
+style = %s/util/style.py
+
+[hooks]
+pretxncommit.style = python:style.check_whitespace
+""" % (ROOT)
+        sys.exit(1)
+
+if ARGUMENTS.get('IGNORE_STYLE') != 'True' and isdir(joinpath(ROOT, '.hg')):
+    try:
+        from mercurial import ui
+        check_style_hook(ui.ui())
+    except ImportError:
+        pass
+
+###################################################
+#
+# Figure out which configurations to set up based on the path(s) of
+# the target(s).
+#
+###################################################
+
+# Find default configuration & binary.
+Default(os.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):
+    for i in range(len(l)+offs, 0, -1):
+        if l[i] == elt:
+            return i
+    raise ValueError, "element not found"
 
 # Each target must have 'build' in the interior of the path; the
 # directory below this will determine the build parameters.  For
@@ -263,6 +303,8 @@ global_sticky_opts.AddOptions(
 global_sticky_opts.AddOptions(
     ('CC', 'C compiler', os.environ.get('CC', env['CC'])),
     ('CXX', 'C++ compiler', os.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)
     )    
@@ -329,6 +371,12 @@ else:
     print '       Please fix SConstruct and src/SConscript and try again.'
     Exit(1)
 
+# Do this after we save setting back, or else we'll tack on an
+# extra 'qdo' every time we run scons.
+if env['BATCH']:
+    env['CC']  = env['BATCH_CMD'] + ' ' + env['CC']
+    env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX']
+
 if sys.platform == 'cygwin':
     # cygwin has some header file issues...
     env.Append(CCFLAGS=Split("-Wno-uninitialized"))
@@ -397,7 +445,6 @@ try:
             env.Append(CFLAGS='-arch x86_64')
             env.Append(LINKFLAGS='-arch x86_64')
             env.Append(ASFLAGS='-arch x86_64')
-            env['OSX64bit'] = True
 except:
     pass
 
@@ -552,8 +599,6 @@ sticky_opts.AddOptions(
     BoolOption('USE_MYSQL', 'Use MySQL for stats output', have_mysql),
     BoolOption('USE_FENV', 'Use <fenv.h> IEEE mode control', have_fenv),
     BoolOption('USE_CHECKER', 'Use checker for detailed CPU models', False),
-    BoolOption('BATCH', 'Use batch pool for build and tests', False),
-    ('BATCH_CMD', 'Batch pool submission command name', 'qdo'),
     ('PYTHONHOME',
      'Override the default PYTHONHOME for this system (use with caution)',
      '%s:%s' % (sys.prefix, sys.exec_prefix)),
@@ -779,12 +824,6 @@ for build_path in build_paths:
     # Save sticky option settings back to current options file
     sticky_opts.Save(current_opts_file, env)
 
-    # Do this after we save setting back, or else we'll tack on an
-    # extra 'qdo' every time we run scons.
-    if env['BATCH']:
-        env['CC']  = env['BATCH_CMD'] + ' ' + env['CC']
-        env['CXX'] = env['BATCH_CMD'] + ' ' + env['CXX']
-
     if env['USE_SSE2']:
         env.Append(CCFLAGS='-msse2')
 
diff -r eca80b56f4fd -r 2f1be3353f78 ext/libelf/SConscript
--- a/ext/libelf/SConscript     Tue Mar 25 15:58:54 2008 -0400
+++ b/ext/libelf/SConscript     Mon Apr 07 23:40:24 2008 -0400
@@ -87,16 +87,9 @@ ElfFile('libelf_fsize.c')
 ElfFile('libelf_fsize.c')
 ElfFile('libelf_msize.c')
 
-m4env = Environment(ENV=os.environ)
-
-if env.get('CC'):
-    m4env['CC'] = env['CC']
-if env.get('CXX'):
-    m4env['CXX'] = env['CXX']
-
-if env.get('OSX64bit'):
-    m4env.Append(CFLAGS='-arch x86_64')
-    m4env.Append(LINKFLAGS='-arch x86_64')
+m4env = env.Copy()
+del m4env['CCFLAGS']
+del m4env['CPPPATH']
 
 # If we have gm4 use it
 if m4env.Detect('gm4'):
_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to