diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2013-11-02 21:34:02 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2013-11-02 21:34:02 (GMT) |
commit | 540f32bcd903747165947dd998f5c8e426bd9d69 (patch) | |
tree | 59a41e432d00e7f454e9996aa77b8cf94f714b67 /src | |
parent | cc202cdc15cd156c458ad9a2f94b2e9145be3ec2 (diff) | |
parent | 7fdab2a7cae767172f4dcea67c3ab4d1a37926e2 (diff) | |
download | SCons-540f32bcd903747165947dd998f5c8e426bd9d69.zip SCons-540f32bcd903747165947dd998f5c8e426bd9d69.tar.gz SCons-540f32bcd903747165947dd998f5c8e426bd9d69.tar.bz2 |
Merge pull request #88 (for real this time). Prev commit was actually #87.
* Allow multiple options to be specified with --debug=a,b,c
* Add support for a readonly cache (--cache-readonly)
* Always print stats if requested
* Generally try harder to print out a message on build errors
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/CacheDir.py | 8 | ||||
-rw-r--r-- | src/engine/SCons/Script/Main.py | 29 | ||||
-rw-r--r-- | src/engine/SCons/Script/SConsOptions.py | 47 |
3 files changed, 55 insertions, 29 deletions
diff --git a/src/engine/SCons/CacheDir.py b/src/engine/SCons/CacheDir.py index 3516018..9dd18e5 100644 --- a/src/engine/SCons/CacheDir.py +++ b/src/engine/SCons/CacheDir.py @@ -37,6 +37,7 @@ cache_enabled = True cache_debug = False cache_force = False cache_show = False +cache_readonly = False def CacheRetrieveFunc(target, source, env): t = target[0] @@ -70,6 +71,8 @@ CacheRetrieve = SCons.Action.Action(CacheRetrieveFunc, CacheRetrieveString) CacheRetrieveSilent = SCons.Action.Action(CacheRetrieveFunc, None) def CachePushFunc(target, source, env): + if cache_readonly: return + t = target[0] if t.nocache: return @@ -150,6 +153,9 @@ class CacheDir(object): def is_enabled(self): return (cache_enabled and not self.path is None) + def is_readonly(self): + return cache_readonly + def cachepath(self, node): """ """ @@ -201,7 +207,7 @@ class CacheDir(object): return False def push(self, node): - if not self.is_enabled(): + if self.is_readonly() or not self.is_enabled(): return return CachePush(node, [], node.get_build_env()) diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py index a81ac98..7c21519 100644 --- a/src/engine/SCons/Script/Main.py +++ b/src/engine/SCons/Script/Main.py @@ -79,7 +79,12 @@ def fetch_win32_parallel_msg(): import SCons.Platform.win32 return SCons.Platform.win32.parallel_msg -# +def revert_io(): + # This call is added to revert stderr and stdout to the original + # ones just in case some build rule or something else in the system + # has redirected them elsewhere. + sys.stderr = sys.__stderr__ + sys.stdout = sys.__stdout__ class SConsPrintHelpException(Exception): pass @@ -272,6 +277,9 @@ class BuildTask(SCons.Taskmaster.OutOfDateTask): (EnvironmentError, SCons.Errors.StopError, SCons.Errors.UserError))): type, value, trace = buildError.exc_info + if tb and print_stacktrace: + sys.stderr.write("scons: internal stack trace:\n") + traceback.print_tb(tb, file=sys.stderr) traceback.print_exception(type, value, trace) elif tb and print_stacktrace: sys.stderr.write("scons: internal stack trace:\n") @@ -986,9 +994,9 @@ def _main(parser): # reading SConscript files and haven't started building # things yet, stop regardless of whether they used -i or -k # or anything else. + revert_io() sys.stderr.write("scons: *** %s Stop.\n" % e) - exit_status = 2 - sys.exit(exit_status) + sys.exit(2) global sconscript_time sconscript_time = time.time() - start_time @@ -1074,6 +1082,8 @@ def _main(parser): # Build the targets nodes = _build_targets(fs, options, targets, target_top) if not nodes: + revert_io() + print 'Found nothing to build' exit_status = 2 def _build_targets(fs, options, targets, target_top): @@ -1093,6 +1103,7 @@ def _build_targets(fs, options, targets, target_top): SCons.Node.FS.set_diskcheck(options.diskcheck) SCons.CacheDir.cache_enabled = not options.cache_disable + SCons.CacheDir.cache_readonly = options.cache_readonly SCons.CacheDir.cache_debug = options.cache_debug SCons.CacheDir.cache_force = options.cache_force SCons.CacheDir.cache_show = options.cache_show @@ -1302,12 +1313,8 @@ def _exec_main(parser, values): prof = Profile() try: prof.runcall(_main, parser) - except SConsPrintHelpException, e: + finally: prof.dump_stats(options.profile_file) - raise e - except SystemExit: - pass - prof.dump_stats(options.profile_file) else: _main(parser) @@ -1345,7 +1352,10 @@ def main(): OptionsParser = parser try: - _exec_main(parser, values) + try: + _exec_main(parser, values) + finally: + revert_io() except SystemExit, s: if s: exit_status = s @@ -1362,6 +1372,7 @@ def main(): parser.print_help() exit_status = 0 except SCons.Errors.BuildError, e: + print e exit_status = e.exitstatus except: # An exception here is likely a builtin Python exception Python diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py index 645ab11..62033ba 100644 --- a/src/engine/SCons/Script/SConsOptions.py +++ b/src/engine/SCons/Script/SConsOptions.py @@ -248,7 +248,7 @@ class SConsOption(optparse.Option): class SConsOptionGroup(optparse.OptionGroup): """ A subclass for SCons-specific option groups. - + The only difference between this and the base class is that we print the group's help text flush left, underneath their own title but lined up with the normal "SCons Options". @@ -340,7 +340,7 @@ class SConsOptionParser(optparse.OptionParser): def add_local_option(self, *args, **kw): """ Adds a local option to the parser. - + This is initiated by a SetOption() call to add a user-defined command-line option. We add the option to a separate option group for the local options, creating the group if necessary. @@ -394,11 +394,11 @@ class SConsIndentedHelpFormatter(optparse.IndentedHelpFormatter): out liking: -- add our own regular expression that doesn't break on hyphens - (so things like --no-print-directory don't get broken); + (so things like --no-print-directory don't get broken); -- wrap the list of options themselves when it's too long (the wrapper.fill(opts) call below); - + -- set the subsequent_indent when wrapping the help_text. """ # The help for each option consists of two parts: @@ -564,6 +564,11 @@ def Parser(version): action="store_true", help="Copy already-built targets into the CacheDir.") + op.add_option('--cache-readonly', + dest='cache_readonly', default=False, + action="store_true", + help="Do not update CacheDir with built targets.") + op.add_option('--cache-show', dest='cache_show', default=False, action="store_true", @@ -579,8 +584,10 @@ def Parser(version): if not value in c_options: raise OptionValueError(opt_invalid('config', value, c_options)) setattr(parser.values, option.dest, value) + opt_config_help = "Controls Configure subsystem: %s." \ % ", ".join(config_options) + op.add_option('--config', nargs=1, type="string", dest="config", default="auto", @@ -606,23 +613,25 @@ def Parser(version): "pdb", "prepare", "presub", "stacktrace", "time"] - def opt_debug(option, opt, value, parser, + def opt_debug(option, opt, value__, parser, debug_options=debug_options, deprecated_debug_options=deprecated_debug_options): - if value in debug_options: - parser.values.debug.append(value) - elif value in deprecated_debug_options.keys(): - parser.values.debug.append(value) - try: - parser.values.delayed_warnings - except AttributeError: - parser.values.delayed_warnings = [] - msg = deprecated_debug_options[value] - w = "The --debug=%s option is deprecated%s." % (value, msg) - t = (SCons.Warnings.DeprecatedDebugOptionsWarning, w) - parser.values.delayed_warnings.append(t) - else: - raise OptionValueError(opt_invalid('debug', value, debug_options)) + for value in value__.split(','): + if value in debug_options: + parser.values.debug.append(value) + elif value in deprecated_debug_options.keys(): + parser.values.debug.append(value) + try: + parser.values.delayed_warnings + except AttributeError: + parser.values.delayed_warnings = [] + msg = deprecated_debug_options[value] + w = "The --debug=%s option is deprecated%s." % (value, msg) + t = (SCons.Warnings.DeprecatedDebugOptionsWarning, w) + parser.values.delayed_warnings.append(t) + else: + raise OptionValueError(opt_invalid('debug', value, debug_options)) + opt_debug_help = "Print various types of debugging information: %s." \ % ", ".join(debug_options) op.add_option('--debug', |