summaryrefslogtreecommitdiff
path: root/engine/SCons/Script
diff options
context:
space:
mode:
authorLuca Falavigna <dktrkranz@debian.org>2014-04-26 11:52:25 +0200
committerLuca Falavigna <dktrkranz@debian.org>2014-04-26 11:52:25 +0200
commitc58ef47cac0ffa49ecabdb228991a89fcdb4f8ef (patch)
tree677bf40bab72549a4c2dd882328a9896d1a08a87 /engine/SCons/Script
parentd4746a568b9d1464742de0788d39b08309e28cb0 (diff)
parent599d55e3999ad29f72fdc3a61d7c4bafc3171452 (diff)
Merge tag 'upstream/2.3.1'
Upstream version 2.3.1
Diffstat (limited to 'engine/SCons/Script')
-rw-r--r--engine/SCons/Script/Interactive.py4
-rw-r--r--engine/SCons/Script/Main.py42
-rw-r--r--engine/SCons/Script/SConsOptions.py118
-rw-r--r--engine/SCons/Script/SConscript.py4
-rw-r--r--engine/SCons/Script/__init__.py4
5 files changed, 131 insertions, 41 deletions
diff --git a/engine/SCons/Script/Interactive.py b/engine/SCons/Script/Interactive.py
index b9a2e1e..1bc4fc8 100644
--- a/engine/SCons/Script/Interactive.py
+++ b/engine/SCons/Script/Interactive.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -20,7 +20,7 @@
# 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/engine/SCons/Script/Interactive.py 2013/03/03 09:48:35 garyo"
+__revision__ = "src/engine/SCons/Script/Interactive.py 2014/03/02 14:18:15 garyo"
__doc__ = """
SCons interactive mode
diff --git a/engine/SCons/Script/Main.py b/engine/SCons/Script/Main.py
index 3f1b407..164c61d 100644
--- a/engine/SCons/Script/Main.py
+++ b/engine/SCons/Script/Main.py
@@ -13,7 +13,7 @@ it goes here.
unsupported_python_version = (2, 3, 0)
deprecated_python_version = (2, 7, 0)
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -34,7 +34,7 @@ deprecated_python_version = (2, 7, 0)
# 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/engine/SCons/Script/Main.py 2013/03/03 09:48:35 garyo"
+__revision__ = "src/engine/SCons/Script/Main.py 2014/03/02 14:18:15 garyo"
import SCons.compat
@@ -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")
@@ -622,7 +630,7 @@ def _set_debug_values(options):
debug_values = options.debug
if "count" in debug_values:
- # All of the object counts are within "if __debug__:" blocks,
+ # All of the object counts are within "if track_instances:" blocks,
# which get stripped when running optimized (with python -O or
# from compiled *.pyo files). Provide a warning if __debug__ is
# stripped, so it doesn't just look like --debug=count is broken.
@@ -630,6 +638,7 @@ def _set_debug_values(options):
if __debug__: enable_count = True
if enable_count:
count_stats.enable(sys.stdout)
+ SCons.Debug.track_instances = True
else:
msg = "--debug=count is not supported when running SCons\n" + \
"\twith the python -O option or optimized (.pyo) modules."
@@ -644,6 +653,8 @@ def _set_debug_values(options):
if "memory" in debug_values:
memory_stats.enable(sys.stdout)
print_objects = ("objects" in debug_values)
+ if print_objects:
+ SCons.Debug.track_instances = True
if "presub" in debug_values:
SCons.Action.print_actions_presub = 1
if "stacktrace" in debug_values:
@@ -983,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
@@ -1063,6 +1074,7 @@ def _main(parser):
platform = SCons.Platform.platform_module()
if options.interactive:
+ SCons.Node.interactive = True
SCons.Script.Interactive.interact(fs, OptionsParser, options,
targets, target_top)
@@ -1071,6 +1083,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):
@@ -1083,12 +1097,14 @@ def _build_targets(fs, options, targets, target_top):
SCons.Action.print_actions = not options.silent
SCons.Action.execute_actions = not options.no_exec
SCons.Node.FS.do_store_info = not options.no_exec
+ SCons.Node.do_store_info = not options.no_exec
SCons.SConf.dryrun = options.no_exec
if options.diskcheck:
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
@@ -1298,12 +1314,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)
@@ -1331,7 +1343,7 @@ def main():
pass
parts.append(version_string("engine", SCons))
parts.append(path_string("engine", SCons))
- parts.append("Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation")
+ parts.append("Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation")
version = ''.join(parts)
import SConsOptions
@@ -1341,7 +1353,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
@@ -1358,6 +1373,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/engine/SCons/Script/SConsOptions.py b/engine/SCons/Script/SConsOptions.py
index 6a6bae3..09f71b7 100644
--- a/engine/SCons/Script/SConsOptions.py
+++ b/engine/SCons/Script/SConsOptions.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/SConsOptions.py 2013/03/03 09:48:35 garyo"
+__revision__ = "src/engine/SCons/Script/SConsOptions.py 2014/03/02 14:18:15 garyo"
import optparse
import re
@@ -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".
@@ -337,10 +337,75 @@ class SConsOptionParser(optparse.OptionParser):
option.process(opt, value, values, self)
+ def reparse_local_options(self):
+ """
+ Re-parse the leftover command-line options stored
+ in self.largs, so that any value overridden on the
+ command line is immediately available if the user turns
+ around and does a GetOption() right away.
+
+ We mimic the processing of the single args
+ in the original OptionParser._process_args(), but here we
+ allow exact matches for long-opts only (no partial
+ argument names!).
+
+ Else, this would lead to problems in add_local_option()
+ below. When called from there, we try to reparse the
+ command-line arguments that
+ 1. haven't been processed so far (self.largs), but
+ 2. are possibly not added to the list of options yet.
+
+ So, when we only have a value for "--myargument" yet,
+ a command-line argument of "--myarg=test" would set it.
+ Responsible for this behaviour is the method
+ _match_long_opt(), which allows for partial matches of
+ the option name, as long as the common prefix appears to
+ be unique.
+ This would lead to further confusion, because we might want
+ to add another option "--myarg" later on (see issue #2929).
+
+ """
+ rargs = []
+ largs_restore = []
+ # Loop over all remaining arguments
+ skip = False
+ for l in self.largs:
+ if skip:
+ # Accept all remaining arguments as they are
+ largs_restore.append(l)
+ else:
+ if len(l) > 2 and l[0:2] == "--":
+ # Check long option
+ lopt = (l,)
+ if "=" in l:
+ # Split into option and value
+ lopt = l.split("=", 1)
+
+ if lopt[0] in self._long_opt:
+ # Argument is already known
+ rargs.append('='.join(lopt))
+ else:
+ # Not known yet, so reject for now
+ largs_restore.append('='.join(lopt))
+ else:
+ if l == "--" or l == "-":
+ # Stop normal processing and don't
+ # process the rest of the command-line opts
+ largs_restore.append(l)
+ skip = True
+ else:
+ rargs.append(l)
+
+ # Parse the filtered list
+ self.parse_args(rargs, self.values)
+ # Restore the list of remaining arguments for the
+ # next call of AddOption/add_local_option...
+ self.largs = self.largs + largs_restore
+
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.
@@ -364,7 +429,7 @@ class SConsOptionParser(optparse.OptionParser):
# available if the user turns around and does a GetOption()
# right away.
setattr(self.values.__defaults__, result.dest, result.default)
- self.parse_args(self.largs, self.values)
+ self.reparse_local_options()
return result
@@ -394,11 +459,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 +629,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 +649,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 +678,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',
diff --git a/engine/SCons/Script/SConscript.py b/engine/SCons/Script/SConscript.py
index 59039ea..52aade2 100644
--- a/engine/SCons/Script/SConscript.py
+++ b/engine/SCons/Script/SConscript.py
@@ -6,7 +6,7 @@ files.
"""
#
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -28,7 +28,7 @@ files.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import division
-__revision__ = "src/engine/SCons/Script/SConscript.py 2013/03/03 09:48:35 garyo"
+__revision__ = "src/engine/SCons/Script/SConscript.py 2014/03/02 14:18:15 garyo"
import SCons
import SCons.Action
diff --git a/engine/SCons/Script/__init__.py b/engine/SCons/Script/__init__.py
index 5b3eac8..c27dacd 100644
--- a/engine/SCons/Script/__init__.py
+++ b/engine/SCons/Script/__init__.py
@@ -12,7 +12,7 @@ it goes here.
"""
#
-# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -34,7 +34,7 @@ it goes here.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/__init__.py 2013/03/03 09:48:35 garyo"
+__revision__ = "src/engine/SCons/Script/__init__.py 2014/03/02 14:18:15 garyo"
import time
start_time = time.time()