00001 __copyright__ = """
00002 Copyright 2008 Sean Ross-Ross
00003 """
00004 __license__ = """
00005 This file is part of SLIMpy .
00006
00007 SLIMpy is free software: you can redistribute it and/or modify
00008 it under the terms of the GNU Lesser General Public License as published by
00009 the Free Software Foundation, either version 3 of the License, or
00010 (at your option) any later version.
00011
00012 SLIMpy is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015 GNU Lesser General Public License for more details.
00016
00017 You should have received a copy of the GNU Lesser General Public License
00018 along with SLIMpy . If not, see <http://www.gnu.org/licenses/>.
00019 """
00020
00021
00022 from SCons.Script import DefaultEnvironment
00023
00024 class DefaultEnvCall(object):
00025 """A class that implements "global function" calls of
00026 Environment methods by fetching the specified method from the
00027 DefaultEnvironment's class. """
00028
00029 def __init__(self, method_name, tool=None, help=None ):
00030 self.method_name = method_name
00031 self._help = help
00032 self.tool = tool
00033
00034 def __repr__(self):
00035 return "DefaultEnvCall( %s )" %repr(self.method_name)
00036
00037 def __call__(self, *args, **kw):
00038
00039 denv = DefaultEnvironment( )
00040 env = denv.Clone( )
00041 if self.tool:
00042 env.Tool( self.tool )
00043
00044 method = getattr( env, self.method_name )
00045 return method( *args, **kw )
00046
00047 def help(self):
00048 print self._help
00049
00050
00051 class DefaultBuilderCall( object ):
00052
00053 def __init__(self, builder ):
00054 self.builder = builder
00055
00056 def __call__(self, *args, **kw ):
00057
00058
00059 denv = DefaultEnvironment( )
00060 env = denv.Clone()
00061 env['BUILDERS']['_SLIM_BUILDER'] = self.builder
00062 return env._SLIM_BUILDER( *args, **kw )
00063
00064
00065