diff options
author | Luca Falavigna <dktrkranz@debian.org> | 2010-06-15 09:21:32 +0000 |
---|---|---|
committer | Luca Falavigna <dktrkranz@debian.org> | 2010-06-15 09:21:32 +0000 |
commit | 07fc59e19636a4fc97a18b2038f3fe1c72a94000 (patch) | |
tree | 79d4a6239d81b2ccb4752d4f5ca25e0a7d3b4d4b /script | |
parent | 7f642861f3946d4241cbd668de258293ba92767a (diff) | |
parent | 340d57481935334465037d97c0db1555b70c0eb1 (diff) |
Merge commit 'upstream/2.0.0'
Diffstat (limited to 'script')
-rw-r--r-- | script/scons | 25 | ||||
-rw-r--r-- | script/scons-time | 105 | ||||
-rw-r--r-- | script/scons.bat | 6 | ||||
-rw-r--r-- | script/sconsign | 68 |
4 files changed, 105 insertions, 99 deletions
diff --git a/script/scons b/script/scons index 7fe4c60..c95bfac 100644 --- a/script/scons +++ b/script/scons @@ -24,17 +24,17 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/script/scons.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/script/scons.py 5023 2010/06/14 22:05:46 scons" -__version__ = "1.3.0" +__version__ = "2.0.0.final.0" -__build__ = "r4720" +__build__ = "r5023" -__buildsys__ = "jars-desktop" +__buildsys__ = "scons-dev" -__date__ = "2010/03/24 03:14:11" +__date__ = "2010/06/14 22:05:46" -__developer__ = "jars" +__developer__ = "scons" import os import os.path @@ -76,7 +76,7 @@ if script_dir in sys.path: libs = [] -if os.environ.has_key("SCONS_LIB_DIR"): +if "SCONS_LIB_DIR" in os.environ: libs.append(os.environ["SCONS_LIB_DIR"]) local_version = 'scons-local-' + __version__ @@ -137,12 +137,11 @@ else: # check only /foo/lib/scons*. prefs.append(sys.prefix) - temp = map(lambda x: os.path.join(x, 'lib'), prefs) - temp.extend(map(lambda x: os.path.join(x, + temp = [os.path.join(x, 'lib') for x in prefs] + temp.extend([os.path.join(x, 'lib', 'python' + sys.version[:3], - 'site-packages'), - prefs)) + 'site-packages') for x in prefs]) prefs = temp # Add the parent directory of the current python's library to the @@ -175,8 +174,8 @@ else: # Look first for 'scons-__version__' in all of our preference libs, # then for 'scons'. -libs.extend(map(lambda x: os.path.join(x, scons_version), prefs)) -libs.extend(map(lambda x: os.path.join(x, 'scons'), prefs)) +libs.extend([os.path.join(x, scons_version) for x in prefs]) +libs.extend([os.path.join(x, 'scons') for x in prefs]) sys.path = libs + sys.path diff --git a/script/scons-time b/script/scons-time index ed8530c..36c1134 100644 --- a/script/scons-time +++ b/script/scons-time @@ -29,36 +29,58 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - +from __future__ import division from __future__ import nested_scopes -__revision__ = "src/script/scons-time.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/script/scons-time.py 5023 2010/06/14 22:05:46 scons" import getopt import glob import os -import os.path import re import shutil -import string import sys import tempfile import time try: - False + sorted except NameError: - # Pre-2.2 Python has no False keyword. - import __builtin__ - __builtin__.False = not 1 + # Pre-2.4 Python has no sorted() function. + # + # The pre-2.4 Python list.sort() method does not support + # list.sort(key=) nor list.sort(reverse=) keyword arguments, so + # we must implement the functionality of those keyword arguments + # by hand instead of passing them to list.sort(). + def sorted(iterable, cmp=None, key=None, reverse=False): + if key is not None: + result = [(key(x), x) for x in iterable] + else: + result = iterable[:] + if cmp is None: + # Pre-2.3 Python does not support list.sort(None). + result.sort() + else: + result.sort(cmp) + if key is not None: + result = [t1 for t0,t1 in result] + if reverse: + result.reverse() + return result -try: - True -except NameError: - # Pre-2.2 Python has no True keyword. - import __builtin__ - __builtin__.True = not 0 +if os.environ.get('SCONS_HORRIBLE_REGRESSION_TEST_HACK') is not None: + # We can't apply the 'callable' fixer until the floor is 2.6, but the + # '-3' option to Python 2.6 and 2.7 generates almost ten thousand + # warnings. This hack allows us to run regression tests with the '-3' + # option by replacing the callable() built-in function with a hack + # that performs the same function but doesn't generate the warning. + # Note that this hack is ONLY intended to be used for regression + # testing, and should NEVER be used for real runs. + from types import ClassType + def callable(obj): + if hasattr(obj, '__call__'): return True + if isinstance(obj, (ClassType, type)): return True + return False def make_temp_file(**kw): try: @@ -90,7 +112,7 @@ def HACK_for_exec(cmd, *args): elif len(args) == 1: exec cmd in args[0] else: exec cmd in args[0], args[1] -class Plotter: +class Plotter(object): def increment_size(self, largest): """ Return the size of each horizontal increment line for a specified @@ -98,12 +120,12 @@ class Plotter: between 5 and 9 horizontal lines on the graph, on some set of boundaries that are multiples of 10/100/1000/etc. """ - i = largest / 5 + i = largest // 5 if not i: return largest multiplier = 1 while i >= 10: - i = i / 10 + i = i // 10 multiplier = multiplier * 10 return i * multiplier @@ -111,9 +133,9 @@ class Plotter: # Round up to next integer. largest = int(largest) + 1 increment = self.increment_size(largest) - return ((largest + increment - 1) / increment) * increment + return ((largest + increment - 1) // increment) * increment -class Line: +class Line(object): def __init__(self, points, type, title, label, comment, fmt="%s %s"): self.points = points self.type = type @@ -177,13 +199,13 @@ class Gnuplotter(Plotter): result = [] for line in self.lines: result.extend(line.get_x_values()) - return filter(lambda r: not r is None, result) + return [r for r in result if not r is None] def get_all_y_values(self): result = [] for line in self.lines: result.extend(line.get_y_values()) - return filter(lambda r: not r is None, result) + return [r for r in result if not r is None] def get_min_x(self): try: @@ -236,10 +258,9 @@ class Gnuplotter(Plotter): min_y = self.get_min_y() max_y = self.max_graph_value(self.get_max_y()) - range = max_y - min_y - incr = range / 10.0 + incr = (max_y - min_y) / 10.0 start = min_y + (max_y / 2.0) + (2.0 * incr) - position = [ start - (i * incr) for i in xrange(5) ] + position = [ start - (i * incr) for i in range(5) ] inx = 1 for line in self.lines: @@ -274,12 +295,11 @@ def unzip(fname): open(name, 'w').write(zf.read(name)) def read_tree(dir): - def read_files(arg, dirname, fnames): - for fn in fnames: - fn = os.path.join(dirname, fn) + for dirpath, dirnames, filenames in os.walk(dir): + for fn in filenames: + fn = os.path.join(dirpath, fn) if os.path.isfile(fn): open(fn, 'rb').read() - os.path.walk('.', read_files, None) def redirect_to_file(command, log): return '%s > %s 2>&1' % (command, log) @@ -289,7 +309,7 @@ def tee_to_file(command, log): -class SConsTimer: +class SConsTimer(object): """ Usage: scons-time SUBCOMMAND [ARGUMENTS] Type "scons-time help SUBCOMMAND" for help on a specific subcommand. @@ -506,9 +526,7 @@ class SConsTimer: """ files = [] for a in args: - g = glob.glob(a) - g.sort() - files.extend(g) + files.extend(sorted(glob.glob(a))) if tail: files = files[-tail:] @@ -539,7 +557,7 @@ class SConsTimer: for file in files: base = os.path.splitext(file)[0] - run, index = string.split(base, '-')[-2:] + run, index = base.split('-')[-2:] run = int(run) index = int(index) @@ -577,11 +595,11 @@ class SConsTimer: and returns the next run number after the largest it finds. """ x = re.compile(re.escape(prefix) + '-([0-9]+).*') - matches = map(lambda e, x=x: x.match(e), os.listdir(dir)) - matches = filter(None, matches) + matches = [x.match(e) for e in os.listdir(dir)] + matches = [_f for _f in matches if _f] if not matches: return 0 - run_numbers = map(lambda m: int(m.group(1)), matches) + run_numbers = [int(m.group(1)) for m in matches] return int(max(run_numbers)) + 1 def gnuplot_results(self, results, fmt='%s %.3f'): @@ -590,10 +608,7 @@ class SConsTimer: """ gp = Gnuplotter(self.title, self.key_location) - indices = results.keys() - indices.sort() - - for i in indices: + for i in sorted(results.keys()): try: t = self.run_titles[i] except IndexError: @@ -964,7 +979,7 @@ class SConsTimer: if self.chdir: os.chdir(self.chdir) - logfile_path = lambda x, c=self.chdir: os.path.join(c, x) + logfile_path = lambda x: os.path.join(self.chdir, x) if not args: @@ -1084,7 +1099,7 @@ class SConsTimer: if self.chdir: os.chdir(self.chdir) - logfile_path = lambda x, c=self.chdir: os.path.join(c, x) + logfile_path = lambda x: os.path.join(self.chdir, x) if not args: @@ -1248,7 +1263,7 @@ class SConsTimer: except ValueError: result.append(int(n)) else: - result.extend(range(int(x), int(y)+1)) + result.extend(list(range(int(x), int(y)+1))) return result def scons_path(self, dir): @@ -1462,7 +1477,7 @@ class SConsTimer: if self.chdir: os.chdir(self.chdir) - logfile_path = lambda x, c=self.chdir: os.path.join(c, x) + logfile_path = lambda x: os.path.join(self.chdir, x) if not args: diff --git a/script/scons.bat b/script/scons.bat index 892f867..dbc1e75 100644 --- a/script/scons.bat +++ b/script/scons.bat @@ -1,11 +1,11 @@ @REM Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
-@REM src/script/scons.bat 4720 2010/03/24 03:14:11 jars
+@REM src/script/scons.bat 5023 2010/06/14 22:05:46 scons
@echo off
set SCONS_ERRORLEVEL=
if "%OS%" == "Windows_NT" goto WinNT
@REM for 9x/Me you better not have more than 9 args
-python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-1.3.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-1.3.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9
+python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-2.0.0.final.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-2.0.0.final.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %1 %2 %3 %4 %5 %6 %7 %8 %9
@REM no way to set exit status of this script for 9x/Me
goto endscons
@@ -17,7 +17,7 @@ goto endscons setlocal
@REM ensure the script will be executed with the Python it was installed for
set path=%~dp0;%~dp0..;%path%
-python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-1.3.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-1.3.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %*
+python -c "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-2.0.0.final.0'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons-2.0.0.final.0'), join(sys.prefix, 'scons')] + sys.path; import SCons.Script; SCons.Script.main()" %*
endlocal & set SCONS_ERRORLEVEL=%ERRORLEVEL%
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto returncode
diff --git a/script/sconsign b/script/sconsign index e86f47f..c1f9632 100644 --- a/script/sconsign +++ b/script/sconsign @@ -22,22 +22,20 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# -__revision__ = "src/script/sconsign.py 4720 2010/03/24 03:14:11 jars" +__revision__ = "src/script/sconsign.py 5023 2010/06/14 22:05:46 scons" -__version__ = "1.3.0" +__version__ = "2.0.0.final.0" -__build__ = "r4720" +__build__ = "r5023" -__buildsys__ = "jars-desktop" +__buildsys__ = "scons-dev" -__date__ = "2010/03/24 03:14:11" +__date__ = "2010/06/14 22:05:46" -__developer__ = "jars" +__developer__ = "scons" import os -import os.path import sys import time @@ -64,7 +62,7 @@ if script_dir in sys.path: libs = [] -if os.environ.has_key("SCONS_LIB_DIR"): +if "SCONS_LIB_DIR" in os.environ: libs.append(os.environ["SCONS_LIB_DIR"]) local_version = 'scons-local-' + __version__ @@ -125,12 +123,11 @@ else: # check only /foo/lib/scons*. prefs.append(sys.prefix) - temp = map(lambda x: os.path.join(x, 'lib'), prefs) - temp.extend(map(lambda x: os.path.join(x, + temp = [os.path.join(x, 'lib') for x in prefs] + temp.extend([os.path.join(x, 'lib', 'python' + sys.version[:3], - 'site-packages'), - prefs)) + 'site-packages') for x in prefs]) prefs = temp # Add the parent directory of the current python's library to the @@ -163,8 +160,8 @@ else: # Look first for 'scons-__version__' in all of our preference libs, # then for 'scons'. -libs.extend(map(lambda x: os.path.join(x, scons_version), prefs)) -libs.extend(map(lambda x: os.path.join(x, 'scons'), prefs)) +libs.extend([os.path.join(x, scons_version) for x in prefs]) +libs.extend([os.path.join(x, 'scons') for x in prefs]) sys.path = libs + sys.path @@ -172,10 +169,11 @@ sys.path = libs + sys.path # END STANDARD SCons SCRIPT HEADER ############################################################################## -import cPickle -import imp -import string +import SCons.compat # so pickle will import cPickle instead + import whichdb +import pickle +import imp import SCons.SConsign @@ -195,7 +193,7 @@ whichdb.whichdb = my_whichdb def my_import(mname): if '.' in mname: - i = string.rfind(mname, '.') + i = mname.rfind('.') parent = my_import(mname[:i]) fp, pathname, description = imp.find_module(mname[i+1:], parent.__path__) @@ -203,7 +201,7 @@ def my_import(mname): fp, pathname, description = imp.find_module(mname) return imp.load_module(mname, fp, pathname, description) -class Flagger: +class Flagger(object): default_value = 1 def __setitem__(self, item, value): self.__dict__[item] = value @@ -250,11 +248,11 @@ def map_bkids(entry, name): except AttributeError: return None result = [] - for i in xrange(len(bkids)): + for i in range(len(bkids)): result.append(nodeinfo_string(bkids[i], bkidsigs[i], " ")) if result == []: return None - return string.join(result, "\n ") + return "\n ".join(result) map_field = { 'action' : map_action, @@ -283,29 +281,27 @@ def nodeinfo_raw(name, ninfo, prefix=""): try: keys = ninfo.field_list + ['_version_id'] except AttributeError: - keys = d.keys() - keys.sort() + keys = sorted(d.keys()) l = [] for k in keys: l.append('%s: %s' % (repr(k), repr(d.get(k)))) if '\n' in name: name = repr(name) - return name + ': {' + string.join(l, ', ') + '}' + return name + ': {' + ', '.join(l) + '}' def nodeinfo_cooked(name, ninfo, prefix=""): try: field_list = ninfo.field_list except AttributeError: field_list = [] - f = lambda x, ni=ninfo, v=Verbose: field(x, ni, v) if '\n' in name: name = repr(name) - outlist = [name+':'] + filter(None, map(f, field_list)) + outlist = [name+':'] + [_f for _f in [field(x, ninfo, Verbose) for x in field_list] if _f] if Verbose: sep = '\n ' + prefix else: sep = ' ' - return string.join(outlist, sep) + return sep.join(outlist) nodeinfo_string = nodeinfo_cooked @@ -338,9 +334,7 @@ def printentries(entries, location): print nodeinfo_string(name, entry.ninfo) printfield(name, entry.binfo) else: - names = entries.keys() - names.sort() - for name in names: + for name in sorted(entries.keys()): entry = entries[name] try: ninfo = entry.ninfo @@ -350,7 +344,7 @@ def printentries(entries, location): print nodeinfo_string(name, entry.ninfo) printfield(name, entry.binfo) -class Do_SConsignDB: +class Do_SConsignDB(object): def __init__(self, dbm_name, dbm): self.dbm_name = dbm_name self.dbm = dbm @@ -388,7 +382,7 @@ class Do_SConsignDB: return except KeyboardInterrupt: raise - except cPickle.UnpicklingError: + except pickle.UnpicklingError: sys.stderr.write("sconsign: ignoring invalid `%s' file `%s'\n" % (self.dbm_name, fname)) return except Exception, e: @@ -404,14 +398,12 @@ class Do_SConsignDB: else: self.printentries(dir, val) else: - keys = db.keys() - keys.sort() - for dir in keys: + for dir in sorted(db.keys()): self.printentries(dir, db[dir]) def printentries(self, dir, val): print '=== ' + dir + ':' - printentries(cPickle.loads(val), dir) + printentries(pickle.loads(val), dir) def Do_SConsignDir(name): try: @@ -423,7 +415,7 @@ def Do_SConsignDir(name): sconsign = SCons.SConsign.Dir(fp) except KeyboardInterrupt: raise - except cPickle.UnpicklingError: + except pickle.UnpicklingError: sys.stderr.write("sconsign: ignoring invalid .sconsign file `%s'\n" % (name)) return except Exception, e: |