summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Script
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Script')
-rw-r--r--src/engine/SCons/Script/Interactive.py4
-rw-r--r--src/engine/SCons/Script/Main.py91
-rw-r--r--src/engine/SCons/Script/SConsOptions.py51
-rw-r--r--src/engine/SCons/Script/SConscript.py14
-rw-r--r--src/engine/SCons/Script/__init__.py1
5 files changed, 85 insertions, 76 deletions
diff --git a/src/engine/SCons/Script/Interactive.py b/src/engine/SCons/Script/Interactive.py
index e38c400..d18eec1 100644
--- a/src/engine/SCons/Script/Interactive.py
+++ b/src/engine/SCons/Script/Interactive.py
@@ -217,12 +217,12 @@ class SConsInteractiveCmd(cmd.Cmd):
def add_to_seen_nodes(node, parent, seen_nodes=seen_nodes):
seen_nodes[node] = 1
- # If this file is in a BuildDir and has a
+ # If this file is in a VariantDir and has a
# corresponding source file in the source tree, remember the
# node in the source tree, too. This is needed in
# particular to clear cached implicit dependencies on the
# source file, since the scanner will scan it if the
- # BuildDir was created with duplicate=0.
+ # VariantDir was created with duplicate=0.
try:
rfile_method = node.rfile
except AttributeError:
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index bcbd0a1..80b9032 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -404,6 +404,16 @@ class TreePrinter:
SCons.Util.print_tree(t, func, prune=self.prune, showtags=s)
+def python_version_string():
+ return string.split(sys.version)[0]
+
+def python_version_unsupported(version=sys.version_info):
+ return version < (1, 5, 2)
+
+def python_version_deprecated(version=sys.version_info):
+ return version < (2, 2, 0)
+
+
# Global variables
print_objects = 0
@@ -578,51 +588,6 @@ def _scons_internal_error():
traceback.print_exc()
sys.exit(2)
-def _setup_warn(arg):
- """The --warn option. An argument to this option
- should be of the form <warning-class> or no-<warning-class>.
- The warning class is munged in order to get an actual class
- name from the SCons.Warnings module to enable or disable.
- The supplied <warning-class> is split on hyphens, each element
- is captialized, then smushed back together. Then the string
- "SCons.Warnings." is added to the front and "Warning" is added
- to the back to get the fully qualified class name.
-
- For example, --warn=deprecated will enable the
- SCons.Warnings.DeprecatedWarning class.
-
- --warn=no-dependency will disable the
- SCons.Warnings.DependencyWarning class.
-
- As a special case, --warn=all and --warn=no-all
- will enable or disable (respectively) the base
- class of all warnings, which is SCons.Warning.Warning."""
-
- elems = string.split(string.lower(arg), '-')
- enable = 1
- if elems[0] == 'no':
- enable = 0
- del elems[0]
-
- if len(elems) == 1 and elems[0] == 'all':
- class_name = "Warning"
- else:
- def _capitalize(s):
- if s[:5] == "scons":
- return "SCons" + s[5:]
- else:
- return string.capitalize(s)
- class_name = string.join(map(_capitalize, elems), '') + "Warning"
- try:
- clazz = getattr(SCons.Warnings, class_name)
- except AttributeError:
- sys.stderr.write("No warning type: '%s'\n" % arg)
- else:
- if enable:
- SCons.Warnings.enableWarningClass(clazz)
- else:
- SCons.Warnings.suppressWarningClass(clazz)
-
def _SConstruct_exists(dirname='', repositories=[]):
"""This function checks that an SConstruct file exists in a directory.
If so, it returns the path of the file. By default, it checks the
@@ -766,8 +731,7 @@ def _main(parser):
for warning in default_warnings:
SCons.Warnings.enableWarningClass(warning)
SCons.Warnings._warningOut = _scons_internal_warning
- if options.warn:
- _setup_warn(options.warn)
+ SCons.Warnings.process_warn_strings(options.warn)
# Now that we have the warnings configuration set up, we can actually
# issue (or suppress) any warnings about warning-worthy things that
@@ -912,7 +876,7 @@ def _main(parser):
SCons.Script._SConscript._SConscript(fs, script)
except SCons.Errors.StopError, e:
# We had problems reading an SConscript file, such as it
- # couldn't be copied in to the BuildDir. Since we're just
+ # couldn't be copied in to the VariantDir. Since we're just
# reading SConscript files and haven't started building
# things yet, stop regardless of whether they used -i or -k
# or anything else.
@@ -927,6 +891,26 @@ def _main(parser):
memory_stats.append('after reading SConscript files:')
count_stats.append(('post-', 'read'))
+ # Re-{enable,disable} warnings in case they disabled some in
+ # the SConscript file.
+ #
+ # We delay enabling the PythonVersionWarning class until here so that,
+ # if they explicity disabled it in either in the command line or in
+ # $SCONSFLAGS, or in the SConscript file, then the search through
+ # the list of deprecated warning classes will find that disabling
+ # first and not issue the warning.
+ SCons.Warnings.enableWarningClass(SCons.Warnings.PythonVersionWarning)
+ SCons.Warnings.process_warn_strings(options.warn)
+
+ # Now that we've read the SConscript files, we can check for the
+ # warning about deprecated Python versions--delayed until here
+ # in case they disabled the warning in the SConscript files.
+ if python_version_deprecated():
+ msg = "Support for pre-2.2 Python (%s) is deprecated.\n" + \
+ " If this will cause hardship, contact dev@scons.tigris.org."
+ SCons.Warnings.warn(SCons.Warnings.PythonVersionWarning,
+ msg % python_version_string())
+
if not options.help:
SCons.SConf.CreateConfigHBuilder(SCons.Defaults.DefaultEnvironment())
@@ -953,7 +937,7 @@ def _main(parser):
# Change directory to the top-level SConstruct directory, then tell
# the Node.FS subsystem that we're all done reading the SConscript
- # files and calling Repository() and BuildDir() and changing
+ # files and calling Repository() and VariantDir() and changing
# directories and the like, so it can go ahead and start memoizing
# the string values of file system nodes.
@@ -1215,6 +1199,15 @@ def main():
global exit_status
global first_command_start
+ # Check up front for a Python version we do not support. We
+ # delay the check for deprecated Python versions until later,
+ # after the SConscript files have been read, in case they
+ # disable that warning.
+ if python_version_unsupported():
+ msg = "scons: *** SCons version %s does not run under Python version %s.\n"
+ sys.stderr.write(msg % (SCons.__version__, python_version_string()))
+ sys.exit(1)
+
parts = ["SCons by Steven Knight et al.:\n"]
try:
parts.append(version_string("script", __main__))
diff --git a/src/engine/SCons/Script/SConsOptions.py b/src/engine/SCons/Script/SConsOptions.py
index 8f7116d..ee34a85 100644
--- a/src/engine/SCons/Script/SConsOptions.py
+++ b/src/engine/SCons/Script/SConsOptions.py
@@ -38,6 +38,7 @@ except ImportError:
_ = gettext
import SCons.Node.FS
+import SCons.Warnings
OptionValueError = optparse.OptionValueError
SUPPRESS_HELP = optparse.SUPPRESS_HELP
@@ -123,6 +124,7 @@ class SConsValues(optparse.Values):
'num_jobs',
'random',
'stack_size',
+ 'warn',
]
def set_option(self, name, value):
@@ -169,6 +171,11 @@ class SConsValues(optparse.Values):
value = int(value)
except ValueError:
raise SCons.Errors.UserError, "An integer is required: %s"%repr(value)
+ elif name == 'warn':
+ if SCons.Util.is_String(value):
+ value = [value]
+ value = self.__SConscript_settings__.get(name, []) + value
+ SCons.Warnings.process_warn_strings(value)
self.__SConscript_settings__[name] = value
@@ -563,29 +570,32 @@ def Parser(version):
help="Search up directory tree for SConstruct, "
"build all Default() targets.")
- debug_options = ["count", "dtree", "explain", "findlibs",
- "includes", "memoizer", "memory", "objects",
- "pdb", "presub", "stacktrace", "stree",
- "time", "tree"]
-
deprecated_debug_options = {
- "nomemoizer" : ' and has no effect',
+ "dtree" : '; please use --tree=derived instead',
+ "nomemoizer" : ' and has no effect',
+ "stree" : '; please use --tree=all,status instead',
+ "tree" : '; please use --tree=all instead',
}
+ debug_options = ["count", "explain", "findlibs",
+ "includes", "memoizer", "memory", "objects",
+ "pdb", "presub", "stacktrace",
+ "time"] + deprecated_debug_options.keys()
+
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():
- 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.DeprecatedWarning, w)
- parser.values.delayed_warnings.append(t)
+ if value in deprecated_debug_options.keys():
+ 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.DeprecatedWarning, w)
+ parser.values.delayed_warnings.append(t)
else:
raise OptionValueError("Warning: %s is not a valid debug type" % value)
opt_debug_help = "Print various types of debugging information: %s." \
@@ -803,10 +813,15 @@ def Parser(version):
action="callback", callback=opt_version,
help="Print the SCons version number and exit.")
+ def opt_warn(option, opt, value, parser, tree_options=tree_options):
+ if SCons.Util.is_String(value):
+ value = string.split(value, ',')
+ parser.values.warn.extend(value)
+
op.add_option('--warn', '--warning',
- nargs=1,
- dest="warn", default=None,
- action="store",
+ nargs=1, type="string",
+ dest="warn", default=[],
+ action="callback", callback=opt_warn,
help="Enable or disable warnings.",
metavar="WARNING-SPEC")
diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py
index 5278d40..36a147d 100644
--- a/src/engine/SCons/Script/SConscript.py
+++ b/src/engine/SCons/Script/SConscript.py
@@ -403,16 +403,16 @@ class SConsEnvironment(SCons.Environment.Base):
if kw.get('exports'):
exports.extend(self.Split(kw['exports']))
- build_dir = kw.get('build_dir')
- if build_dir:
+ variant_dir = kw.get('variant_dir') or kw.get('build_dir')
+ if variant_dir:
if len(files) != 1:
raise SCons.Errors.UserError, \
- "Invalid SConscript() usage - can only specify one SConscript with a build_dir"
+ "Invalid SConscript() usage - can only specify one SConscript with a variant_dir"
duplicate = kw.get('duplicate', 1)
src_dir = kw.get('src_dir')
if not src_dir:
src_dir, fname = os.path.split(str(files[0]))
- files = [os.path.join(str(build_dir), fname)]
+ files = [os.path.join(str(variant_dir), fname)]
else:
if not isinstance(src_dir, SCons.Node.Node):
src_dir = self.fs.Dir(src_dir)
@@ -422,11 +422,11 @@ class SConsEnvironment(SCons.Environment.Base):
if fn.is_under(src_dir):
# Get path relative to the source directory.
fname = fn.get_path(src_dir)
- files = [os.path.join(str(build_dir), fname)]
+ files = [os.path.join(str(variant_dir), fname)]
else:
files = [fn.abspath]
- kw['src_dir'] = build_dir
- self.fs.BuildDir(build_dir, src_dir, duplicate)
+ kw['src_dir'] = variant_dir
+ self.fs.VariantDir(variant_dir, src_dir, duplicate)
return (files, exports)
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 44f01b8..ddeaf9e 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -321,6 +321,7 @@ GlobalDefaultEnvironmentFunctions = [
'Tag',
'TargetSignatures',
'Value',
+ 'VariantDir',
]
GlobalDefaultBuilders = [