diff options
author | Steven Knight <knight@baldmt.com> | 2008-12-20 16:23:36 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2008-12-20 16:23:36 (GMT) |
commit | ca777a0529909609ccd29b518348ae52b0b1f120 (patch) | |
tree | 0d22552936968f8ef0f890a511a9b82ca3728ad4 /src | |
parent | 63a8df2c0783d98d402f3e6dfbb9e8d84af965d5 (diff) | |
download | SCons-ca777a0529909609ccd29b518348ae52b0b1f120.zip SCons-ca777a0529909609ccd29b518348ae52b0b1f120.tar.gz SCons-ca777a0529909609ccd29b518348ae52b0b1f120.tar.bz2 |
Add warnings for use of the (already) deprecated Options object
and its related functions.
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 2 | ||||
-rw-r--r-- | src/engine/SCons/Options/BoolOption.py | 11 | ||||
-rw-r--r-- | src/engine/SCons/Options/EnumOption.py | 11 | ||||
-rw-r--r-- | src/engine/SCons/Options/ListOption.py | 11 | ||||
-rw-r--r-- | src/engine/SCons/Options/PackageOption.py | 11 | ||||
-rw-r--r-- | src/engine/SCons/Options/PathOption.py | 37 | ||||
-rw-r--r-- | src/engine/SCons/Options/__init__.py | 12 | ||||
-rw-r--r-- | src/engine/SCons/Warnings.py | 3 |
8 files changed, 93 insertions, 5 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index d334b64..fb44ad7 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -20,6 +20,8 @@ RELEASE 1.X - XXX - Don't fail if can't import a _subprocess module on Windows. + - Add warnings for use of the deprecated Options object. + From Greg Spencer: - Support implicit dependency scanning of files encoded in utf-8 diff --git a/src/engine/SCons/Options/BoolOption.py b/src/engine/SCons/Options/BoolOption.py index c3b50b3..a247ef5 100644 --- a/src/engine/SCons/Options/BoolOption.py +++ b/src/engine/SCons/Options/BoolOption.py @@ -31,5 +31,14 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings -BoolOption = SCons.Variables.BoolVariable +warned = False + +def BoolOption(*args, **kw): + global warned + if not warned: + msg = "The BoolOption() function is deprecated; use the BoolVariable() function instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + return apply(SCons.Variables.BoolVariable, args, kw) diff --git a/src/engine/SCons/Options/EnumOption.py b/src/engine/SCons/Options/EnumOption.py index 24ccf28..f4c3c03 100644 --- a/src/engine/SCons/Options/EnumOption.py +++ b/src/engine/SCons/Options/EnumOption.py @@ -31,5 +31,14 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings -EnumOption = SCons.Variables.EnumVariable +warned = False + +def EnumOption(*args, **kw): + global warned + if not warned: + msg = "The EnumOption() function is deprecated; use the EnumVariable() function instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + return apply(SCons.Variables.EnumVariable, args, kw) diff --git a/src/engine/SCons/Options/ListOption.py b/src/engine/SCons/Options/ListOption.py index 1a56806..88334d4 100644 --- a/src/engine/SCons/Options/ListOption.py +++ b/src/engine/SCons/Options/ListOption.py @@ -31,5 +31,14 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings -ListOption = SCons.Variables.ListVariable +warned = False + +def ListOption(*args, **kw): + global warned + if not warned: + msg = "The ListOption() function is deprecated; use the ListVariable() function instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + return apply(SCons.Variables.ListVariable, args, kw) diff --git a/src/engine/SCons/Options/PackageOption.py b/src/engine/SCons/Options/PackageOption.py index 479a8a2..0f5ef7f 100644 --- a/src/engine/SCons/Options/PackageOption.py +++ b/src/engine/SCons/Options/PackageOption.py @@ -31,5 +31,14 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings -PackageOption = SCons.Variables.PackageVariable +warned = False + +def PackageOption(*args, **kw): + global warned + if not warned: + msg = "The PackageOption() function is deprecated; use the PackageVariable() function instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + return apply(SCons.Variables.PackageVariable, args, kw) diff --git a/src/engine/SCons/Options/PathOption.py b/src/engine/SCons/Options/PathOption.py index e694127..3223ac3 100644 --- a/src/engine/SCons/Options/PathOption.py +++ b/src/engine/SCons/Options/PathOption.py @@ -31,5 +31,40 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings -PathOption = SCons.Variables.PathVariable +warned = False + +class _PathOptionClass: + def warn(self): + global warned + if not warned: + msg = "The PathOption() function is deprecated; use the PathVariable() function instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + + def __call__(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable, args, kw) + + def PathAccept(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable.PathAccept, args, kw) + + def PathIsDir(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable.PathIsDir, args, kw) + + def PathIsDirCreate(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable.PathIsDirCreate, args, kw) + + def PathIsFile(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable.PathIsFile, args, kw) + + def PathExists(self, *args, **kw): + self.warn() + return apply(SCons.Variables.PathVariable.PathExists, args, kw) + +PathOption = _PathOptionClass() diff --git a/src/engine/SCons/Options/__init__.py b/src/engine/SCons/Options/__init__.py index 5cc09a7..e1e8b3f 100644 --- a/src/engine/SCons/Options/__init__.py +++ b/src/engine/SCons/Options/__init__.py @@ -31,6 +31,7 @@ and will then be removed entirely (some day). """ import SCons.Variables +import SCons.Warnings from BoolOption import BoolOption # okay from EnumOption import EnumOption # okay @@ -38,7 +39,18 @@ from ListOption import ListOption # naja from PackageOption import PackageOption # naja from PathOption import PathOption # okay +warned = False + class Options(SCons.Variables.Variables): + def __init__(self, *args, **kw): + global warned + if not warned: + msg = "The Options class is deprecated; use the Variables class instead." + SCons.Warnings.warn(SCons.Warnings.DeprecatedOptionsWarning, msg) + warned = True + apply(SCons.Variables.Variables.__init__, + (self,) + args, + kw) def AddOptions(self, *args, **kw): return apply(SCons.Variables.Variables.AddVariables, diff --git a/src/engine/SCons/Warnings.py b/src/engine/SCons/Warnings.py index 83e3ccb..e23d1ef 100644 --- a/src/engine/SCons/Warnings.py +++ b/src/engine/SCons/Warnings.py @@ -67,6 +67,9 @@ class DependencyWarning(Warning): class DeprecatedCopyWarning(DeprecatedWarning): pass +class DeprecatedOptionsWarning(DeprecatedWarning): + pass + class DeprecatedSourceSignaturesWarning(DeprecatedWarning): pass |