"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "SCons/Script/SConsOptions.py" between
SCons-4.3.0.tar.gz and SCons-4.4.0.tar.gz

About: SCons is a software construction tool (a Python script and a set of modules as a superior alternative to the classic "Make" build tool).

SConsOptions.py  (SCons-4.3.0):SConsOptions.py  (SCons-4.4.0)
skipping to change at line 27 skipping to change at line 27
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import gettext import gettext
import optparse import optparse
import re import re
import shutil
import sys import sys
import textwrap import textwrap
import SCons.Node.FS import SCons.Node.FS
import SCons.Platform.virtualenv import SCons.Platform.virtualenv
import SCons.Warnings import SCons.Warnings
from . import Main from . import Main
no_hyphen_re = re.compile(r'(\s+|(?<=[\w!\"\'&.,?])-{2,}(?=\w))') no_hyphen_re = re.compile(r'(\s+|(?<=[\w!\"\'&.,?])-{2,}(?=\w))')
_ = gettext.gettext _ = gettext.gettext
skipping to change at line 147 skipping to change at line 148
'md5_chunksize', 'md5_chunksize',
'no_exec', 'no_exec',
'no_progress', 'no_progress',
'num_jobs', 'num_jobs',
'random', 'random',
'silent', 'silent',
'stack_size', 'stack_size',
'warn', 'warn',
# TODO: Remove these once we update the AddOption() API to allow setting # TODO: Remove these once we update the AddOption() API to allow setting
# added flag as setable. # added flag as settable.
# Requested setable flag in : https://github.com/SCons/scons/issues/3983 # Requested settable flag in : https://github.com/SCons/scons/issues/398
3
# From experimental ninja # From experimental ninja
'disable_execute_ninja', 'disable_execute_ninja',
'disable_ninja' 'disable_ninja',
'skip_ninja_regen'
] ]
def set_option(self, name, value): def set_option(self, name, value):
"""Sets an option from an SConscript file. """Sets an option from an SConscript file.
Raises: Raises:
UserError: invalid or malformed option ("error in your script") UserError: invalid or malformed option ("error in your script")
""" """
if name not in self.settable: if name not in self.settable:
skipping to change at line 239 skipping to change at line 241
if value: if value:
self.__SConscript_settings__['implicit_cache'] = True self.__SConscript_settings__['implicit_cache'] = True
self.__SConscript_settings__[name] = value self.__SConscript_settings__[name] = value
class SConsOption(optparse.Option): class SConsOption(optparse.Option):
def convert_value(self, opt, value): def convert_value(self, opt, value):
if value is not None: if value is not None:
if self.nargs in (1, '?'): if self.nargs in (1, '?'):
return self.check_value(opt, value) return self.check_value(opt, value)
else: return tuple([self.check_value(opt, v) for v in value])
return tuple([self.check_value(opt, v) for v in value])
def process(self, opt, value, values, parser): def process(self, opt, value, values, parser):
# First, convert the value(s) to the right type. Howl if any # First, convert the value(s) to the right type. Howl if any
# value(s) are bogus. # value(s) are bogus.
value = self.convert_value(opt, value) value = self.convert_value(opt, value)
# And then take whatever action is expected of us. # And then take whatever action is expected of us.
# This is a separate method to make life easier for # This is a separate method to make life easier for
# subclasses to add new actions. # subclasses to add new actions.
skipping to change at line 275 skipping to change at line 276
class SConsOptionGroup(optparse.OptionGroup): class SConsOptionGroup(optparse.OptionGroup):
""" """
A subclass for SCons-specific option groups. A subclass for SCons-specific option groups.
The only difference between this and the base class is that we print 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 the group's help text flush left, underneath their own title but
lined up with the normal "SCons Options". lined up with the normal "SCons Options".
""" """
def format_help(self, formatter): def format_help(self, formatter):
""" """ Format an option group's help text.
Format an option group's help text, outdenting the title so it's
flush with the "SCons Options" title we print at the top. The title is dedented so it's flush with the "SCons Options"
title we print at the top.
""" """
formatter.dedent() formatter.dedent()
result = formatter.format_heading(self.title) result = formatter.format_heading(self.title)
formatter.indent() formatter.indent()
result = result + optparse.OptionContainer.format_help(self, formatter) result = result + optparse.OptionContainer.format_help(self, formatter)
return result return result
class SConsOptionParser(optparse.OptionParser): class SConsOptionParser(optparse.OptionParser):
preserve_unknown_options = False preserve_unknown_options = False
def error(self, msg): def error(self, msg):
# overridden OptionValueError exception handler # overridden OptionValueError exception handler
self.print_usage(sys.stderr) self.print_usage(sys.stderr)
sys.stderr.write("SCons Error: %s\n" % msg) sys.stderr.write("SCons Error: %s\n" % msg)
sys.exit(2) sys.exit(2)
def _process_long_opt(self, rargs, values): def _process_long_opt(self, rargs, values):
""" """ SCons-specific processing of long options.
SCons-specific processing of long options.
This is copied directly from the normal This is copied directly from the normal
optparse._process_long_opt() method, except that, if configured ``optparse._process_long_opt()`` method, except that, if configured
to do so, we catch the exception thrown when an unknown option to do so, we catch the exception thrown when an unknown option
is encountered and just stick it back on the "leftover" arguments is encountered and just stick it back on the "leftover" arguments
for later (re-)processing. for later (re-)processing. This is because we may see the option
definition later, while processing SConscript files.
""" """
arg = rargs.pop(0) arg = rargs.pop(0)
# Value explicitly attached to arg? Pretend it's the next argument. # Value explicitly attached to arg? Pretend it's the next argument.
if "=" in arg: if "=" in arg:
(opt, next_arg) = arg.split("=", 1) (opt, next_arg) = arg.split("=", 1)
rargs.insert(0, next_arg) rargs.insert(0, next_arg)
had_explicit_value = True had_explicit_value = True
else: else:
opt = arg opt = arg
skipping to change at line 431 skipping to change at line 433
else: else:
rargs.append(l) rargs.append(l)
# Parse the filtered list # Parse the filtered list
self.parse_args(rargs, self.values) self.parse_args(rargs, self.values)
# Restore the list of remaining arguments for the # Restore the list of remaining arguments for the
# next call of AddOption/add_local_option... # next call of AddOption/add_local_option...
self.largs = self.largs + largs_restore self.largs = self.largs + largs_restore
def add_local_option(self, *args, **kw): def add_local_option(self, *args, **kw):
""" """ Adds a local option to the parser.
Adds a local option to the parser.
This is initiated by an AddOption() call to add a user-defined This is initiated by an :func:`AddOption` call to add a user-defined
command-line option. We add the option to a separate option command-line option. We add the option to a separate option
group for the local options, creating the group if necessary. group for the local options, creating the group if necessary.
""" """
try: try:
group = self.local_option_group group = self.local_option_group
except AttributeError: except AttributeError:
group = SConsOptionGroup(self, 'Local Options') group = SConsOptionGroup(self, 'Local Options')
group = self.add_option_group(group) group = self.add_option_group(group)
self.local_option_group = group self.local_option_group = group
skipping to change at line 463 skipping to change at line 464
# any value overridden on the command line is immediately # any value overridden on the command line is immediately
# available if the user turns around and does a GetOption() # available if the user turns around and does a GetOption()
# right away. # right away.
setattr(self.values.__defaults__, result.dest, result.default) setattr(self.values.__defaults__, result.dest, result.default)
self.reparse_local_options() self.reparse_local_options()
return result return result
class SConsIndentedHelpFormatter(optparse.IndentedHelpFormatter): class SConsIndentedHelpFormatter(optparse.IndentedHelpFormatter):
def format_usage(self, usage): def format_usage(self, usage):
""" Formats the usage message. """
return "usage: %s\n" % usage return "usage: %s\n" % usage
def format_heading(self, heading): def format_heading(self, heading):
""" """ Translates heading to "SCons Options"
This translates any heading of "options" or "Options" into
"SCons Options." Unfortunately, we have to do this here, Heading of "Options" changed to "SCons Options."
because those titles are hard-coded in the optparse calls. Unfortunately, we have to do this here, because those titles
are hard-coded in the optparse calls.
""" """
if heading == 'Options': if heading == 'Options':
heading = "SCons Options" heading = "SCons Options"
return optparse.IndentedHelpFormatter.format_heading(self, heading) return optparse.IndentedHelpFormatter.format_heading(self, heading)
def format_option(self, option): def format_option(self, option):
""" """ Customized option formatter.
A copy of the normal optparse.IndentedHelpFormatter.format_option()
A copy of the normal ``optparse.IndentedHelpFormatter.format_option()``
method. This has been snarfed so we can modify text wrapping to method. This has been snarfed so we can modify text wrapping to
out liking: our liking:
* add our own regular expression that doesn't break on hyphens
(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 :attr:`subsequent_indent` when wrapping the :attr:`help_text`.
The help for each option consists of two parts:
* the opt strings and metavars e.g. ("-x", or
"-fFILENAME, --file=FILENAME")
* the user-supplied help string e.g.
("turn on expert mode", "read data from FILENAME")
-- add our own regular expression that doesn't break on hyphens If possible, we write both of these on the same line::
(so things like --no-print-directory don't get broken);
-- wrap the list of options themselves when it's too long -x turn on expert mode
(the wrapper.fill(opts) call below);
-- set the subsequent_indent when wrapping the help_text. But if the opt string list is too long, we put the help
string on a second line, indented to the same column it would
start in if it fit on the first line::
-fFILENAME, --file=FILENAME
read data from FILENAME
""" """
# The help for each option consists of two parts:
# * the opt strings and metavars
# eg. ("-x", or "-fFILENAME, --file=FILENAME")
# * the user-supplied help string
# eg. ("turn on expert mode", "read data from FILENAME")
#
# If possible, we write both of these on the same line:
# -x turn on expert mode
#
# But if the opt string list is too long, we put the help
# string on a second line, indented to the same column it would
# start in if it fit on the first line.
# -fFILENAME, --file=FILENAME
# read data from FILENAME
result = [] result = []
opts = self.option_strings[option] opts = self.option_strings[option]
opt_width = self.help_position - self.current_indent - 2 opt_width = self.help_position - self.current_indent - 2
if len(opts) > opt_width: # SCons: pre-compute if we could combine opts and text on one line,
wrapper = textwrap.TextWrapper(width=self.width, # even if opts spills over opt_width. Saves some lines.
initial_indent=' ', # Note: check is currently disabled and this removed from docstring:
subsequent_indent=' ') # * if it would all fit on one line even if opts are long, don't break.
combine_anyway = False
if option.help:
help_text = self.expand_default(option)
# if len(opts) > opt_width and len(opts) + len(help_text) + 2 <= sel
f.width:
# combine_anyway = True
if len(opts) > opt_width and not combine_anyway:
# SCons: wrap options if needed
wrapper = textwrap.TextWrapper(
width=self.width, initial_indent=' ', subsequent_indent=' '
)
wrapper.wordsep_re = no_hyphen_re wrapper.wordsep_re = no_hyphen_re
opts = wrapper.fill(opts) + '\n' opts = wrapper.fill(opts) + '\n'
indent_first = self.help_position indent_first = self.help_position
else: # start help on same line as opts else: # start help on same line as opts
opts = "%*s%-*s " % (self.current_indent, "", opt_width, opts) opts = "%*s%-*s " % (self.current_indent, "", opt_width, opts)
indent_first = 0 indent_first = 0
result.append(opts) result.append(opts)
if option.help: if option.help:
# this is now done above in the pre-check.
help_text = self.expand_default(option) # help_text = self.expand_default(option)
# SCons: indent every line of the help text but the first.
# SCons: indent every line of the help text but the first. wrapper = textwrap.TextWrapper(
wrapper = textwrap.TextWrapper(width=self.help_width, width=self.help_width, subsequent_indent=' '
subsequent_indent=' ') )
wrapper.wordsep_re = no_hyphen_re wrapper.wordsep_re = no_hyphen_re
help_lines = wrapper.wrap(help_text) help_lines = wrapper.wrap(help_text)
result.append("%*s%s\n" % (indent_first, "", help_lines[0])) result.append("%*s%s\n" % (indent_first, "", help_lines[0]))
for line in help_lines[1:]: for line in help_lines[1:]:
result.append("%*s%s\n" % (self.help_position, "", line)) result.append("%*s%s\n" % (self.help_position, "", line))
elif opts[-1] != "\n": elif opts[-1] != "\n":
result.append("\n") result.append("\n")
return "".join(result) return "".join(result)
def Parser(version): def Parser(version):
""" """Returns a parser object initialized with the standard SCons options.
Returns an options parser object initialized with the standard
SCons options.
"""
formatter = SConsIndentedHelpFormatter(max_help_position=30)
op = SConsOptionParser(option_class=SConsOption,
add_help_option=False,
formatter=formatter,
usage="usage: scons [OPTION] [TARGET] ...",)
Add options in the order we want them to show up in the ``-H`` help
text, basically alphabetical. Each ``op.add_option()`` call
should have a consistent format::
op.add_option("-L", "--long-option-name",
nargs=1, type="string",
dest="long_option_name", default='foo',
action="callback", callback=opt_long_option,
help="help text goes here",
metavar="VAR")
Even though the :mod:`optparse` module constructs reasonable default
destination names from the long option names, we're going to be
explicit about each one for easier readability and so this code
will at least show up when grepping the source for option attribute
names, or otherwise browsing the source code.
"""
columns, lines = shutil.get_terminal_size()
formatter = SConsIndentedHelpFormatter(max_help_position=30, width=columns)
op = SConsOptionParser(
option_class=SConsOption,
add_help_option=False,
formatter=formatter,
usage="usage: scons [OPTIONS] [VARIABLES] [TARGETS]",
)
op.preserve_unknown_options = True op.preserve_unknown_options = True
op.version = version op.version = version
# Add the options to the parser we just created.
#
# These are in the order we want them to show up in the -H help
# text, basically alphabetical. Each op.add_option() call below
# should have a consistent format:
#
# op.add_option("-L", "--long-option-name",
# nargs=1, type="string",
# dest="long_option_name", default='foo',
# action="callback", callback=opt_long_option,
# help="help text goes here",
# metavar="VAR")
#
# Even though the optparse module constructs reasonable default
# destination names from the long option names, we're going to be
# explicit about each one for easier readability and so this code
# will at least show up when grepping the source for option attribute
# names, or otherwise browsing the source code.
# options ignored for compatibility # options ignored for compatibility
def opt_ignore(option, opt, value, parser): def opt_ignore(option, opt, value, parser):
sys.stderr.write("Warning: ignoring %s option\n" % opt) sys.stderr.write("Warning: ignoring %s option\n" % opt)
op.add_option("-b", "-d", "-e", "-m", "-S", "-t", "-w", op.add_option("-b", "-d", "-e", "-m", "-S", "-t", "-w",
"--environment-overrides", "--environment-overrides",
"--no-keep-going", "--no-keep-going",
"--no-print-directory", "--no-print-directory",
"--print-directory", "--print-directory",
"--stop", "--stop",
"--touch", "--touch",
action="callback", callback=opt_ignore, action="callback", callback=opt_ignore,
help="Ignored for compatibility.") help=SUPPRESS_HELP)
op.add_option('-c', '--clean', '--remove', op.add_option('-c', '--clean', '--remove',
dest="clean", default=False, dest="clean", default=False,
action="store_true", action="store_true",
help="Remove specified targets and dependencies.") help="Remove specified targets and dependencies")
op.add_option('-C', '--directory', op.add_option('-C', '--directory',
nargs=1, type="string", nargs=1, type="string",
dest="directory", default=[], dest="directory", default=[],
action="append", action="append",
help="Change to DIR before doing anything.", help="Change to DIR before doing anything",
metavar="DIR") metavar="DIR")
op.add_option('--cache-debug', op.add_option('--cache-debug',
nargs=1, nargs=1,
dest="cache_debug", default=None, dest="cache_debug", default=None,
action="store", action="store",
help="Print CacheDir debug info to FILE.", help="Print CacheDir debug info to FILE",
metavar="FILE") metavar="FILE")
op.add_option('--cache-disable', '--no-cache', op.add_option('--cache-disable', '--no-cache',
dest='cache_disable', default=False, dest='cache_disable', default=False,
action="store_true", action="store_true",
help="Do not retrieve built targets from CacheDir.") help="Do not retrieve built targets from CacheDir")
op.add_option('--cache-force', '--cache-populate', op.add_option('--cache-force', '--cache-populate',
dest='cache_force', default=False, dest='cache_force', default=False,
action="store_true", action="store_true",
help="Copy already-built targets into the CacheDir.") help="Copy already-built targets into the CacheDir")
op.add_option('--cache-readonly', op.add_option('--cache-readonly',
dest='cache_readonly', default=False, dest='cache_readonly', default=False,
action="store_true", action="store_true",
help="Do not update CacheDir with built targets.") help="Do not update CacheDir with built targets")
op.add_option('--cache-show', op.add_option('--cache-show',
dest='cache_show', default=False, dest='cache_show', default=False,
action="store_true", action="store_true",
help="Print build actions for files from CacheDir.") help="Print build actions for files from CacheDir")
def opt_invalid(group, value, options): def opt_invalid(group, value, options):
"""report an invalid option from a group""" """report an invalid option from a group"""
errmsg = "`%s' is not a valid %s option type, try:\n" % (value, group) errmsg = "`%s' is not a valid %s option type, try:\n" % (value, group)
return errmsg + " %s" % ", ".join(options) return errmsg + " %s" % ", ".join(options)
def opt_invalid_rm(group, value, msg): def opt_invalid_rm(group, value, msg):
"""report an invalid option from a group: recognized but removed""" """report an invalid option from a group: recognized but removed"""
errmsg = "`%s' is not a valid %s option type " % (value, group) errmsg = "`%s' is not a valid %s option type " % (value, group)
return errmsg + msg return errmsg + msg
config_options = ["auto", "force", "cache"] config_options = ["auto", "force", "cache"]
opt_config_help = "Controls Configure subsystem: %s." \ opt_config_help = "Controls Configure subsystem [%s]" \
% ", ".join(config_options) % ", ".join(config_options)
op.add_option('--config', op.add_option('--config',
nargs=1, choices=config_options, nargs=1, choices=config_options,
dest="config", default="auto", dest="config", default="auto",
help=opt_config_help, help=opt_config_help,
metavar="MODE") metavar="MODE")
op.add_option('-D', op.add_option('-D',
dest="climb_up", default=None, dest="climb_up", default=None,
action="store_const", const=2, action="store_const", const=2,
help="Search up directory tree for SConstruct, " help="Search up directory tree for SConstruct, "
"build all Default() targets.") "build all Default() targets")
deprecated_debug_options = {} deprecated_debug_options = {}
removed_debug_options = { removed_debug_options = {
"dtree": '; please use --tree=derived instead', "dtree": '; please use --tree=derived instead',
"nomemoizer": '; there is no replacement', "nomemoizer": '; there is no replacement',
"stree": '; please use --tree=all,status instead', "stree": '; please use --tree=all,status instead',
"tree": '; please use --tree=all instead', "tree": '; please use --tree=all instead',
} }
skipping to change at line 686 skipping to change at line 698
w = "The --debug=%s option is deprecated%s." % (value, msg) w = "The --debug=%s option is deprecated%s." % (value, msg)
t = (SCons.Warnings.DeprecatedDebugOptionsWarning, w) t = (SCons.Warnings.DeprecatedDebugOptionsWarning, w)
parser.values.delayed_warnings.append(t) parser.values.delayed_warnings.append(t)
elif value in removed_debug_options: elif value in removed_debug_options:
msg = removed_debug_options[value] msg = removed_debug_options[value]
raise OptionValueError(opt_invalid_rm('debug', value, msg)) raise OptionValueError(opt_invalid_rm('debug', value, msg))
else: else:
raise OptionValueError(opt_invalid( raise OptionValueError(opt_invalid(
'debug', value, debug_options)) 'debug', value, debug_options))
opt_debug_help = "Print various types of debugging information: %s." \ opt_debug_help = "Print various types of debugging information [%s]" \
% ", ".join(debug_options) % ", ".join(debug_options)
op.add_option('--debug', op.add_option('--debug',
nargs=1, type="string", nargs=1, type="string",
dest="debug", default=[], dest="debug", default=[],
action="callback", callback=opt_debug, action="callback", callback=opt_debug,
help=opt_debug_help, help=opt_debug_help,
metavar="TYPE") metavar="TYPE")
def opt_diskcheck(option, opt, value, parser): def opt_diskcheck(option, opt, value, parser):
try: try:
diskcheck_value = diskcheck_convert(value) diskcheck_value = diskcheck_convert(value)
except ValueError as e: except ValueError as e:
raise OptionValueError("`%s' is not a valid diskcheck type" % e) raise OptionValueError("`%s' is not a valid diskcheck type" % e)
setattr(parser.values, option.dest, diskcheck_value) setattr(parser.values, option.dest, diskcheck_value)
op.add_option('--diskcheck', op.add_option('--diskcheck',
nargs=1, type="string", nargs=1, type="string",
dest='diskcheck', default=None, dest='diskcheck', default=None,
action="callback", callback=opt_diskcheck, action="callback", callback=opt_diskcheck,
help="Enable specific on-disk checks.", help="Enable specific on-disk checks",
metavar="TYPE") metavar="TYPE")
def opt_duplicate(option, opt, value, parser): def opt_duplicate(option, opt, value, parser):
if value not in SCons.Node.FS.Valid_Duplicates: if value not in SCons.Node.FS.Valid_Duplicates:
raise OptionValueError(opt_invalid('duplication', value, raise OptionValueError(opt_invalid('duplication', value,
SCons.Node.FS.Valid_Duplicates)) SCons.Node.FS.Valid_Duplicates))
setattr(parser.values, option.dest, value) setattr(parser.values, option.dest, value)
# Set the duplicate style right away so it can affect linking # Set the duplicate style right away so it can affect linking
# of SConscript files. # of SConscript files.
SCons.Node.FS.set_duplicate(value) SCons.Node.FS.set_duplicate(value)
opt_duplicate_help = "Set the preferred duplication methods. Must be one of opt_duplicate_help = "Set the preferred duplication methods [%s]" \
" \ % ", ".join(SCons.Node.FS.Valid_Duplicates)
+ ", ".join(SCons.Node.FS.Valid_Duplicates)
op.add_option('--duplicate', op.add_option('--duplicate',
nargs=1, type="string", nargs=1, type="string",
dest="duplicate", default='hard-soft-copy', dest="duplicate", default='hard-soft-copy',
action="callback", callback=opt_duplicate, action="callback", callback=opt_duplicate,
help=opt_duplicate_help) help=opt_duplicate_help)
if not SCons.Platform.virtualenv.virtualenv_enabled_by_default: if not SCons.Platform.virtualenv.virtualenv_enabled_by_default:
op.add_option('--enable-virtualenv', op.add_option('--enable-virtualenv',
dest="enable_virtualenv", dest="enable_virtualenv",
skipping to change at line 770 skipping to change at line 782
default=set(), # empty set default=set(), # empty set
type='str', type='str',
# choices=experimental_options+experimental_features, # choices=experimental_options+experimental_features,
callback=experimental_callback, callback=experimental_callback,
help='Enable experimental features') help='Enable experimental features')
op.add_option('-f', '--file', '--makefile', '--sconstruct', op.add_option('-f', '--file', '--makefile', '--sconstruct',
nargs=1, type="string", nargs=1, type="string",
dest="file", default=[], dest="file", default=[],
action="append", action="append",
help="Read FILE as the top-level SConstruct file.") help="Read FILE as the top-level SConstruct file")
op.add_option('-h', '--help', op.add_option('-h', '--help',
dest="help", default=False, dest="help", default=False,
action="store_true", action="store_true",
help="Print defined help message, or this one.") help="Print defined help message, or this one")
op.add_option("-H", "--help-options", op.add_option("-H", "--help-options",
action="help", action="help",
help="Print this message and exit.") help="Print this message and exit")
def warn_md5_chunksize_deprecated(option, opt, value, parser): def warn_md5_chunksize_deprecated(option, opt, value, parser):
if opt == '--md5-chunksize': if opt == '--md5-chunksize':
SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning, SCons.Warnings.warn(SCons.Warnings.DeprecatedWarning,
"Parameter %s is deprecated. Use " "Parameter %s is deprecated. Use "
"--hash-chunksize instead." % opt) "--hash-chunksize instead." % opt)
setattr(parser.values, option.dest, value) setattr(parser.values, option.dest, value)
op.add_option('--hash-chunksize', '--md5-chunksize', op.add_option('--hash-chunksize', '--md5-chunksize',
nargs=1, type="int", nargs=1, type="int",
dest='md5_chunksize', default=SCons.Node.FS.File.hash_chunksiz e, dest='md5_chunksize', default=SCons.Node.FS.File.hash_chunksiz e,
action="callback", action="callback",
help="Set chunk-size for hash signature computation to N kilob ytes.", help="Set chunk-size for hash signature computation to N kilob ytes",
callback=warn_md5_chunksize_deprecated, callback=warn_md5_chunksize_deprecated,
metavar="N") metavar="N")
op.add_option('--hash-format', op.add_option('--hash-format',
dest='hash_format', dest='hash_format',
action='store', action='store',
help='Hash format (e.g. md5, sha1, or sha256).') help='Hash format [md5, sha1, sha256, etc].')
op.add_option('-i', '--ignore-errors', op.add_option('-i', '--ignore-errors',
dest='ignore_errors', default=False, dest='ignore_errors', default=False,
action="store_true", action="store_true",
help="Ignore errors from build actions.") help="Ignore errors from build actions")
op.add_option('-I', '--include-dir', op.add_option('-I', '--include-dir',
nargs=1, nargs=1,
dest='include_dir', default=[], dest='include_dir', default=[],
action="append", action="append",
help="Search DIR for imported Python modules.", help="Search DIR for imported Python modules",
metavar="DIR") metavar="DIR")
op.add_option('--ignore-virtualenv', op.add_option('--ignore-virtualenv',
dest="ignore_virtualenv", dest="ignore_virtualenv",
action="store_true", action="store_true",
help="Do not import virtualenv variables to SCons") help="Do not import virtualenv variables to SCons")
op.add_option('--implicit-cache', op.add_option('--implicit-cache',
dest='implicit_cache', default=False, dest='implicit_cache', default=False,
action="store_true", action="store_true",
help="Cache implicit dependencies") help="Cache implicit dependencies")
def opt_implicit_deps(option, opt, value, parser): def opt_implicit_deps(option, opt, value, parser):
setattr(parser.values, 'implicit_cache', True) setattr(parser.values, 'implicit_cache', True)
setattr(parser.values, option.dest, True) setattr(parser.values, option.dest, True)
op.add_option('--implicit-deps-changed', op.add_option('--implicit-deps-changed',
dest="implicit_deps_changed", default=False, dest="implicit_deps_changed", default=False,
action="callback", callback=opt_implicit_deps, action="callback", callback=opt_implicit_deps,
help="Ignore cached implicit dependencies.") help="Ignore cached implicit dependencies")
op.add_option('--implicit-deps-unchanged', op.add_option('--implicit-deps-unchanged',
dest="implicit_deps_unchanged", default=False, dest="implicit_deps_unchanged", default=False,
action="callback", callback=opt_implicit_deps, action="callback", callback=opt_implicit_deps,
help="Ignore changes in implicit dependencies.") help="Ignore changes in implicit dependencies")
op.add_option('--interact', '--interactive', op.add_option('--interact', '--interactive',
dest='interactive', default=False, dest='interactive', default=False,
action="store_true", action="store_true",
help="Run in interactive mode.") help="Run in interactive mode")
op.add_option('-j', '--jobs', op.add_option('-j', '--jobs',
nargs=1, type="int", nargs=1, type="int",
dest="num_jobs", default=1, dest="num_jobs", default=1,
action="store", action="store",
help="Allow N jobs at once.", help="Allow N jobs at once",
metavar="N") metavar="N")
op.add_option('-k', '--keep-going', op.add_option('-k', '--keep-going',
dest='keep_going', default=False, dest='keep_going', default=False,
action="store_true", action="store_true",
help="Keep going when a target can't be made.") help="Keep going when a target can't be made")
op.add_option('--max-drift', op.add_option('--max-drift',
nargs=1, type="int", nargs=1, type="int",
dest='max_drift', default=SCons.Node.FS.default_max_drift, dest='max_drift', default=SCons.Node.FS.default_max_drift,
action="store", action="store",
help="Set maximum system clock drift to N seconds.", help="Set maximum system clock drift to N seconds",
metavar="N") metavar="N")
op.add_option('-n', '--no-exec', '--just-print', '--dry-run', '--recon', op.add_option('-n', '--no-exec', '--just-print', '--dry-run', '--recon',
dest='no_exec', default=False, dest='no_exec', default=False,
action="store_true", action="store_true",
help="Don't build; just print commands.") help="Don't build; just print commands")
op.add_option('--no-site-dir', op.add_option('--no-site-dir',
dest='site_dir', dest='site_dir',
action="store_false", action="store_false",
help="Don't search or use the usual site_scons dir.") help="Don't search or use the usual site_scons dir")
op.add_option('--profile', op.add_option('--profile',
nargs=1, nargs=1,
dest="profile_file", default=None, dest="profile_file", default=None,
action="store", action="store",
help="Profile SCons and put results in FILE.", help="Profile SCons and put results in FILE",
metavar="FILE") metavar="FILE")
op.add_option('-q', '--question', op.add_option('-q', '--question',
dest="question", default=False, dest="question", default=False,
action="store_true", action="store_true",
help="Don't build; exit status says if up to date.") help="Don't build; exit status says if up to date")
op.add_option('-Q', op.add_option('-Q',
dest='no_progress', default=False, dest='no_progress', default=False,
action="store_true", action="store_true",
help="Suppress \"Reading/Building\" progress messages.") help="Suppress \"Reading/Building\" progress messages")
op.add_option('--random', op.add_option('--random',
dest="random", default=False, dest="random", default=False,
action="store_true", action="store_true",
help="Build dependencies in random order.") help="Build dependencies in random order")
op.add_option('-s', '--silent', '--quiet', op.add_option('-s', '--silent', '--quiet',
dest="silent", default=False, dest="silent", default=False,
action="store_true", action="store_true",
help="Don't print commands.") help="Don't print commands")
op.add_option('--site-dir', op.add_option('--site-dir',
nargs=1, nargs=1,
dest='site_dir', default=None, dest='site_dir', default=None,
action="store", action="store",
help="Use DIR instead of the usual site_scons dir.", help="Use DIR instead of the usual site_scons dir",
metavar="DIR") metavar="DIR")
op.add_option('--stack-size', op.add_option('--stack-size',
nargs=1, type="int", nargs=1, type="int",
dest='stack_size', dest='stack_size',
action="store", action="store",
help="Set the stack size of the threads used to run jobs to N kilobytes.", help="Set the stack size of the threads used to run jobs to N kilobytes",
metavar="N") metavar="N")
op.add_option('--taskmastertrace', op.add_option('--taskmastertrace',
nargs=1, nargs=1,
dest="taskmastertrace_file", default=None, dest="taskmastertrace_file", default=None,
action="store", action="store",
help="Trace Node evaluation to FILE.", help="Trace Node evaluation to FILE",
metavar="FILE") metavar="FILE")
tree_options = ["all", "derived", "prune", "status", "linedraw"] tree_options = ["all", "derived", "prune", "status", "linedraw"]
def opt_tree(option, opt, value, parser, tree_options=tree_options): def opt_tree(option, opt, value, parser, tree_options=tree_options):
tp = Main.TreePrinter() tp = Main.TreePrinter()
for o in value.split(','): for o in value.split(','):
if o == 'all': if o == 'all':
tp.derived = False tp.derived = False
elif o == 'derived': elif o == 'derived':
skipping to change at line 939 skipping to change at line 951
elif o == 'prune': elif o == 'prune':
tp.prune = True tp.prune = True
elif o == 'status': elif o == 'status':
tp.status = True tp.status = True
elif o == 'linedraw': elif o == 'linedraw':
tp.sLineDraw = True tp.sLineDraw = True
else: else:
raise OptionValueError(opt_invalid('--tree', o, tree_options)) raise OptionValueError(opt_invalid('--tree', o, tree_options))
parser.values.tree_printers.append(tp) parser.values.tree_printers.append(tp)
opt_tree_help = "Print a dependency tree in various formats: %s." \ opt_tree_help = "Print a dependency tree in various formats [%s]" \
% ", ".join(tree_options) % ", ".join(tree_options)
op.add_option('--tree', op.add_option('--tree',
nargs=1, type="string", nargs=1, type="string",
dest="tree_printers", default=[], dest="tree_printers", default=[],
action="callback", callback=opt_tree, action="callback", callback=opt_tree,
help=opt_tree_help, help=opt_tree_help,
metavar="OPTIONS") metavar="OPTIONS")
op.add_option('-u', '--up', '--search-up', op.add_option('-u', '--up', '--search-up',
dest="climb_up", default=0, dest="climb_up", default=0,
action="store_const", const=1, action="store_const", const=1,
help="Search up directory tree for SConstruct, " help="Search up directory tree for SConstruct, "
"build targets at or below current directory.") "build targets at or below current directory")
op.add_option('-U', op.add_option('-U',
dest="climb_up", default=0, dest="climb_up", default=0,
action="store_const", const=3, action="store_const", const=3,
help="Search up directory tree for SConstruct, " help="Search up directory tree for SConstruct, "
"build Default() targets from local SConscript.") "build Default() targets from local SConscript")
def opt_version(option, opt, value, parser): def opt_version(option, opt, value, parser):
sys.stdout.write(parser.version + '\n') sys.stdout.write(parser.version + '\n')
sys.exit(0) sys.exit(0)
op.add_option("-v", "--version", op.add_option("-v", "--version",
action="callback", callback=opt_version, action="callback", callback=opt_version,
help="Print the SCons version number and exit.") help="Print the SCons version number and exit")
def opt_warn(option, opt, value, parser, tree_options=tree_options): def opt_warn(option, opt, value, parser, tree_options=tree_options):
if SCons.Util.is_String(value): if SCons.Util.is_String(value):
value = value.split(',') value = value.split(',')
parser.values.warn.extend(value) parser.values.warn.extend(value)
op.add_option('--warn', '--warning', op.add_option('--warn', '--warning',
nargs=1, type="string", nargs=1, type="string",
dest="warn", default=[], dest="warn", default=[],
action="callback", callback=opt_warn, action="callback", callback=opt_warn,
help="Enable or disable warnings.", help="Enable or disable warnings",
metavar="WARNING-SPEC") metavar="WARNING-SPEC")
op.add_option('-Y', '--repository', '--srcdir', op.add_option('-Y', '--repository', '--srcdir',
nargs=1, nargs=1,
dest="repository", default=[], dest="repository", default=[],
action="append", action="append",
help="Search REPOSITORY for source and target files.") help="Search REPOSITORY for source and target files")
# Options from Make and Cons classic that we do not yet support, # Options from Make and Cons classic that we do not yet support,
# but which we may support someday and whose (potential) meanings # but which we may support someday and whose (potential) meanings
# we don't want to change. These all get a "the -X option is not # we don't want to change. These all get a "the -X option is not
# yet implemented" message and don't show up in the help output. # yet implemented" message and don't show up in the help output.
def opt_not_yet(option, opt, value, parser): def opt_not_yet(option, opt, value, parser):
msg = "Warning: the %s option is not yet implemented\n" % opt msg = "Warning: the %s option is not yet implemented\n" % opt
sys.stderr.write(msg) sys.stderr.write(msg)
op.add_option('-l', '--load-average', '--max-load', op.add_option('-l', '--load-average', '--max-load',
nargs=1, type="float", nargs=1, type="float",
dest="load_average", default=0, dest="load_average", default=0,
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
# action="store", # action="store",
# help="Don't start multiple jobs unless load is below " # help="Don't start multiple jobs unless load is below "
# "LOAD-AVERAGE." # "LOAD-AVERAGE"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
op.add_option('--list-actions', op.add_option('--list-actions',
dest="list_actions", dest="list_actions",
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
# help="Don't build; list files and build actions." # help="Don't build; list files and build actions"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
op.add_option('--list-derived', op.add_option('--list-derived',
dest="list_derived", dest="list_derived",
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
# help="Don't build; list files that would be built." # help="Don't build; list files that would be built"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
op.add_option('--list-where', op.add_option('--list-where',
dest="list_where", dest="list_where",
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
# help="Don't build; list files and where defined." # help="Don't build; list files and where defined"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
op.add_option('-o', '--old-file', '--assume-old', op.add_option('-o', '--old-file', '--assume-old',
nargs=1, type="string", nargs=1, type="string",
dest="old_file", default=[], dest="old_file", default=[],
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
# action="append", # action="append",
# help = "Consider FILE to be old; don't rebuild it." # help = "Consider FILE to be old; don't rebuild it"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
op.add_option('--override', op.add_option('--override',
nargs=1, type="string", nargs=1, type="string",
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
dest="override", dest="override",
# help="Override variables as specified in FILE." # help="Override variables as specified in FILE"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
op.add_option('-p', op.add_option('-p',
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
dest="p", dest="p",
# help="Print internal environments/objects." # help="Print internal environments/objects"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
op.add_option('-r', '-R', '--no-builtin-rules', '--no-builtin-variables', op.add_option('-r', '-R', '--no-builtin-rules', '--no-builtin-variables',
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
dest="no_builtin_rules", dest="no_builtin_rules",
# help="Clear default environments and variables." # help="Clear default environments and variables"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
op.add_option('--write-filenames', op.add_option('--write-filenames',
nargs=1, type="string", nargs=1, type="string",
dest="write_filenames", dest="write_filenames",
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
# help="Write all filenames examined into FILE." # help="Write all filenames examined into FILE"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
op.add_option('-W', '--new-file', '--assume-new', '--what-if', op.add_option('-W', '--new-file', '--assume-new', '--what-if',
nargs=1, type="string", nargs=1, type="string",
dest="new_file", dest="new_file",
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
# help="Consider FILE to be changed." # help="Consider FILE to be changed"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
op.add_option('--warn-undefined-variables', op.add_option('--warn-undefined-variables',
dest="warn_undefined_variables", dest="warn_undefined_variables",
action="callback", callback=opt_not_yet, action="callback", callback=opt_not_yet,
# help="Warn when an undefined variable is referenced." # help="Warn when an undefined variable is referenced"
help=SUPPRESS_HELP) help=SUPPRESS_HELP)
return op return op
# Local Variables: # Local Variables:
# tab-width:4 # tab-width:4
# indent-tabs-mode:nil # indent-tabs-mode:nil
# End: # End:
# vim: set expandtab tabstop=4 shiftwidth=4: # vim: set expandtab tabstop=4 shiftwidth=4:
 End of changes. 79 change blocks. 
140 lines changed or deleted 154 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)