SConstruct (5385:658926ff82ed) | SConstruct (5396:0347e9a6d2c2) |
---|---|
1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 51 unchanged lines hidden (view full) --- 60# 'm5' directory (or use -u or -C to tell scons where to find this 61# file), you can use 'scons -h' to print all the M5-specific build 62# options as well. 63# 64################################################### 65 66import sys 67import os | 1# -*- mode:python -*- 2 3# Copyright (c) 2004-2005 The Regents of The University of Michigan 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions are 8# met: redistributions of source code must retain the above copyright --- 51 unchanged lines hidden (view full) --- 60# 'm5' directory (or use -u or -C to tell scons where to find this 61# file), you can use 'scons -h' to print all the M5-specific build 62# options as well. 63# 64################################################### 65 66import sys 67import os |
68import re |
|
68 69from os.path import isdir, isfile, join as joinpath 70 71import SCons 72 73# Check for recent-enough Python and SCons versions. If your system's 74# default installation of Python is not recent enough, you can use a 75# non-default installation of the Python interpreter by either (1) 76# rearranging your PATH so that scons finds the non-default 'python' 77# first or (2) explicitly invoking an alternative interpreter on the 78# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]". 79EnsurePythonVersion(2,4) 80 81# Import subprocess after we check the version since it doesn't exist in 82# Python < 2.4. 83import subprocess 84 | 69 70from os.path import isdir, isfile, join as joinpath 71 72import SCons 73 74# Check for recent-enough Python and SCons versions. If your system's 75# default installation of Python is not recent enough, you can use a 76# non-default installation of the Python interpreter by either (1) 77# rearranging your PATH so that scons finds the non-default 'python' 78# first or (2) explicitly invoking an alternative interpreter on the 79# scons script, e.g., "/usr/local/bin/python2.4 `which scons` [args]". 80EnsurePythonVersion(2,4) 81 82# Import subprocess after we check the version since it doesn't exist in 83# Python < 2.4. 84import subprocess 85 |
85# Ironically, SCons 0.96 dies if you give EnsureSconsVersion a 86# 3-element version number. 87min_scons_version = (0,96,91) 88try: 89 EnsureSConsVersion(*min_scons_version) 90except: 91 print "Error checking current SCons version." 92 print "SCons", ".".join(map(str,min_scons_version)), "or greater required." 93 Exit(2) | 86# helper function: compare arrays or strings of version numbers. 87# E.g., compare_version((1,3,25), (1,4,1)') 88# returns -1, 0, 1 if v1 is <, ==, > v2 89def compare_versions(v1, v2): 90 def make_version_list(v): 91 if isinstance(v, (list,tuple)): 92 return v 93 elif isinstance(v, str): 94 return map(int, v.split('.')) 95 else: 96 raise TypeError |
94 | 97 |
98 v1 = make_version_list(v1) 99 v2 = make_version_list(v2) 100 # Compare corresponding elements of lists 101 for n1,n2 in zip(v1, v2): 102 if n1 < n2: return -1 103 if n1 > n2: return 1 104 # all corresponding values are equal... see if one has extra values 105 if len(v1) < len(v2): return -1 106 if len(v1) > len(v2): return 1 107 return 0 |
|
95 | 108 |
109# SCons version numbers need special processing because they can have 110# charecters and an release date embedded in them. This function does 111# the magic to extract them in a similar way to the SCons internal function 112# function does and then checks that the current version is not contained in 113# a list of version tuples (bad_ver_strs) 114def CheckSCons(bad_ver_strs): 115 def scons_ver(v): 116 num_parts = v.split(' ')[0].split('.') 117 major = int(num_parts[0]) 118 minor = int(re.match('\d+', num_parts[1]).group()) 119 rev = 0 120 rdate = 0 121 if len(num_parts) > 2: 122 try: rev = int(re.match('\d+', num_parts[2]).group()) 123 except: pass 124 rev_parts = num_parts[2].split('d') 125 if len(rev_parts) > 1: 126 rdate = int(re.match('\d+', rev_parts[1]).group()) 127 128 return (major, minor, rev, rdate) 129 130 sc_ver = scons_ver(SCons.__version__) 131 for bad_ver in bad_ver_strs: 132 bv = (scons_ver(bad_ver[0]), scons_ver(bad_ver[1])) 133 if compare_versions(sc_ver, bv[0]) != -1 and\ 134 compare_versions(sc_ver, bv[1]) != 1: 135 print "The version of SCons that you have installed: ", SCons.__version__ 136 print "has a bug that prevents it from working correctly with M5." 137 print "Please install a version NOT contained within the following", 138 print "ranges (inclusive):" 139 for bad_ver in bad_ver_strs: 140 print " %s - %s" % bad_ver 141 Exit(2) 142 143CheckSCons(( 144 # We need a version that is 0.96.91 or newer 145 ('0.0.0', '0.96.90'), 146 # This range has a bug with linking directories into the build dir 147 # that only have header files in them 148 ('0.97.0d20071212', '0.98.0') 149 )) 150 151 |
|
96# The absolute path to the current directory (where this file lives). 97ROOT = Dir('.').abspath 98 99# Path to the M5 source tree. 100SRCDIR = joinpath(ROOT, 'src') 101 102# tell python where to find m5 python code 103sys.path.append(joinpath(ROOT, 'src/python')) --- 38 unchanged lines hidden (view full) --- 142 143# helper function: find last occurrence of element in list 144def rfind(l, elt, offs = -1): 145 for i in range(len(l)+offs, 0, -1): 146 if l[i] == elt: 147 return i 148 raise ValueError, "element not found" 149 | 152# The absolute path to the current directory (where this file lives). 153ROOT = Dir('.').abspath 154 155# Path to the M5 source tree. 156SRCDIR = joinpath(ROOT, 'src') 157 158# tell python where to find m5 python code 159sys.path.append(joinpath(ROOT, 'src/python')) --- 38 unchanged lines hidden (view full) --- 198 199# helper function: find last occurrence of element in list 200def rfind(l, elt, offs = -1): 201 for i in range(len(l)+offs, 0, -1): 202 if l[i] == elt: 203 return i 204 raise ValueError, "element not found" 205 |
150# helper function: compare dotted version numbers. 151# E.g., compare_version('1.3.25', '1.4.1') 152# returns -1, 0, 1 if v1 is <, ==, > v2 153def compare_versions(v1, v2): 154 # Convert dotted strings to lists 155 v1 = map(int, v1.split('.')) 156 v2 = map(int, v2.split('.')) 157 # Compare corresponding elements of lists 158 for n1,n2 in zip(v1, v2): 159 if n1 < n2: return -1 160 if n1 > n2: return 1 161 # all corresponding values are equal... see if one has extra values 162 if len(v1) < len(v2): return -1 163 if len(v1) > len(v2): return 1 164 return 0 165 | |
166# Each target must have 'build' in the interior of the path; the 167# directory below this will determine the build parameters. For 168# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 169# recognize that ALPHA_SE specifies the configuration because it 170# follow 'build' in the bulid path. 171 172# Generate absolute paths to targets so we can see where the build dir is 173if COMMAND_LINE_TARGETS: --- 639 unchanged lines hidden --- | 206# Each target must have 'build' in the interior of the path; the 207# directory below this will determine the build parameters. For 208# example, for target 'foo/bar/build/ALPHA_SE/arch/alpha/blah.do' we 209# recognize that ALPHA_SE specifies the configuration because it 210# follow 'build' in the bulid path. 211 212# Generate absolute paths to targets so we can see where the build dir is 213if COMMAND_LINE_TARGETS: --- 639 unchanged lines hidden --- |