Have the Tool() method add the tool name to the construction variable. (David Snopek)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 16 May 2003 11:09:27 +0000 (11:09 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 16 May 2003 11:09:27 +0000 (11:09 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@685 fdb21ef1-2011-0410-befe-b5e4ea1792b1

doc/man/scons.1
src/CHANGES.txt
src/engine/SCons/Tool/ToolTests.py
src/engine/SCons/Tool/__init__.py

index 99ddfa023b25e3e004a592700be855aa7d5d306f..ec2866975c957de6cc1f9a4d68d9d1cd6ab708a0 100644 (file)
@@ -2944,6 +2944,10 @@ The command line used to call the TeX formatter and typesetter.
 .IP TEXFLAGS
 General options passed to the TeX formatter and typesetter.
 
+.IP TOOLS
+A list of the names of the Tool specifications
+that are part of this construction environment.
+
 .IP WIN32_INSERT_DEF
 When this is set to true,
 a library build of a WIN32 shared library (.dll file)
@@ -4170,6 +4174,21 @@ tools keyword of the Environment() method.
 env = Environment(tools = [ Tool('msvc') ])
 .EE
 
+The object may be called with a construction
+environment as an argument,
+in which case the object will be
+add the necessary variables
+to the construction environment
+and the name of the tool will be added to the
+.B $TOOLS
+construction variable.
+
+.ES
+env = Environment()
+t = Tool('msvc')
+t(env)  # adds 'msvc' to the TOOLS variable
+.EE
+
 .TP
 .RI Value( value )
 Returns a Node object representing the specified Python value.  Value
index 3ae491fafbef46cf0a329f8f10ba30be7172a735..6c84af6bb897bcdb01d14d913021cba2d23a38d7 100644 (file)
@@ -123,6 +123,9 @@ RELEASE 0.14 - XXX
   - Contribute the "Autoscons" code for Autoconf-like checking for
     the existence of libraries, header files and the like.
 
+  - Have the Tool() function add the tool name to the $TOOLS
+    construction variable.
+
   From Greg Spencer:
 
   - Support the C preprocessor #import statement.
index c53ada387b49ebf16951e5f005c57886ae811042..cd809dfa3f7bc26fe4acd54edab48d05d716eb74 100644 (file)
@@ -39,6 +39,8 @@ class ToolTestCase(unittest.TestCase):
                 if not SCons.Util.is_List(progs):
                     progs = [ progs ]
                 return progs[0]
+            def Append(self, **kw):
+                self.dict.update(kw)
             def __getitem__(self, key):
                 return self.dict[key]
             def __setitem__(self, key, val):
@@ -52,6 +54,7 @@ class ToolTestCase(unittest.TestCase):
         assert (env['CXX'] == 'c++' or env['CXX'] == 'g++'), env['CXX']
         assert env['CXXFLAGS'] == '$CCFLAGS', env['CXXFLAGS']
         assert env['INCPREFIX'] == '-I', env['INCPREFIX']
+        assert env['TOOLS'] == ['g++'], env['TOOLS']
 
         try:
             SCons.Tool.Tool()
index 908101eaea2fca99dc8425eadf814f2af1ff683b..7cf9b292b0fed774b745a11b7824337f3a37d1a5 100644 (file)
@@ -48,6 +48,10 @@ class ToolSpec:
     def __init__(self, name):
         self.name = name
 
+    def __call__(self, env, *args, **kw):
+        env.Append(TOOLS = [ self.name ])
+        apply(self.generate, ( env, ) + args, kw)
+
     def __str__(self):
         return self.name
     
@@ -66,7 +70,7 @@ def Tool(name):
         if file:
             file.close()
     spec = ToolSpec(name)
-    spec.__call__ = sys.modules[full_name].generate
+    spec.generate = sys.modules[full_name].generate
     spec.exists = sys.modules[full_name].exists
     return spec