From: stevenknight Date: Fri, 16 May 2003 11:09:27 +0000 (+0000) Subject: Have the Tool() method add the tool name to the construction variable. (David Snopek) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=30b4004fd2bacf943c2f5dc4894dba2e7ed2b36e;p=scons.git Have the Tool() method add the tool name to the construction variable. (David Snopek) git-svn-id: http://scons.tigris.org/svn/scons/trunk@685 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/doc/man/scons.1 b/doc/man/scons.1 index 99ddfa02..ec286697 100644 --- a/doc/man/scons.1 +++ b/doc/man/scons.1 @@ -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 diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 3ae491fa..6c84af6b 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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. diff --git a/src/engine/SCons/Tool/ToolTests.py b/src/engine/SCons/Tool/ToolTests.py index c53ada38..cd809dfa 100644 --- a/src/engine/SCons/Tool/ToolTests.py +++ b/src/engine/SCons/Tool/ToolTests.py @@ -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() diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py index 908101ea..7cf9b292 100644 --- a/src/engine/SCons/Tool/__init__.py +++ b/src/engine/SCons/Tool/__init__.py @@ -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