Make ${,UN}CHANGED_{SOURCES,TARGETS} into future reserved construction
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 7 Dec 2008 18:04:59 +0000 (18:04 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sun, 7 Dec 2008 18:04:59 +0000 (18:04 +0000)
variable names, with an appropriate warning.

git-svn-id: http://scons.tigris.org/svn/scons/trunk@3811 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/RELEASE.txt
src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py
src/engine/SCons/Script/Main.py
src/engine/SCons/Warnings.py

index 6b89aa7d769843b775b94149766ea738704f60f4..f496fa747de37c0d14dc15f065d75af4aa4c4cec 100644 (file)
@@ -74,6 +74,12 @@ RELEASE 1.X - XXX
     - Fix use of Glob() when a repository or source directory contains
       an in-memory Node without a corresponding on-disk file or directory.
 
+    - Add a warning about future reservation of $CHANGED_SOURCES,
+      $CHANGED_TARGETS, $UNCHANGED_SOURCES and $UNCHANGED_TARGETS.
+
+    - Enable by default the existing warnings about setting the resource
+      $SOURCE, $SOURCES, $TARGET and $TARGETS variable.
+
   From Rob Managan:
 
     - Scan for TeX files in the paths specified in the $TEXINPUTS
index 2bca53126d63d4856c5c5117ac62aa718929e080..223beb1f4a4fd31e4f0c55a7cd8e77116467fe0d 100644 (file)
@@ -20,11 +20,32 @@ more effectively, please sign up for the scons-users mailing list at:
 
 
 
-RELEASE 1.1.0 - Thu, 09 Oct 2008 08:33:47 -0700
+RELEASE XXX -
 
   Please consult the CHANGES.txt file for a list of specific changes
   since last release.
 
+  Please note the following important changes since release 1.1.0:
+
+    --  THE $CHANGED_SOURCES, $CHANGED_TARGETS, $UNCHANGED_SOURCES
+        AND $UNCHANGED_TARGETS VARIABLES WILL BECOME RESERVED
+
+        A future release (probably 1.3.0) will make the construction
+        variable names $CHANGED_SOURCES, $CHANGED_TARGETS,
+        $UNCHANGED_SOURCES and $UNCHANGED_TARGETS into reserved
+        construction variable names controlled by SCons itself (like
+        the current $SOURCE, $TARGETS, etc.).
+
+        Setting these variable names in the current release will generate
+        a warning but still set the variables.  When they become reserved
+        variable names, they will generate a different warning message
+        and attempts to set these variables will be ignored.
+
+        SCons configurations that happen to use these variable names
+        should be changed to use different variable names, in order
+        to ensure that the configuration continues to work with future
+        versions of SCons.
+
   Please note the following important changes since release 0.98.4:
 
     --  scons.bat NOW RETURNS THE REAL SCONS EXIT STATUS
index 5b82086535a2e22b3db3521bf1670f39fc534445..f6123b918833f556431596f56afb7960410c3a70 100644 (file)
@@ -105,24 +105,40 @@ def apply_tools(env, tools, toolpath):
         else:
             env.Tool(tool)
 
-# These names are controlled by SCons; users should never set or override
-# them.  This warning can optionally be turned off, but scons will still
-# ignore the illegal variable names even if it's off.
-reserved_construction_var_names = \
-    ['TARGET', 'TARGETS', 'SOURCE', 'SOURCES']
+# These names are (or will be) controlled by SCons; users should never
+# set or override them.  This warning can optionally be turned off,
+# but scons will still ignore the illegal variable names even if it's off.
+reserved_construction_var_names = [
+    'SOURCE',
+    'SOURCES',
+    'TARGET',
+    'TARGETS',
+]
+
+future_reserved_construction_var_names = [
+    'CHANGED_SOURCES',
+    'CHANGED_TARGETS',
+    'UNCHANGED_SOURCES',
+    'UNCHANGED_TARGETS',
+]
 
 def copy_non_reserved_keywords(dict):
     result = semi_deepcopy(dict)
     for k in result.keys():
         if k in reserved_construction_var_names:
-            SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning,
-                                "Ignoring attempt to set reserved variable `%s'" % k)
+            msg = "Ignoring attempt to set reserved variable `$%s'"
+            SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning, msg % k)
             del result[k]
     return result
 
 def _set_reserved(env, key, value):
-    msg = "Ignoring attempt to set reserved variable `%s'" % key
-    SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning, msg)
+    msg = "Ignoring attempt to set reserved variable `$%s'"
+    SCons.Warnings.warn(SCons.Warnings.ReservedVariableWarning, msg % key)
+
+def _set_future_reserved(env, key, value):
+    env._dict[key] = value
+    msg = "`$%s' will be reserved in a future release and setting it will become ignored"
+    SCons.Warnings.warn(SCons.Warnings.FutureReservedVariableWarning, msg % key)
 
 def _set_BUILDERS(env, key, value):
     try:
