From cc62e067332e442f7f044fd328bff7b9073ea5d3 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 22 Oct 2004 18:57:48 +0000 Subject: [PATCH] Support default Options values of None. (Gary Oberbrunner) git-svn-id: http://scons.tigris.org/svn/scons/trunk@1135 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- doc/man/scons.1 | 8 +++++++- src/CHANGES.txt | 4 ++++ src/engine/SCons/Options/OptionsTests.py | 16 +++++++++++++++- 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 b94d680e..fdfae695 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 df34c85a..67472610 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 afcb4d38..4248dc3f 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 521171c1..fdaee920 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): -- 2.26.2