<s> """<STR_LIT>""" <EOL> __revision__ = "<STR_LIT>" <EOL> import SCons . compat <EOL> import dis <EOL> import os <EOL> import pickle <EOL> import re <EOL> import sys <EOL> import subprocess <EOL> import SCons . Debug <EOL> from SCons . Debug import logInstanceCreation <EOL> import SCons . Errors <EOL> import SCons . Executor <EOL> import SCons . Util <EOL> import SCons . Subst <EOL> is_String = SCons . Util . is_String <EOL> is_List = SCons . Util . is_List <EOL> class _null ( object ) : <EOL> pass <EOL> print_actions = <NUM_LIT:1> <EOL> execute_actions = <NUM_LIT:1> <EOL> print_actions_presub = <NUM_LIT:0> <EOL> def rfile ( n ) : <EOL> try : <EOL> return n . rfile ( ) <EOL> except AttributeError : <EOL> return n <EOL> def default_exitstatfunc ( s ) : <EOL> return s <EOL> try : <EOL> SET_LINENO = dis . SET_LINENO <EOL> HAVE_ARGUMENT = dis . HAVE_ARGUMENT <EOL> except AttributeError : <EOL> remove_set_lineno_codes = lambda x : x <EOL> else : <EOL> def remove_set_lineno_codes ( code ) : <EOL> result = [ ] <EOL> n = len ( code ) <EOL> i = <NUM_LIT:0> <EOL> while i < n : <EOL> c = code [ i ] <EOL> op = ord ( c ) <EOL> if op >= HAVE_ARGUMENT : <EOL> if op != SET_LINENO : <EOL> result . append ( code [ i : i + <NUM_LIT:3> ] ) <EOL> i = i + <NUM_LIT:3> <EOL> else : <EOL> result . append ( c ) <EOL> i = i + <NUM_LIT:1> <EOL> return '<STR_LIT>' . join ( result ) <EOL> strip_quotes = re . compile ( '<STR_LIT>' ) <EOL> def _callable_contents ( obj ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return _function_contents ( obj . im_func ) <EOL> except AttributeError : <EOL> try : <EOL> return _function_contents ( obj . __call__ . im_func ) <EOL> except AttributeError : <EOL> try : <EOL> return _code_contents ( obj ) <EOL> except AttributeError : <EOL> return _function_contents ( obj ) <EOL> def _object_contents ( obj ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return _function_contents ( obj . im_func ) <EOL> except AttributeError : <EOL> try : <EOL> return _function_contents ( obj . __call__ . im_func ) <EOL> except AttributeError : <EOL> try : <EOL> return _code_contents ( obj ) <EOL> except AttributeError : <EOL> try : <EOL> return _function_contents ( obj ) <EOL> except AttributeError : <EOL> try : <EOL> return pickle . dumps ( obj ) <EOL> except ( pickle . PicklingError , TypeError ) : <EOL> return str ( obj ) <EOL> def _code_contents ( code ) : <EOL> """<STR_LIT>""" <EOL> contents = [ ] <EOL> contents . append ( "<STR_LIT>" % ( code . co_argcount , len ( code . co_varnames ) ) ) <EOL> try : <EOL> contents . append ( "<STR_LIT>" % ( len ( code . co_cellvars ) , len ( code . co_freevars ) ) ) <EOL> except AttributeError : <EOL> contents . append ( "<STR_LIT>" ) <EOL> contents . append ( '<STR_LIT>' + '<STR_LIT:U+002C>' . join ( map ( _object_contents , code . co_consts [ <NUM_LIT:1> : ] ) ) + '<STR_LIT:)>' ) <EOL> contents . append ( '<STR_LIT>' + '<STR_LIT:U+002C>' . join ( map ( _object_contents , code . co_names ) ) + '<STR_LIT:)>' ) <EOL> contents . append ( '<STR_LIT>' + str ( remove_set_lineno_codes ( code . co_code ) ) + '<STR_LIT:)>' ) <EOL> return '<STR_LIT>' . join ( contents ) <EOL> def _function_contents ( func ) : <EOL> """<STR_LIT>""" <EOL> contents = [ _code_contents ( func . func_code ) ] <EOL> if func . func_defaults : <EOL> contents . append ( '<STR_LIT>' + '<STR_LIT:U+002C>' . join ( map ( _object_contents , func . func_defaults ) ) + '<STR_LIT:)>' ) <EOL> else : <EOL> contents . append ( '<STR_LIT>' ) <EOL> try : <EOL> closure = func . func_closure or [ ] <EOL> except AttributeError : <EOL> closure = [ ] <EOL> try : <EOL> xxx = [ _object_contents ( x . cell_contents ) for x in closure ] <EOL> except AttributeError : <EOL> xxx = [ ] <EOL> contents . append ( '<STR_LIT>' + '<STR_LIT:U+002C>' . join ( xxx ) + '<STR_LIT:)>' ) <EOL> return '<STR_LIT>' . join ( contents ) <EOL> def _actionAppend ( act1 , act2 ) : <EOL> a1 = Action ( act1 ) <EOL> a2 = Action ( act2 ) <EOL> if a1 is None : <EOL> return a2 <EOL> if a2 is None : <EOL> return a1 <EOL> if isinstance ( a1 , ListAction ) : <EOL> if isinstance ( a2 , ListAction ) : <EOL> return ListAction ( a1 . list + a2 . list ) <EOL> else : <EOL> return ListAction ( a1 . list + [ a2 ] ) <EOL> else : <EOL> if isinstance ( a2 , ListAction ) : <EOL> return ListAction ( [ a1 ] + a2 . list ) <EOL> else : <EOL> return ListAction ( [ a1 , a2 ] ) <EOL> def _do_create_keywords ( args , kw ) : <EOL> """<STR_LIT>""" <EOL> v = kw . get ( '<STR_LIT>' , ( ) ) <EOL> if is_String ( v ) : v = ( v , ) <EOL> kw [ '<STR_LIT>' ] = tuple ( v ) <EOL> if args : <EOL> cmdstrfunc = args [ <NUM_LIT:0> ] <EOL> if cmdstrfunc is None or is_String ( cmdstrfunc ) : <EOL> kw [ '<STR_LIT>' ] = cmdstrfunc <EOL> elif callable ( cmdstrfunc ) : <EOL> kw [ '<STR_LIT>' ] = cmdstrfunc <EOL> else : <EOL> raise SCons . Errors . UserError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> if len ( args ) > <NUM_LIT:1> : <EOL> kw [ '<STR_LIT>' ] = tuple ( SCons . Util . flatten ( args [ <NUM_LIT:1> : ] ) ) + kw [ '<STR_LIT>' ] <EOL> if kw . get ( '<STR_LIT>' , _null ) is not _null and kw . get ( '<STR_LIT>' , _null ) is not _null : <EOL> raise SCons . Errors . UserError ( <EOL> '<STR_LIT>' ) <EOL> def _do_create_action ( act , kw ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( act , ActionBase ) : <EOL> return act <EOL> if is_List ( act ) : <EOL> return CommandAction ( act , ** kw ) <EOL> if callable ( act ) : <EOL> try : <EOL> gen = kw [ '<STR_LIT>' ] <EOL> del kw [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> gen = <NUM_LIT:0> <EOL> if gen : <EOL> action_type = CommandGeneratorAction <EOL> else : <EOL> action_type = FunctionAction <EOL> return action_type ( act , kw ) <EOL> if is_String ( act ) : <EOL> var = SCons . Util . get_environment_var ( act ) <EOL> if var : <EOL> return LazyAction ( var , kw ) <EOL> commands = str ( act ) . split ( '<STR_LIT:\n>' ) <EOL> if len ( commands ) == <NUM_LIT:1> : <EOL> return CommandAction ( commands [ <NUM_LIT:0> ] , ** kw ) <EOL> return _do_create_list_action ( commands , kw ) <EOL> if isinstance ( act , int ) or isinstance ( act , float ) : <EOL> raise TypeError ( "<STR_LIT>" % act ) <EOL> return None <EOL> def _do_create_list_action ( act , kw ) : <EOL> """<STR_LIT>""" <EOL> acts = [ ] <EOL> for a in act : <EOL> aa = _do_create_action ( a , kw ) <EOL> if aa is not None : acts . append ( aa ) <EOL> if not acts : <EOL> return ListAction ( [ ] ) <EOL> elif len ( acts ) == <NUM_LIT:1> : <EOL> return acts [ <NUM_LIT:0> ] <EOL> else : <EOL> return ListAction ( acts ) <EOL> def Action ( act , * args , ** kw ) : <EOL> """<STR_LIT>""" <EOL> _do_create_keywords ( args , kw ) <EOL> if is_List ( act ) : <EOL> return _do_create_list_action ( act , kw ) <EOL> return _do_create_action ( act , kw ) <EOL> class ActionBase ( object ) : <EOL> """<STR_LIT>""" <EOL> def __cmp__ ( self , other ) : <EOL> return cmp ( self . __dict__ , other ) <EOL> def no_batch_key ( self , env , target , source ) : <EOL> return None <EOL> batch_key = no_batch_key <EOL> def genstring ( self , target , source , env ) : <EOL> return str ( self ) <EOL> def get_contents ( self , target , source , env ) : <EOL> result = [ self . get_presig ( target , source , env ) ] <EOL> vl = self . get_varlist ( target , source , env ) <EOL> if is_String ( vl ) : vl = ( vl , ) <EOL> for v in vl : <EOL> result . append ( env . subst_target_source ( '<STR_LIT>' + v + '<STR_LIT:}>' , SCons . Subst . SUBST_SIG , target , source ) ) <EOL> return '<STR_LIT>' . join ( result ) <EOL> def __add__ ( self , other ) : <EOL> return _actionAppend ( self , other ) <EOL> def __radd__ ( self , other ) : <EOL> return _actionAppend ( other , self ) <EOL> def presub_lines ( self , env ) : <EOL> self . presub_env = env <EOL> lines = str ( self ) . split ( '<STR_LIT:\n>' ) <EOL> self . presub_env = None <EOL> return lines <EOL> def get_varlist ( self , target , source , env , executor = None ) : <EOL> return self . varlist <EOL> def get_targets ( self , env , executor ) : <EOL> """<STR_LIT>""" <EOL> return self . targets <EOL> class _ActionAction ( ActionBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , cmdstr = _null , strfunction = _null , varlist = ( ) , <EOL> presub = _null , chdir = None , exitstatfunc = None , <EOL> batch_key = None , targets = '<STR_LIT>' , <EOL> ** kw ) : <EOL> self . cmdstr = cmdstr <EOL> if strfunction is not _null : <EOL> if strfunction is None : <EOL> self . cmdstr = None <EOL> else : <EOL> self . strfunction = strfunction <EOL> self . varlist = varlist <EOL> self . presub = presub <EOL> self . chdir = chdir <EOL> if not exitstatfunc : <EOL> exitstatfunc = default_exitstatfunc <EOL> self . exitstatfunc = exitstatfunc <EOL> self . targets = targets <EOL> if batch_key : <EOL> if not callable ( batch_key ) : <EOL> def default_batch_key ( self , env , target , source ) : <EOL> return ( id ( self ) , id ( env ) ) <EOL> batch_key = default_batch_key <EOL> SCons . Util . AddMethod ( self , batch_key , '<STR_LIT>' ) <EOL> def print_cmd_line ( self , s , target , source , env ) : <EOL> try : <EOL> sys . stdout . write ( unicode ( s + "<STR_LIT:\n>" ) ) <EOL> except UnicodeDecodeError : <EOL> sys . stdout . write ( s + "<STR_LIT:\n>" ) <EOL> def __call__ ( self , target , source , env , <EOL> exitstatfunc = _null , <EOL> presub = _null , <EOL> show = _null , <EOL> execute = _null , <EOL> chdir = _null , <EOL> executor = None ) : <EOL> if not is_List ( target ) : <EOL> target = [ target ] <EOL> if not is_List ( source ) : <EOL> source = [ source ] <EOL> if presub is _null : <EOL> presub = self . presub <EOL> if presub is _null : <EOL> presub = print_actions_presub <EOL> if exitstatfunc is _null : exitstatfunc = self . exitstatfunc <EOL> if show is _null : show = print_actions <EOL> if execute is _null : execute = execute_actions <EOL> if chdir is _null : chdir = self . chdir <EOL> save_cwd = None <EOL> if chdir : <EOL> save_cwd = os . getcwd ( ) <EOL> try : <EOL> chdir = str ( chdir . abspath ) <EOL> except AttributeError : <EOL> if not is_String ( chdir ) : <EOL> if executor : <EOL> chdir = str ( executor . batches [ <NUM_LIT:0> ] . targets [ <NUM_LIT:0> ] . dir ) <EOL> else : <EOL> chdir = str ( target [ <NUM_LIT:0> ] . dir ) <EOL> if presub : <EOL> if executor : <EOL> target = executor . get_all_targets ( ) <EOL> source = executor . get_all_sources ( ) <EOL> t = '<STR_LIT>' . join ( map ( str , target ) ) <EOL> l = '<STR_LIT>' . join ( self . presub_lines ( env ) ) <EOL> out = u"<STR_LIT>" % ( t , l ) <EOL> sys . stdout . write ( out ) <EOL> cmd = None <EOL> if show and self . strfunction : <EOL> if executor : <EOL> target = executor . get_all_targets ( ) <EOL> source = executor . get_all_sources ( ) <EOL> try : <EOL> cmd = self . strfunction ( target , source , env , executor ) <EOL> except TypeError : <EOL> cmd = self . strfunction ( target , source , env ) <EOL> if cmd : <EOL> if chdir : <EOL> cmd = ( '<STR_LIT>' % repr ( chdir ) ) + cmd <EOL> try : <EOL> get = env . get <EOL> except AttributeError : <EOL> print_func = self . print_cmd_line <EOL> else : <EOL> print_func = get ( '<STR_LIT>' ) <EOL> if not print_func : <EOL> print_func = self . print_cmd_line <EOL> print_func ( cmd , target , source , env ) <EOL> stat = <NUM_LIT:0> <EOL> if execute : <EOL> if chdir : <EOL> os . chdir ( chdir ) <EOL> try : <EOL> stat = self . execute ( target , source , env , executor = executor ) <EOL> if isinstance ( stat , SCons . Errors . BuildError ) : <EOL> s = exitstatfunc ( stat . status ) <EOL> if s : <EOL> stat . status = s <EOL> else : <EOL> stat = s <EOL> else : <EOL> stat = exitstatfunc ( stat ) <EOL> finally : <EOL> if save_cwd : <EOL> os . chdir ( save_cwd ) <EOL> if cmd and save_cwd : <EOL> print_func ( '<STR_LIT>' % repr ( save_cwd ) , target , source , env ) <EOL> return stat <EOL> def _string_from_cmd_list ( cmd_list ) : <EOL> """<STR_LIT>""" <EOL> cl = [ ] <EOL> for arg in map ( str , cmd_list ) : <EOL> if '<STR_LIT:U+0020>' in arg or '<STR_LIT:\t>' in arg : <EOL> arg = '<STR_LIT:">' + arg + '<STR_LIT:">' <EOL> cl . append ( arg ) <EOL> return '<STR_LIT:U+0020>' . join ( cl ) <EOL> default_ENV = None <EOL> def get_default_ENV ( env ) : <EOL> global default_ENV <EOL> try : <EOL> return env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> if not default_ENV : <EOL> import SCons . Environment <EOL> default_ENV = SCons . Environment . Environment ( ) [ '<STR_LIT>' ] <EOL> return default_ENV <EOL> def _subproc ( scons_env , cmd , error = '<STR_LIT:ignore>' , ** kw ) : <EOL> """<STR_LIT>""" <EOL> io = kw . get ( '<STR_LIT>' ) <EOL> if is_String ( io ) and io == '<STR_LIT>' : <EOL> kw [ '<STR_LIT>' ] = open ( os . devnull ) <EOL> io = kw . get ( '<STR_LIT>' ) <EOL> if is_String ( io ) and io == '<STR_LIT>' : <EOL> kw [ '<STR_LIT>' ] = open ( os . devnull , '<STR_LIT:w>' ) <EOL> io = kw . get ( '<STR_LIT>' ) <EOL> if is_String ( io ) and io == '<STR_LIT>' : <EOL> kw [ '<STR_LIT>' ] = open ( os . devnull , '<STR_LIT:w>' ) <EOL> ENV = kw . get ( '<STR_LIT>' , None ) <EOL> if ENV is None : ENV = get_default_ENV ( scons_env ) <EOL> new_env = { } <EOL> for key , value in ENV . items ( ) : <EOL> if is_List ( value ) : <EOL> value = SCons . Util . flatten_sequence ( value ) <EOL> new_env [ key ] = os . pathsep . join ( map ( str , value ) ) <EOL> else : <EOL> new_env [ key ] = str ( value ) <EOL> kw [ '<STR_LIT>' ] = new_env <EOL> try : <EOL> return subprocess . Popen ( cmd , ** kw ) <EOL> except EnvironmentError , e : <EOL> if error == '<STR_LIT>' : raise <EOL> class dummyPopen ( object ) : <EOL> def __init__ ( self , e ) : self . exception = e <EOL> def communicate ( self , input = None ) : return ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def wait ( self ) : return - self . exception . errno <EOL> stdin = None <EOL> class f ( object ) : <EOL> def read ( self ) : return '<STR_LIT>' <EOL> def readline ( self ) : return '<STR_LIT>' <EOL> def __iter__ ( self ) : return iter ( ( ) ) <EOL> stdout = stderr = f ( ) <EOL> return dummyPopen ( e ) <EOL> class CommandAction ( _ActionAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , cmd , ** kw ) : <EOL> if SCons . Debug . track_instances : logInstanceCreation ( self , '<STR_LIT>' ) <EOL> _ActionAction . __init__ ( self , ** kw ) <EOL> if is_List ( cmd ) : <EOL> if list ( filter ( is_List , cmd ) ) : <EOL> raise TypeError ( "<STR_LIT>" "<STR_LIT>" ) <EOL> self . cmd_list = cmd <EOL> def __str__ ( self ) : <EOL> if is_List ( self . cmd_list ) : <EOL> return '<STR_LIT:U+0020>' . join ( map ( str , self . cmd_list ) ) <EOL> return str ( self . cmd_list ) <EOL> def process ( self , target , source , env , executor = None ) : <EOL> if executor : <EOL> result = env . subst_list ( self . cmd_list , <NUM_LIT:0> , executor = executor ) <EOL> else : <EOL> result = env . subst_list ( self . cmd_list , <NUM_LIT:0> , target , source ) <EOL> silent = None <EOL> ignore = None <EOL> while True : <EOL> try : c = result [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> except IndexError : c = None <EOL> if c == '<STR_LIT:@>' : silent = <NUM_LIT:1> <EOL> elif c == '<STR_LIT:->' : ignore = <NUM_LIT:1> <EOL> else : break <EOL> result [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] = result [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> : ] <EOL> try : <EOL> if not result [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] : <EOL> result [ <NUM_LIT:0> ] = result [ <NUM_LIT:0> ] [ <NUM_LIT:1> : ] <EOL> except IndexError : <EOL> pass <EOL> return result , ignore , silent <EOL> def strfunction ( self , target , source , env , executor = None ) : <EOL> if self . cmdstr is None : <EOL> return None <EOL> if self . cmdstr is not _null : <EOL> from SCons . Subst import SUBST_RAW <EOL> if executor : <EOL> c = env . subst ( self . cmdstr , SUBST_RAW , executor = executor ) <EOL> else : <EOL> c = env . subst ( self . cmdstr , SUBST_RAW , target , source ) <EOL> if c : <EOL> return c <EOL> cmd_list , ignore , silent = self . process ( target , source , env , executor ) <EOL> if silent : <EOL> return '<STR_LIT>' <EOL> return _string_from_cmd_list ( cmd_list [ <NUM_LIT:0> ] ) <EOL> def execute ( self , target , source , env , executor = None ) : <EOL> """<STR_LIT>""" <EOL> escape_list = SCons . Subst . escape_list <EOL> flatten_sequence = SCons . Util . flatten_sequence <EOL> try : <EOL> shell = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> raise SCons . Errors . UserError ( '<STR_LIT>' ) <EOL> try : <EOL> spawn = env [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> raise SCons . Errors . UserError ( '<STR_LIT>' ) <EOL> else : <EOL> if is_String ( spawn ) : <EOL> spawn = env . subst ( spawn , raw = <NUM_LIT:1> , conv = lambda x : x ) <EOL> escape = env . get ( '<STR_LIT>' , lambda x : x ) <EOL> ENV = get_default_ENV ( env ) <EOL> for key , value in ENV . items ( ) : <EOL> if not is_String ( value ) : <EOL> if is_List ( value ) : <EOL> value = flatten_sequence ( value ) <EOL> ENV [ key ] = os . pathsep . join ( map ( str , value ) ) <EOL> else : <EOL> ENV [ key ] = str ( value ) <EOL> if executor : <EOL> target = executor . get_all_targets ( ) <EOL> source = executor . get_all_sources ( ) <EOL> cmd_list , ignore , silent = self . process ( target , list ( map ( rfile , source ) ) , env , executor ) <EOL> for cmd_line in filter ( len , cmd_list ) : <EOL> cmd_line = escape_list ( cmd_line , escape ) <EOL> result = spawn ( shell , escape , cmd_line [ <NUM_LIT:0> ] , cmd_line , ENV ) <EOL> if not ignore and result : <EOL> msg = "<STR_LIT>" % result <EOL> return SCons . Errors . BuildError ( errstr = msg , <EOL> status = result , <EOL> action = self , <EOL> command = cmd_line ) <EOL> return <NUM_LIT:0> <EOL> def get_presig ( self , target , source , env , executor = None ) : <EOL> """<STR_LIT>""" <EOL> from SCons . Subst import SUBST_SIG <EOL> cmd = self . cmd_list <EOL> if is_List ( cmd ) : <EOL> cmd = '<STR_LIT:U+0020>' . join ( map ( str , cmd ) ) <EOL> else : <EOL> cmd = str ( cmd ) <EOL> if executor : <EOL> return env . subst_target_source ( cmd , SUBST_SIG , executor = executor ) <EOL> else : <EOL> return env . subst_target_source ( cmd , SUBST_SIG , target , source ) <EOL> def get_implicit_deps ( self , target , source , env , executor = None ) : <EOL> icd = env . get ( '<STR_LIT>' , True ) <EOL> if is_String ( icd ) and icd [ : <NUM_LIT:1> ] == '<STR_LIT:$>' : <EOL> icd = env . subst ( icd ) <EOL> if not icd or icd in ( '<STR_LIT:0>' , '<STR_LIT:None>' ) : <EOL> return [ ] <EOL> from SCons . Subst import SUBST_SIG <EOL> if executor : <EOL> cmd_list = env . subst_list ( self . cmd_list , SUBST_SIG , executor = executor ) <EOL> else : <EOL> cmd_list = env . subst_list ( self . cmd_list , SUBST_SIG , target , source ) <EOL> res = [ ] <EOL> for cmd_line in cmd_list : <EOL> if cmd_line : <EOL> d = str ( cmd_line [ <NUM_LIT:0> ] ) <EOL> m = strip_quotes . match ( d ) <EOL> if m : <EOL> d = m . group ( <NUM_LIT:1> ) <EOL> d = env . WhereIs ( d ) <EOL> if d : <EOL> res . append ( env . fs . File ( d ) ) <EOL> return res <EOL> class CommandGeneratorAction ( ActionBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , generator , kw ) : <EOL> if SCons . Debug . track_instances : logInstanceCreation ( self , '<STR_LIT>' ) <EOL> self . generator = generator <EOL> self . gen_kw = kw <EOL> self . varlist = kw . get ( '<STR_LIT>' , ( ) ) <EOL> self . targets = kw . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def _generate ( self , target , source , env , for_signature , executor = None ) : <EOL> if not is_List ( target ) : <EOL> target = [ target ] <EOL> if executor : <EOL> target = executor . get_all_targets ( ) <EOL> source = executor . get_all_sources ( ) <EOL> ret = self . generator ( target = target , <EOL> source = source , <EOL> env = env , <EOL> for_signature = for_signature ) <EOL> gen_cmd = Action ( ret , ** self . gen_kw ) <EOL> if not gen_cmd : <EOL> raise SCons . Errors . UserError ( "<STR_LIT>" % repr ( ret ) ) <EOL> return gen_cmd <EOL> def __str__ ( self ) : <EOL> try : <EOL> env = self . presub_env <EOL> except AttributeError : <EOL> env = None <EOL> if env is None : <EOL> env = SCons . Defaults . DefaultEnvironment ( ) <EOL> act = self . _generate ( [ ] , [ ] , env , <NUM_LIT:1> ) <EOL> return str ( act ) <EOL> def batch_key ( self , env , target , source ) : <EOL> return self . _generate ( target , source , env , <NUM_LIT:1> ) . batch_key ( env , target , source ) <EOL> def genstring ( self , target , source , env , executor = None ) : <EOL> return self . _generate ( target , source , env , <NUM_LIT:1> , executor ) . genstring ( target , source , env ) <EOL> def __call__ ( self , target , source , env , exitstatfunc = _null , presub = _null , <EOL> show = _null , execute = _null , chdir = _null , executor = None ) : <EOL> act = self . _generate ( target , source , env , <NUM_LIT:0> , executor ) <EOL> if act is None : <EOL> raise SCons . Errors . UserError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> % ( repr ( list ( map ( str , target ) ) ) , repr ( list ( map ( str , source ) ) ) ) ) <EOL> return act ( target , source , env , exitstatfunc , presub , <EOL> show , execute , chdir , executor ) <EOL> def get_presig ( self , target , source , env , executor = None ) : <EOL> """<STR_LIT>""" <EOL> return self . _generate ( target , source , env , <NUM_LIT:1> , executor ) . get_presig ( target , source , env ) <EOL> def get_implicit_deps ( self , target , source , env , executor = None ) : <EOL> return self . _generate ( target , source , env , <NUM_LIT:1> , executor ) . get_implicit_deps ( target , source , env ) <EOL> def get_varlist ( self , target , source , env , executor = None ) : <EOL> return self . _generate ( target , source , env , <NUM_LIT:1> , executor ) . get_varlist ( target , source , env , executor ) <EOL> def get_targets ( self , env , executor ) : <EOL> return self . _generate ( None , None , env , <NUM_LIT:1> , executor ) . get_targets ( env , executor ) <EOL> class LazyAction ( CommandGeneratorAction , CommandAction ) : <EOL> def __init__ ( self , var , kw ) : <EOL> if SCons . Debug . track_instances : logInstanceCreation ( self , '<STR_LIT>' ) <EOL> CommandAction . __init__ ( self , '<STR_LIT>' + var + '<STR_LIT:}>' , ** kw ) <EOL> self . var = SCons . Util . to_String ( var ) <EOL> self . gen_kw = kw <EOL> def get_parent_class ( self , env ) : <EOL> c = env . get ( self . var ) <EOL> if is_String ( c ) and not '<STR_LIT:\n>' in c : <EOL> return CommandAction <EOL> return CommandGeneratorAction <EOL> def _generate_cache ( self , env ) : <EOL> if env : <EOL> c = env . get ( self . var , '<STR_LIT>' ) <EOL> else : <EOL> c = '<STR_LIT>' <EOL> gen_cmd = Action ( c , ** self . gen_kw ) <EOL> if not gen_cmd : <EOL> raise SCons . Errors . UserError ( "<STR_LIT>" % ( self . var , repr ( c ) ) ) <EOL> return gen_cmd <EOL> def _generate ( self , target , source , env , for_signature , executor = None ) : <EOL> return self . _generate_cache ( env ) <EOL> def __call__ ( self , target , source , env , * args , ** kw ) : <EOL> c = self . get_parent_class ( env ) <EOL> return c . __call__ ( self , target , source , env , * args , ** kw ) <EOL> def get_presig ( self , target , source , env ) : <EOL> c = self . get_parent_class ( env ) <EOL> return c . get_presig ( self , target , source , env ) <EOL> def get_varlist ( self , target , source , env , executor = None ) : <EOL> c = self . get_parent_class ( env ) <EOL> return c . get_varlist ( self , target , source , env , executor ) <EOL> class FunctionAction ( _ActionAction ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , execfunction , kw ) : <EOL> if SCons . Debug . track_instances : logInstanceCreation ( self , '<STR_LIT>' ) <EOL> self . execfunction = execfunction <EOL> try : <EOL> self . funccontents = _callable_contents ( execfunction ) <EOL> except AttributeError : <EOL> try : <EOL> self . gc = execfunction . get_contents <EOL> except AttributeError : <EOL> self . funccontents = _object_contents ( execfunction ) <EOL> _ActionAction . __init__ ( self , ** kw ) <EOL> def function_name ( self ) : <EOL> try : <EOL> return self . execfunction . __name__ <EOL> except AttributeError : <EOL> try : <EOL> return self . execfunction . __class__ . __name__ <EOL> except AttributeError : <EOL> return "<STR_LIT>" <EOL> def strfunction ( self , target , source , env , executor = None ) : <EOL> if self . cmdstr is None : <EOL> return None <EOL> if self . cmdstr is not _null : <EOL> from SCons . Subst import SUBST_RAW <EOL> if executor : <EOL> c = env . subst ( self . cmdstr , SUBST_RAW , executor = executor ) <EOL> else : <EOL> c = env . subst ( self . cmdstr , SUBST_RAW , target , source ) <EOL> if c : <EOL> return c <EOL> def array ( a ) : <EOL> def quote ( s ) : <EOL> try : <EOL> str_for_display = s . str_for_display <EOL> except AttributeError : <EOL> s = repr ( s ) <EOL> else : <EOL> s = str_for_display ( ) <EOL> return s <EOL> return '<STR_LIT:[>' + "<STR_LIT:U+002CU+0020>" . join ( map ( quote , a ) ) + '<STR_LIT:]>' <EOL> try : <EOL> strfunc = self . execfunction . strfunction <EOL> except AttributeError : <EOL> pass <EOL> else : <EOL> if strfunc is None : <EOL> return None <EOL> if callable ( strfunc ) : <EOL> return strfunc ( target , source , env ) <EOL> name = self . function_name ( ) <EOL> tstr = array ( target ) <EOL> sstr = array ( source ) <EOL> return "<STR_LIT>" % ( name , tstr , sstr ) <EOL> def __str__ ( self ) : <EOL> name = self . function_name ( ) <EOL> if name == '<STR_LIT>' : <EOL> return str ( self . execfunction ) <EOL> return "<STR_LIT>" % name <EOL> def execute ( self , target , source , env , executor = None ) : <EOL> exc_info = ( None , None , None ) <EOL> try : <EOL> if executor : <EOL> target = executor . get_all_targets ( ) <EOL> source = executor . get_all_sources ( ) <EOL> rsources = list ( map ( rfile , source ) ) <EOL> try : <EOL> result = self . execfunction ( target = target , source = rsources , env = env ) <EOL> except KeyboardInterrupt , e : <EOL> raise <EOL> except SystemExit , e : <EOL> raise <EOL> except Exception , e : <EOL> result = e <EOL> exc_info = sys . exc_info ( ) <EOL> if result : <EOL> result = SCons . Errors . convert_to_BuildError ( result , exc_info ) <EOL> result . node = target <EOL> result . action = self <EOL> try : <EOL> result . command = self . strfunction ( target , source , env , executor ) <EOL> except TypeError : <EOL> result . command = self . strfunction ( target , source , env ) <EOL> if ( exc_info [ <NUM_LIT:1> ] and <EOL> not isinstance ( exc_info [ <NUM_LIT:1> ] , EnvironmentError ) ) : <EOL> raise result <EOL> return result <EOL> finally : <EOL> del exc_info <EOL> def get_presig ( self , target , source , env ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return self . gc ( target , source , env ) <EOL> except AttributeError : <EOL> return self . funccontents <EOL> def get_implicit_deps ( self , target , source , env ) : <EOL> return [ ] <EOL> class ListAction ( ActionBase ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , actionlist ) : <EOL> if SCons . Debug . track_instances : logInstanceCreation ( self , '<STR_LIT>' ) <EOL> def list_of_actions ( x ) : <EOL> if isinstance ( x , ActionBase ) : <EOL> return x <EOL> return Action ( x ) <EOL> self . list = list ( map ( list_of_actions , actionlist ) ) <EOL> self . varlist = ( ) <EOL> self . targets = '<STR_LIT>' <EOL> def genstring ( self , target , source , env ) : <EOL> return '<STR_LIT:\n>' . join ( [ a . genstring ( target , source , env ) for a in self . list ] ) <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT:\n>' . join ( map ( str , self . list ) ) <EOL> def presub_lines ( self , env ) : <EOL> return SCons . Util . flatten_sequence ( <EOL> [ a . presub_lines ( env ) for a in self . list ] ) <EOL> def get_presig ( self , target , source , env ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" . join ( [ x . get_contents ( target , source , env ) for x in self . list ] ) <EOL> def __call__ ( self , target , source , env , exitstatfunc = _null , presub = _null , <EOL> show = _null , execute = _null , chdir = _null , executor = None ) : <EOL> if executor : <EOL> target = executor . get_all_targets ( ) <EOL> source = executor . get_all_sources ( ) <EOL> for act in self . list : <EOL> stat = act ( target , source , env , exitstatfunc , presub , <EOL> show , execute , chdir , executor ) <EOL> if stat : <EOL> return stat <EOL> return <NUM_LIT:0> <EOL> def get_implicit_deps ( self , target , source , env ) : <EOL> result = [ ] <EOL> for act in self . list : <EOL> result . extend ( act . get_implicit_deps ( target , source , env ) ) <EOL> return result <EOL> def get_varlist ( self , target , source , env , executor = None ) : <EOL> result = SCons . Util . OrderedDict ( ) <EOL> for act in self . list : <EOL> for var in act . get_varlist ( target , source , env , executor ) : <EOL> result [ var ] = True <EOL> return list ( result . keys ( ) ) <EOL> class ActionCaller ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , parent , args , kw ) : <EOL> self . parent = parent <EOL> self . args = args <EOL> self . kw = kw <EOL> def get_contents ( self , target , source , env ) : <EOL> actfunc = self . parent . actfunc <EOL> try : <EOL> contents = str ( actfunc . func_code . co_code ) <EOL> except AttributeError : <EOL> try : <EOL> contents = str ( actfunc . __call__ . im_func . func_code . co_code ) <EOL> except AttributeError : <EOL> contents = str ( actfunc ) <EOL> contents = remove_set_lineno_codes ( contents ) <EOL> return contents <EOL> def subst ( self , s , target , source , env ) : <EOL> if is_List ( s ) : <EOL> result = [ ] <EOL> for elem in s : <EOL> result . append ( self . subst ( elem , target , source , env ) ) <EOL> return self . parent . convert ( result ) <EOL> if s == '<STR_LIT>' : <EOL> return env <EOL> elif is_String ( s ) : <EOL> return env . subst ( s , <NUM_LIT:1> , target , source ) <EOL> return self . parent . convert ( s ) <EOL> def subst_args ( self , target , source , env ) : <EOL> return [ self . subst ( x , target , source , env ) for x in self . args ] <EOL> def subst_kw ( self , target , source , env ) : <EOL> kw = { } <EOL> for key in self . kw . keys ( ) : <EOL> kw [ key ] = self . subst ( self . kw [ key ] , target , source , env ) <EOL> return kw <EOL> def __call__ ( self , target , source , env , executor = None ) : <EOL> args = self . subst_args ( target , source , env ) <EOL> kw = self . subst_kw ( target , source , env ) <EOL> return self . parent . actfunc ( * args , ** kw ) <EOL> def strfunction ( self , target , source , env ) : <EOL> args = self . subst_args ( target , source , env ) <EOL> kw = self . subst_kw ( target , source , env ) <EOL> return self . parent . strfunc ( * args , ** kw ) <EOL> def __str__ ( self ) : <EOL> return self . parent . strfunc ( * self . args , ** self . kw ) <EOL> class ActionFactory ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , actfunc , strfunc , convert = lambda x : x ) : <EOL> self . actfunc = actfunc <EOL> self . strfunc = strfunc <EOL> self . convert = convert <EOL> def __call__ ( self , * args , ** kw ) : <EOL> ac = ActionCaller ( self , args , kw ) <EOL> action = Action ( ac , strfunction = ac . strfunction ) <EOL> return action </s>
