summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/SCons/scons-time.py')
-rwxr-xr-x3rdParty/SCons/scons-time.py38
1 files changed, 24 insertions, 14 deletions
diff --git a/3rdParty/SCons/scons-time.py b/3rdParty/SCons/scons-time.py
index cbe8c42..798b675 100755
--- a/3rdParty/SCons/scons-time.py
+++ b/3rdParty/SCons/scons-time.py
@@ -9,7 +9,7 @@
#
#
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -33,7 +33,7 @@
from __future__ import nested_scopes
-__revision__ = "src/script/scons-time.py 4043 2009/02/23 09:06:45 scons"
+__revision__ = "src/script/scons-time.py 4761 2010/04/04 14:04:44 bdeegan"
import getopt
import glob
@@ -79,6 +79,17 @@ def make_temp_file(**kw):
tempfile.template = save_template
return result
+def HACK_for_exec(cmd, *args):
+ '''
+ For some reason, Python won't allow an exec() within a function
+ that also declares an internal function (including lambda functions).
+ This function is a hack that calls exec() in a function with no
+ internal functions.
+ '''
+ if not args: exec(cmd)
+ elif len(args) == 1: exec cmd in args[0]
+ else: exec cmd in args[0], args[1]
+
class Plotter:
def increment_size(self, largest):
"""
@@ -704,7 +715,7 @@ class SConsTimer:
lines = open(file).readlines()
line = [ l for l in lines if l.endswith(object_string) ][0]
result = [ int(field) for field in line.split()[:4] ]
- if not index is None:
+ if index is not None:
result = result[index]
return result
@@ -830,7 +841,7 @@ class SConsTimer:
self.title = a
if self.config_file:
- execfile(self.config_file, self.__dict__)
+ exec open(self.config_file, 'rU').read() in self.__dict__
if self.chdir:
os.chdir(self.chdir)
@@ -859,19 +870,18 @@ class SConsTimer:
if format == 'ascii':
- def print_function_timing(file, func):
+ for file in args:
try:
- f, line, func, time = self.get_function_profile(file, func)
+ f, line, func, time = \
+ self.get_function_profile(file, function_name)
except ValueError, e:
- sys.stderr.write("%s: func: %s: %s\n" % (self.name, file, e))
+ sys.stderr.write("%s: func: %s: %s\n" %
+ (self.name, file, e))
else:
if f.startswith(cwd_):
f = f[len(cwd_):]
print "%.3f %s:%d(%s)" % (time, f, line, func)
- for file in args:
- print_function_timing(file, function_name)
-
elif format == 'gnuplot':
results = self.collect_results(args, self.get_function_time,
@@ -950,7 +960,7 @@ class SConsTimer:
self.title = a
if self.config_file:
- execfile(self.config_file, self.__dict__)
+ HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
if self.chdir:
os.chdir(self.chdir)
@@ -1070,7 +1080,7 @@ class SConsTimer:
object_name = args.pop(0)
if self.config_file:
- execfile(self.config_file, self.__dict__)
+ HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
if self.chdir:
os.chdir(self.chdir)
@@ -1208,7 +1218,7 @@ class SConsTimer:
sys.exit(1)
if self.config_file:
- execfile(self.config_file, self.__dict__)
+ exec open(self.config_file, 'rU').read() in self.__dict__
if args:
self.archive_list = args
@@ -1448,7 +1458,7 @@ class SConsTimer:
which = a
if self.config_file:
- execfile(self.config_file, self.__dict__)
+ HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
if self.chdir:
os.chdir(self.chdir)