@@ -364,6 +380,8 @@ class SubstitutionEnvironment:
         self._special_set = {}
         for key in reserved_construction_var_names:
             self._special_set[key] = _set_reserved
+        for key in future_reserved_construction_var_names:
+            self._special_set[key] = _set_future_reserved
         self._special_set['BUILDERS'] = _set_BUILDERS
         self._special_set['SCANNERS'] = _set_SCANNERS
 
index 2c09378915a80ce7b91e30c192dc6bfaa889f59b..f3210b8d4d3fc6bfbb9923473d509865523f026e 100644 (file)
@@ -1120,25 +1120,59 @@ env4.builder1.env, env3)
         assert env.Dictionary('ENV')['PATH'] == '/foo:/bar'
 
     def test_ReservedVariables(self):
-        """Test generation of warnings when reserved variable names
-        are set in an environment."""
+        """Test warning generation when reserved variable names are set"""
 
-        SCons.Warnings.enableWarningClass(SCons.Warnings.ReservedVariableWarning)
+        reserved_variables = [
+            'SOURCE',
+            'SOURCES',
+            'TARGET',
+            'TARGETS',
+        ]
+
+        warning = SCons.Warnings.ReservedVariableWarning
+        SCons.Warnings.enableWarningClass(warning)
         old = SCons.Warnings.warningAsException(1)
 
         try:
             env4 = Environment()
-            for kw in ['TARGET', 'TARGETS', 'SOURCE', 'SOURCES']:
+            for kw in reserved_variables:
                 exc_caught = None
                 try:
                     env4[kw] = 'xyzzy'
-                except SCons.Warnings.ReservedVariableWarning:
+                except warning:
                     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_FutureReservedVariables(self):
+        """Test warning generation when future reserved variable names are set"""
+
+        future_reserved_variables = [
+            'CHANGED_SOURCES',
+            'CHANGED_TARGETS',
+            'UNCHANGED_SOURCES',
+            'UNCHANGED_TARGETS',
+        ]
+
+        warning = SCons.Warnings.FutureReservedVariableWarning
+        SCons.Warnings.enableWarningClass(warning)
+        old = SCons.Warnings.warningAsException(1)
+
+        try:
+            env4 = Environment()
+            for kw in future_reserved_variables:
+                exc_caught = None
+                try:
+                    env4[kw] = 'xyzzy'
+                except warning:
+                    exc_caught = 1
+                assert exc_caught, "Did not catch FutureReservedVariableWarning for `%s'" % kw
+                assert env4.has_key(kw), "`%s' variable was not set" % kw
+        finally:
+            SCons.Warnings.warningAsException(old)
+
     def test_IllegalVariables(self):
         """Test that use of illegal variables raises an exception"""
         env = Environment()
index 2d4e6a0b627133e8b7cc644b7c553a4de856bf6d..25e73dcedf4dc66d95e6c8526a088f55457e13a6 100644 (file)
@@ -737,6 +737,7 @@ def _main(parser):
     default_warnings = [ SCons.Warnings.CorruptSConsignWarning,
                          SCons.Warnings.DeprecatedWarning,
                          SCons.Warnings.DuplicateEnvironmentWarning,
+                         SCons.Warnings.FutureReservedVariableWarning,
                          SCons.Warnings.LinkWarning,
                          SCons.Warnings.MissingSConscriptWarning,
                          SCons.Warnings.NoMD5ModuleWarning,
@@ -744,7 +745,9 @@ def _main(parser):
                          SCons.Warnings.NoObjectCountWarning,
                          SCons.Warnings.NoParallelSupportWarning,
                          SCons.Warnings.MisleadingKeywordsWarning,
-                         SCons.Warnings.StackSizeWarning, ]
+                         SCons.Warnings.ReservedVariableWarning,
+                         SCons.Warnings.StackSizeWarning,
+                       ]
 
     for warning in default_warnings:
         SCons.Warnings.enableWarningClass(warning)
index 5af9263c793be3ae5d889671b2e4b76e831a56ed..03ab9ae5ca63931fd98b625f8173568aa8db053c 100644 (file)
@@ -64,6 +64,9 @@ class DeprecatedTargetSignaturesWarning(DeprecatedWarning):
 class DuplicateEnvironmentWarning(Warning):
     pass
 
+class FutureReservedVariableWarning(Warning):
+    pass
+
 class LinkWarning(Warning):
     pass