.IP SHOBJSUFFIX
The suffix used for shared object file names.
+.IP SOURCE
+A reserved variable name
+that may not be set or used in a construction environment.
+(See "Variable Substitution," below.)
+
+.IP SOURCES
+A reserved variable name
+that may not be set or used in a construction environment.
+(See "Variable Substitution," below.)
+
.IP SPAWN
A command interpreter function that will be called to execute command line
strings. The function must expect 4 arguments:
.IP TARFLAGS
General options passed to the tar archiver.
+.IP TARGET
+A reserved variable name
+that may not be set or used in a construction environment.
+(See "Variable Substitution," below.)
+
+.IP TARGETS
+A reserved variable name
+that may not be set or used in a construction environment.
+(See "Variable Substitution," below.)
+
.IP TARSUFFIX
The suffix used for tar file names.
.IP SOURCES
The file names of the sources of the build command.
+(Note that the above variables are reserved
+and may not be set in a construction environment.)
+
.LP
For example, given the construction variable CC='cc', targets=['foo'], and
sources=['foo.c', 'bar.c']:
- Make the error message the same as other build errors when there's a
problem unlinking a target file in preparation for it being built.
+ - Make TARGET, TARGETS, SOURCE and SOURCES reserved variable names and
+ warn if the user tries to set them in a construction environment.
+
RELEASE 0.11 - Tue, 11 Feb 2003 05:24:33 -0600
return dlist
def __setitem__(self, key, value):
- if key == 'BUILDERS':
+ if key == 'TARGET' or \
+ key == 'TARGETS' or \
+ key == 'SOURCE' or \
+ key == 'SOURCES':
+ SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning,
+ "Ignoring attempt to set reserved variable `%s'" % key)
+ elif key == 'BUILDERS':
try:
bd = self._dict[key]
for k in bd.keys():
for tnode in tgt:
assert tnode.builder == InstallBuilder
+ def test_ReservedVariables(self):
+ """Test generation of warnings when reserved variable names
+ are set in an environment."""
+
+ SCons.Warnings.enableWarningClass(SCons.Warnings.ReservedVariableWarning)
+ old = SCons.Warnings.warningAsException(1)
+
+ try:
+ env4 = Environment()
+ for kw in ['TARGET', 'TARGETS', 'SOURCE', 'SOURCES']:
+ exc_caught = None
+ try:
+ env4[kw] = 'xyzzy'
+ except SCons.Warnings.ReservedVariableWarning:
+ exc_caught = 1
+ assert exc_caught, "Did not catch ReservedVariableWarning for `%s'" % kw
+ assert not env4.has_key(kw), "`%s' variable was incorrectly set" % kw
+ finally:
+ SCons.Warnings.warningAsException(old)
+
def test_Replace(self):
"""Test replacing construction variables in an Environment
class CorruptSConsignWarning(Warning):
pass
+class ReservedVariableWarning(Warning):
+ pass
+
_warningAsException = 0
# The below is a list of 2-tuples. The first element is a class object.
_enabled.insert(0, (clazz, 1))
def warningAsException(flag=1):
+ """Turn warnings into exceptions. Returns the old value of the flag."""
global _warningAsException
+ old = _warningAsException
_warningAsException = flag
+ return old
def warn(clazz, *args):
global _enabled, _warningAsException, _warningOut
SCons.Warnings._warningAsException = 0
SCons.Warnings.enableWarningClass(SCons.Warnings.Warning)
- SCons.Warnings.warningAsException()
+ old = SCons.Warnings.warningAsException()
+ assert old == 0, old
+ exc_caught = 0
try:
SCons.Warnings.warn(SCons.Warnings.Warning, "Foo")
except:
- pass
- else:
- assert 0
+ exc_caught = 1
+ assert exc_caught == 1
- SCons.Warnings.warningAsException(0)
- SCons.Warnings.warn(SCons.Warnings.Warning, "Foo")
+ old = SCons.Warnings.warningAsException(old)
+ assert old == 1, old
+ exc_caught = 0
+ try:
+ SCons.Warnings.warn(SCons.Warnings.Warning, "Foo")
+ except:
+ exc_caught = 1
+ assert exc_caught == 0
def test_Disable(self):
"""Test disabling/enabling warnings."""