Commits

Anonymous committed 797acf0

Merged revisions 2117-2120 via svnmerge from
http://scons.tigris.org/svn/scons/branches/core

........
r2119 | garyo | 2007-07-11 08:53:36 -0500 (Wed, 11 Jul 2007) | 1 line

Fixed minor cut/paste doc error
........
r2120 | stevenknight | 2007-07-11 12:42:50 -0500 (Wed, 11 Jul 2007) | 4 lines

Simplify the {Add,Get,Set}Option() implementations, and initialize the
OptionsParser variable with a do-nothing class, in case it's used
by test scripts without normal SCons.Script.Main initialization.
........

Comments (0)

Files changed (5)

doc/user/command-line.in

 
       <para>
 
-      Other values that equate to &true; include
+      Other values that equate to &false; include
       <literal>n</literal>,
       <literal>0</literal>,
       <literal>off</literal>

doc/user/command-line.sgml

 
       <para>
 
-      Other values that equate to &true; include
+      Other values that equate to &false; include
       <literal>n</literal>,
       <literal>0</literal>,
       <literal>off</literal>

src/engine/SCons/Script/Main.py

 num_jobs = None
 delayed_warnings = []
 
-OptionsParser = None
+class FakeOptionParser:
+    """
+    A do-nothing option parser, used for the initial OptionsParser variable.
+
+    During normal SCons operation, the OptionsParser is created right
+    away by the main() function.  Certain tests scripts however, can
+    introspect on different Tool modules, the initialization of which
+    can try to add a new, local option to an otherwise uninitialized
+    OptionsParser object.  This allows that introspection to happen
+    without blowing up.
+
+    """
+    class FakeOptionValues:
+        def __getattr__(self, attr):
+            return None
+    values = FakeOptionValues()
+    def add_local_option(self, *args, **kw):
+        pass
+
+OptionsParser = FakeOptionParser()
 
 def AddOption(*args, **kw):
     if not kw.has_key('default'):
         kw['default'] = None
     result = apply(OptionsParser.add_local_option, args, kw)
     return result
+
+def GetOption(name):
+    return getattr(OptionsParser.values, name)
+
+def SetOption(name, value):
+    return OptionsParser.values.set_option(name, value)
+
 #
 class Stats:
     def __init__(self):

src/engine/SCons/Script/SConscript.py

 
     def GetOption(self, name):
         name = self.subst(name)
-        return getattr(SCons.Script.Main.OptionsParser.values, name)
+        return SCons.Script.Main.GetOption(name)
 
     def Help(self, text):
         text = self.subst(text, raw=1)
 
     def SetOption(self, name, value):
         name = self.subst(name)
-        SCons.Script.Main.OptionsParser.values.set_option(name, value)
+        SCons.Script.Main.SetOption(name, value)
 
 #
 #

src/engine/SCons/Script/__init__.py

 QuestionTask            = Main.QuestionTask
 #PrintHelp               = Main.PrintHelp
 #SConscriptSettableOptions = Main.SConscriptSettableOptions
+
 AddOption               = Main.AddOption
+GetOption               = Main.GetOption
+SetOption               = Main.SetOption
 
 #keep_going_on_error     = Main.keep_going_on_error
 #print_dtree             = Main.print_dtree
     'Exit',
     'Export',
     'GetLaunchDir',
-    'GetOption',
     'Help',
     'Import',
     #'SConscript', is handled separately, below.
     'SConscriptChdir',
-    'SetOption',
 
     # Methods from the Environment.Base class.
     'AddPostAction',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.