diff options
author | Steven Knight <knight@baldmt.com> | 2004-10-22 18:57:48 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-10-22 18:57:48 (GMT) |
commit | c7029022abb689e25457a3dc00aced8c1224c389 (patch) | |
tree | 941fe1971e51cc7abcb9b250a81fa7d53af55d24 | |
parent | 4e9fae436fc971e3cbdb19d2f0517a636bb6648b (diff) | |
download | SCons-c7029022abb689e25457a3dc00aced8c1224c389.zip SCons-c7029022abb689e25457a3dc00aced8c1224c389.tar.gz SCons-c7029022abb689e25457a3dc00aced8c1224c389.tar.bz2 |
Support default Options values of None. (Gary Oberbrunner)
-rw-r--r-- | doc/man/scons.1 | 8 | ||||
-rw-r--r-- | src/CHANGES.txt | 4 | ||||
-rw-r--r-- | src/engine/SCons/Options/OptionsTests.py | 16 | ||||
-rw-r--r-- | src/engine/SCons/Options/__init__.py | 2 |
4 files changed, 27 insertions, 3 deletions
diff --git a/doc/man/scons.1 b/doc/man/scons.1 index b94d680..fdfae69 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -7104,7 +7104,13 @@ is the name of the variable. .I help is the help text for the variable. .I default -is the default value of the variable. +is the default value of the variable; +if the default value is +.B None +and there is no explicit value specified, +the construction variable will +.I not +be added to the construction environment. .I validator is called to validate the value of the variable, and should take three arguments: key, value, and environment diff --git a/src/CHANGES.txt b/src/CHANGES.txt index df34c85..6747261 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -150,6 +150,10 @@ RELEASE 0.97 - XXX - Allow Tool specifications to be passed a dictionary of keyword arguments. + - Support an Options default value of None, in which case the variable + will not be added to the construction environment unless it's set + explicitly by the user or from an Options file. + From Chris Pawling: - Have the linkloc tool use $MSVS_VERSION to select the Microsoft diff --git a/src/engine/SCons/Options/OptionsTests.py b/src/engine/SCons/Options/OptionsTests.py index afcb4d3..4248dc3 100644 --- a/src/engine/SCons/Options/OptionsTests.py +++ b/src/engine/SCons/Options/OptionsTests.py @@ -244,7 +244,21 @@ class OptionsTestCase(unittest.TestCase): env = Environment() opts.Update(env, {}) assert not env.has_key('ANSWER') - + + # Test that a default value of None is all right. + test = TestSCons.TestSCons() + file = test.workpath('custom.py') + opts = SCons.Options.Options(file) + + opts.Add('ANSWER', + "This is the answer", + None, + check) + + env = Environment() + opts.Update(env, {}) + assert not env.has_key('ANSWER') + def test_args(self): """Test updating an Environment with arguments overridden""" diff --git a/src/engine/SCons/Options/__init__.py b/src/engine/SCons/Options/__init__.py index 521171c..fdaee92 100644 --- a/src/engine/SCons/Options/__init__.py +++ b/src/engine/SCons/Options/__init__.py @@ -165,7 +165,7 @@ class Options: # Finally validate the values: for option in self.options: - if option.validator: + if option.validator and values.has_key(option.key): option.validator(option.key, env.subst('${%s}'%option.key), env) def Save(self, filename, env): |