diff options
Diffstat (limited to 'src/engine/SCons/Script')
| -rw-r--r-- | src/engine/SCons/Script/Main.py | 36 | ||||
| -rw-r--r-- | src/engine/SCons/Script/SConscript.py | 10 | ||||
| -rw-r--r-- | src/engine/SCons/Script/__init__.py | 40 |
3 files changed, 52 insertions, 34 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index 2c18112..6eedbab 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -309,6 +309,7 @@ command_time = 0 exit_status = 0 # exit status, assume success by default repositories = [] num_jobs = 1 # this is modifed by SConscript.SetJobs() +delayed_warnings = [] diskcheck_all = SCons.Node.FS.diskcheck_types() diskcheck_option_set = None @@ -671,12 +672,13 @@ class OptParser(OptionParser): "build all Default() targets.") debug_options = ["count", "dtree", "explain", "findlibs", - "includes", "memoizer", "memory", - "nomemoizer", "objects", + "includes", "memoizer", "memory", "objects", "pdb", "presub", "stacktrace", "stree", "time", "tree"] - def opt_debug(option, opt, value, parser, debug_options=debug_options): + deprecated_debug_options = [ "nomemoizer", ] + + def opt_debug(option, opt, value, parser, debug_options=debug_options, deprecated_debug_options=deprecated_debug_options): if value in debug_options: try: if parser.values.debug is None: @@ -684,6 +686,9 @@ class OptParser(OptionParser): except AttributeError: parser.values.debug = [] parser.values.debug.append(value) + elif value in deprecated_debug_options: + w = "The --debug=%s option is deprecated and has no effect." % value + delayed_warnings.append((SCons.Warnings.DeprecatedWarning, w)) else: raise OptionValueError("Warning: %s is not a valid debug type" % value) self.add_option('--debug', action="callback", type="string", @@ -945,6 +950,8 @@ class SConscriptSettableOptions: def _main(args, parser): + global exit_status + # Here's where everything really happens. # First order of business: set up default warnings and and then @@ -954,6 +961,7 @@ def _main(args, parser): SCons.Warnings.DeprecatedWarning, SCons.Warnings.DuplicateEnvironmentWarning, SCons.Warnings.MissingSConscriptWarning, + SCons.Warnings.NoMetaclassSupportWarning, SCons.Warnings.NoParallelSupportWarning, SCons.Warnings.MisleadingKeywordsWarning, ] for warning in default_warnings: @@ -962,6 +970,9 @@ def _main(args, parser): if options.warn: _setup_warn(options.warn) + for warning_type, message in delayed_warnings: + SCons.Warnings.warn(warning_type, message) + # Next, we want to create the FS object that represents the outside # world's file system, as that's central to a lot of initialization. # To do this, however, we need to be in the directory from which we @@ -1019,7 +1030,8 @@ def _main(args, parser): # Give them the options usage now, before we fail # trying to read a non-existent SConstruct file. parser.print_help() - sys.exit(0) + exit_status = 0 + return raise SCons.Errors.UserError, "No SConstruct file found." if scripts[0] == "-": @@ -1105,7 +1117,6 @@ def _main(args, parser): # reading SConscript files and haven't started building # things yet, stop regardless of whether they used -i or -k # or anything else. - global exit_status sys.stderr.write("scons: *** %s Stop.\n" % e) exit_status = 2 sys.exit(exit_status) @@ -1134,7 +1145,8 @@ def _main(args, parser): else: print help_text print "Use scons -H for help about command-line options." - sys.exit(0) + exit_status = 0 + return # Now that we've read the SConscripts we can set the options # that are SConscript settable: @@ -1285,12 +1297,9 @@ def _main(args, parser): count_stats.append(('post-', 'build')) def _exec_main(): - all_args = sys.argv[1:] - try: - all_args = string.split(os.environ['SCONSFLAGS']) + all_args - except KeyError: - # it's OK if there's no SCONSFLAGS - pass + sconsflags = os.environ.get('SCONSFLAGS', '') + all_args = string.split(sconsflags) + sys.argv[1:] + parser = OptParser() global options options, args = parser.parse_args(all_args) @@ -1353,8 +1362,7 @@ def main(): #SCons.Debug.dumpLoggedInstances('*') if print_memoizer: - print "Memoizer (memory cache) hits and misses:" - SCons.Memoize.Dump() + SCons.Memoize.Dump("Memoizer (memory cache) hits and misses:") # Dump any development debug info that may have been enabled. # These are purely for internal debugging during development, so diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index dc896a0..749be6d 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -183,6 +183,7 @@ def _SConscript(fs, *files, **kw): # the builder so that it doesn't get built *again* # during the actual build phase. f.build() + f.built() f.builder_set(None) if f.exists(): _file_ = open(f.get_abspath(), "r") @@ -286,9 +287,12 @@ def SConscript_exception(file=sys.stderr): # in SCons itself. Show the whole stack. tb = exc_tb stack = traceback.extract_tb(tb) - type = str(exc_type) - if type[:11] == "exceptions.": - type = type[11:] + try: + type = exc_type.__name__ + except AttributeError: + type = str(exc_type) + if type[:11] == "exceptions.": + type = type[11:] file.write('%s: %s:\n' % (type, exc_value)) for fname, line, func, text in stack: file.write(' File "%s", line %d:\n' % (fname, line)) diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index ce96867..55797df 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -44,29 +44,33 @@ import string import sys import UserList -# Special chicken-and-egg handling of the "--debug=memoizer" -# and "--debug=nomemoizer" flags: +# Special chicken-and-egg handling of the "--debug=memoizer" flag: # # SCons.Memoize contains a metaclass implementation that affects how -# the other classes are instantiated. The Memoizer handles optional -# counting of the hits and misses by using a different, parallel set of -# functions, so we don't slow down normal operation any more than we -# have to. We can also tell it disable memoization completely. +# the other classes are instantiated. The Memoizer may add shim methods +# to classes that have methods that cache computed values in order to +# count and report the hits and misses. # -# If we wait to enable the counting or disable memoization completely -# until we've parsed the command line options normally, it will be too -# late, because the Memoizer will have already analyzed the classes -# that it's Memoizing and bound the (non-counting) versions of the -# functions. So we have to use a special-case, up-front check for -# the "--debug=memoizer" and "--debug=nomemoizer" flags and do what's -# appropriate before we import any of the other modules that use it. +# If we wait to enable the Memoization until after we've parsed the +# command line options normally, it will be too late, because the Memoizer +# will have already analyzed the classes that it's Memoizing and decided +# to not add the shims. So we use a special-case, up-front check for +# the "--debug=memoizer" flag and enable Memoizer before we import any +# of the other modules that use it. + _args = sys.argv + string.split(os.environ.get('SCONSFLAGS', '')) if "--debug=memoizer" in _args: import SCons.Memoize - SCons.Memoize.EnableCounting() -if "--debug=nomemoizer" in _args: - import SCons.Memoize - SCons.Memoize.DisableMemoization() + import SCons.Warnings + try: + SCons.Memoize.EnableMemoization() + except SCons.Warnings.Warning: + # Some warning was thrown (inability to --debug=memoizer on + # Python 1.5.2 because it doesn't have metaclasses). Arrange + # for it to be displayed or not after warnings are configured. + import Main + exc_type, exc_value, tb = sys.exc_info() + Main.delayed_warnings.append(exc_type, exc_value) del _args import SCons.Action @@ -77,6 +81,7 @@ import SCons.Options import SCons.Platform import SCons.Scanner import SCons.SConf +import SCons.Subst import SCons.Tool import SCons.Util import SCons.Defaults @@ -127,6 +132,7 @@ call_stack = _SConscript.call_stack # Action = SCons.Action.Action +AllowSubstExceptions = SCons.Subst.SetAllowableExceptions BoolOption = SCons.Options.BoolOption Builder = SCons.Builder.Builder Configure = _SConscript.Configure |
