<s> """<STR_LIT>""" <EOL> __revision__ = "<STR_LIT>" <EOL> import string <EOL> import UserList <EOL> from SCons . Debug import logInstanceCreation <EOL> import SCons . Errors <EOL> import SCons . Memoize <EOL> class Batch : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , targets = [ ] , sources = [ ] ) : <EOL> self . targets = targets <EOL> self . sources = sources <EOL> class TSList ( UserList . UserList ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , func ) : <EOL> self . func = func <EOL> def __getattr__ ( self , attr ) : <EOL> nl = self . func ( ) <EOL> return getattr ( nl , attr ) <EOL> def __getitem__ ( self , i ) : <EOL> nl = self . func ( ) <EOL> return nl [ i ] <EOL> def __getslice__ ( self , i , j ) : <EOL> nl = self . func ( ) <EOL> i = max ( i , <NUM_LIT:0> ) ; j = max ( j , <NUM_LIT:0> ) <EOL> return nl [ i : j ] <EOL> def __str__ ( self ) : <EOL> nl = self . func ( ) <EOL> return str ( nl ) <EOL> def __repr__ ( self ) : <EOL> nl = self . func ( ) <EOL> return repr ( nl ) <EOL> class TSObject : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , func ) : <EOL> self . func = func <EOL> def __getattr__ ( self , attr ) : <EOL> n = self . func ( ) <EOL> return getattr ( n , attr ) <EOL> def __str__ ( self ) : <EOL> n = self . func ( ) <EOL> if n : <EOL> return str ( n ) <EOL> return '<STR_LIT>' <EOL> def __repr__ ( self ) : <EOL> n = self . func ( ) <EOL> if n : <EOL> return repr ( n ) <EOL> return '<STR_LIT>' <EOL> def rfile ( node ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> rfile = node . rfile <EOL> except AttributeError : <EOL> return node <EOL> else : <EOL> return rfile ( ) <EOL> class Executor : <EOL> """<STR_LIT>""" <EOL> if SCons . Memoize . use_memoizer : <EOL> __metaclass__ = SCons . Memoize . Memoized_Metaclass <EOL> memoizer_counters = [ ] <EOL> def __init__ ( self , action , env = None , overridelist = [ { } ] , <EOL> targets = [ ] , sources = [ ] , builder_kw = { } ) : <EOL> if __debug__ : logInstanceCreation ( self , '<STR_LIT>' ) <EOL> self . set_action_list ( action ) <EOL> self . pre_actions = [ ] <EOL> self . post_actions = [ ] <EOL> self . env = env <EOL> self . overridelist = overridelist <EOL> if targets or sources : <EOL> self . batches = [ Batch ( targets [ : ] , sources [ : ] ) ] <EOL> else : <EOL> self . batches = [ ] <EOL> self . builder_kw = builder_kw <EOL> self . _memo = { } <EOL> def get_lvars ( self ) : <EOL> try : <EOL> return self . lvars <EOL> except AttributeError : <EOL> self . lvars = { <EOL> '<STR_LIT>' : TSList ( self . _get_changed_sources ) , <EOL> '<STR_LIT>' : TSList ( self . _get_changed_targets ) , <EOL> '<STR_LIT>' : TSObject ( self . _get_source ) , <EOL> '<STR_LIT>' : TSList ( self . _get_sources ) , <EOL> '<STR_LIT>' : TSObject ( self . _get_target ) , <EOL> '<STR_LIT>' : TSList ( self . _get_targets ) , <EOL> '<STR_LIT>' : TSList ( self . _get_unchanged_sources ) , <EOL> '<STR_LIT>' : TSList ( self . _get_unchanged_targets ) , <EOL> } <EOL> return self . lvars <EOL> def _get_changes ( self ) : <EOL> cs = [ ] <EOL> ct = [ ] <EOL> us = [ ] <EOL> ut = [ ] <EOL> for b in self . batches : <EOL> if b . targets [ <NUM_LIT:0> ] . changed ( ) : <EOL> cs . extend ( map ( rfile , b . sources ) ) <EOL> ct . extend ( b . targets ) <EOL> else : <EOL> us . extend ( map ( rfile , b . sources ) ) <EOL> ut . extend ( b . targets ) <EOL> self . _changed_sources_list = SCons . Util . NodeList ( cs ) <EOL> self . _changed_targets_list = SCons . Util . NodeList ( ct ) <EOL> self . _unchanged_sources_list = SCons . Util . NodeList ( us ) <EOL> self . _unchanged_targets_list = SCons . Util . NodeList ( ut ) <EOL> def _get_changed_sources ( self , * args , ** kw ) : <EOL> try : <EOL> return self . _changed_sources_list <EOL> except AttributeError : <EOL> self . _get_changes ( ) <EOL> return self . _changed_sources_list <EOL> def _get_changed_targets ( self , * args , ** kw ) : <EOL> try : <EOL> return self . _changed_targets_list <EOL> except AttributeError : <EOL> self . _get_changes ( ) <EOL> return self . _changed_targets_list <EOL> def _get_source ( self , * args , ** kw ) : <EOL> return rfile ( self . batches [ <NUM_LIT:0> ] . sources [ <NUM_LIT:0> ] ) . get_subst_proxy ( ) <EOL> def _get_sources ( self , * args , ** kw ) : <EOL> return SCons . Util . NodeList ( map ( lambda n : rfile ( n ) . get_subst_proxy ( ) , self . get_all_sources ( ) ) ) <EOL> def _get_target ( self , * args , ** kw ) : <EOL> return self . batches [ <NUM_LIT:0> ] . targets [ <NUM_LIT:0> ] . get_subst_proxy ( ) <EOL> def _get_targets ( self , * args , ** kw ) : <EOL> return SCons . Util . NodeList ( map ( lambda n : n . get_subst_proxy ( ) , self . get_all_targets ( ) ) ) <EOL> def _get_unchanged_sources ( self , * args , ** kw ) : <EOL> try : <EOL> return self . _unchanged_sources_list <EOL> except AttributeError : <EOL> self . _get_changes ( ) <EOL> return self . _unchanged_sources_list <EOL> def _get_unchanged_targets ( self , * args , ** kw ) : <EOL> try : <EOL> return self . _unchanged_targets_list <EOL> except AttributeError : <EOL> self . _get_changes ( ) <EOL> return self . _unchanged_targets_list <EOL> def get_action_targets ( self ) : <EOL> if not self . action_list : <EOL> return [ ] <EOL> targets_string = self . action_list [ <NUM_LIT:0> ] . get_targets ( self . env , self ) <EOL> if targets_string [ <NUM_LIT:0> ] == '<STR_LIT:$>' : <EOL> targets_string = targets_string [ <NUM_LIT:1> : ] <EOL> return self . get_lvars ( ) [ targets_string ] <EOL> def set_action_list ( self , action ) : <EOL> import SCons . Util <EOL> if not SCons . Util . is_List ( action ) : <EOL> if not action : <EOL> import SCons . Errors <EOL> raise SCons . Errors . UserError , "<STR_LIT>" <EOL> action = [ action ] <EOL> self . action_list = action <EOL> def get_action_list ( self ) : <EOL> return self . pre_actions + self . action_list + self . post_actions <EOL> def get_all_targets ( self ) : <EOL> """<STR_LIT>""" <EOL> result = [ ] <EOL> for batch in self . batches : <EOL> result . extend ( list ( batch . targets ) ) <EOL> return result <EOL> def get_all_sources ( self ) : <EOL> """<STR_LIT>""" <EOL> result = [ ] <EOL> for batch in self . batches : <EOL> result . extend ( list ( batch . sources ) ) <EOL> return result <EOL> def get_all_children ( self ) : <EOL> """<STR_LIT>""" <EOL> result = SCons . Util . UniqueList ( [ ] ) <EOL> for target in self . get_all_targets ( ) : <EOL> result . extend ( target . children ( ) ) <EOL> return result <EOL> def get_all_prerequisites ( self ) : <EOL> """<STR_LIT>""" <EOL> result = SCons . Util . UniqueList ( [ ] ) <EOL> for target in self . get_all_targets ( ) : <EOL> result . extend ( list ( target . prerequisites ) ) <EOL> return result <EOL> def get_action_side_effects ( self ) : <EOL> """<STR_LIT>""" <EOL> result = SCons . Util . UniqueList ( [ ] ) <EOL> for target in self . get_action_targets ( ) : <EOL> result . extend ( target . side_effects ) <EOL> return result <EOL> memoizer_counters . append ( SCons . Memoize . CountValue ( '<STR_LIT>' ) ) <EOL> def get_build_env ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return self . _memo [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> pass <EOL> overrides = { } <EOL> for odict in self . overridelist : <EOL> overrides . update ( odict ) <EOL> import SCons . Defaults <EOL> env = self . env or SCons . Defaults . DefaultEnvironment ( ) <EOL> build_env = env . Override ( overrides ) <EOL> self . _memo [ '<STR_LIT>' ] = build_env <EOL> return build_env <EOL> def get_build_scanner_path ( self , scanner ) : <EOL> """<STR_LIT>""" <EOL> env = self . get_build_env ( ) <EOL> try : <EOL> cwd = self . batches [ <NUM_LIT:0> ] . targets [ <NUM_LIT:0> ] . cwd <EOL> except ( IndexError , AttributeError ) : <EOL> cwd = None <EOL> return scanner . path ( env , cwd , <EOL> self . get_all_targets ( ) , <EOL> self . get_all_sources ( ) ) <EOL> def get_kw ( self , kw = { } ) : <EOL> result = self . builder_kw . copy ( ) <EOL> result . update ( kw ) <EOL> result [ '<STR_LIT>' ] = self <EOL> return result <EOL> def do_nothing ( self , target , kw ) : <EOL> return <NUM_LIT:0> <EOL> def do_execute ( self , target , kw ) : <EOL> """<STR_LIT>""" <EOL> env = self . get_build_env ( ) <EOL> kw = self . get_kw ( kw ) <EOL> status = <NUM_LIT:0> <EOL> for act in self . get_action_list ( ) : <EOL> args = ( [ ] , [ ] , env ) <EOL> status = apply ( act , args , kw ) <EOL> if isinstance ( status , SCons . Errors . BuildError ) : <EOL> status . executor = self <EOL> raise status <EOL> elif status : <EOL> msg = "<STR_LIT>" % status <EOL> raise SCons . Errors . BuildError ( <EOL> errstr = msg , <EOL> node = self . batches [ <NUM_LIT:0> ] . targets , <EOL> executor = self , <EOL> action = act ) <EOL> return status <EOL> def __call__ ( self , target , ** kw ) : <EOL> return self . do_execute ( target , kw ) <EOL> def cleanup ( self ) : <EOL> self . _memo = { } <EOL> def add_sources ( self , sources ) : <EOL> """<STR_LIT>""" <EOL> assert ( len ( self . batches ) == <NUM_LIT:1> ) <EOL> sources = filter ( lambda x , s = self . batches [ <NUM_LIT:0> ] . sources : x not in s , sources ) <EOL> self . batches [ <NUM_LIT:0> ] . sources . extend ( sources ) <EOL> def get_sources ( self ) : <EOL> return self . batches [ <NUM_LIT:0> ] . sources <EOL> def add_batch ( self , targets , sources ) : <EOL> """<STR_LIT>""" <EOL> self . batches . append ( Batch ( targets , sources ) ) <EOL> def prepare ( self ) : <EOL> """<STR_LIT>""" <EOL> for s in self . get_all_sources ( ) : <EOL> if s . missing ( ) : <EOL> msg = "<STR_LIT>" <EOL> raise SCons . Errors . StopError , msg % ( s , self . batches [ <NUM_LIT:0> ] . targets [ <NUM_LIT:0> ] ) <EOL> def add_pre_action ( self , action ) : <EOL> self . pre_actions . append ( action ) <EOL> def add_post_action ( self , action ) : <EOL> self . post_actions . append ( action ) <EOL> def my_str ( self ) : <EOL> env = self . get_build_env ( ) <EOL> get = lambda action , t = self . get_all_targets ( ) , s = self . get_all_sources ( ) , e = env : action . genstring ( t , s , e ) <EOL> return string . join ( map ( get , self . get_action_list ( ) ) , "<STR_LIT:\n>" ) <EOL> def __str__ ( self ) : <EOL> return self . my_str ( ) <EOL> def nullify ( self ) : <EOL> self . cleanup ( ) <EOL> self . do_execute = self . do_nothing <EOL> self . my_str = lambda S = self : '<STR_LIT>' <EOL> memoizer_counters . append ( SCons . Memoize . CountValue ( '<STR_LIT>' ) ) <EOL> def get_contents ( self ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return self . _memo [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> pass <EOL> env = self . get_build_env ( ) <EOL> get = lambda action , t = self . get_all_targets ( ) , s = self . get_all_sources ( ) , e = env : action . get_contents ( t , s , e ) <EOL> result = string . join ( map ( get , self . get_action_list ( ) ) , "<STR_LIT>" ) <EOL> self . _memo [ '<STR_LIT>' ] = result <EOL> return result <EOL> def get_timestamp ( self ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def scan_targets ( self , scanner ) : <EOL> self . scan ( scanner , self . get_all_targets ( ) ) <EOL> def scan_sources ( self , scanner ) : <EOL> if self . batches [ <NUM_LIT:0> ] . sources : <EOL> self . scan ( scanner , self . get_all_sources ( ) ) <EOL> def scan ( self , scanner , node_list ) : <EOL> """<STR_LIT>""" <EOL> env = self . get_build_env ( ) <EOL> deps = [ ] <EOL> if scanner : <EOL> for node in node_list : <EOL> node . disambiguate ( ) <EOL> s = scanner . select ( node ) <EOL> if not s : <EOL> continue <EOL> path = self . get_build_scanner_path ( s ) <EOL> deps . extend ( node . get_implicit_deps ( env , s , path ) ) <EOL> else : <EOL> kw = self . get_kw ( ) <EOL> for node in node_list : <EOL> node . disambiguate ( ) <EOL> scanner = node . get_env_scanner ( env , kw ) <EOL> if not scanner : <EOL> continue <EOL> scanner = scanner . select ( node ) <EOL> if not scanner : <EOL> continue <EOL> path = self . get_build_scanner_path ( scanner ) <EOL> deps . extend ( node . get_implicit_deps ( env , scanner , path ) ) <EOL> deps . extend ( self . get_implicit_deps ( ) ) <EOL> for tgt in self . get_all_targets ( ) : <EOL> tgt . add_to_implicit ( deps ) <EOL> def _get_unignored_sources_key ( self , node , ignore = ( ) ) : <EOL> return ( node , ) + tuple ( ignore ) <EOL> memoizer_counters . append ( SCons . Memoize . CountDict ( '<STR_LIT>' , _get_unignored_sources_key ) ) <EOL> def get_unignored_sources ( self , node , ignore = ( ) ) : <EOL> key = ( node , ) + tuple ( ignore ) <EOL> try : <EOL> memo_dict = self . _memo [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> memo_dict = { } <EOL> self . _memo [ '<STR_LIT>' ] = memo_dict <EOL> else : <EOL> try : <EOL> return memo_dict [ key ] <EOL> except KeyError : <EOL> pass <EOL> if node : <EOL> sourcelist = [ ] <EOL> for b in self . batches : <EOL> if node in b . targets : <EOL> sourcelist = b . sources <EOL> break <EOL> else : <EOL> sourcelist = self . get_all_sources ( ) <EOL> if ignore : <EOL> idict = { } <EOL> for i in ignore : <EOL> idict [ i ] = <NUM_LIT:1> <EOL> sourcelist = filter ( lambda s , i = idict : not i . has_key ( s ) , sourcelist ) <EOL> memo_dict [ key ] = sourcelist <EOL> return sourcelist <EOL> def get_implicit_deps ( self ) : <EOL> """<STR_LIT>""" <EOL> result = [ ] <EOL> build_env = self . get_build_env ( ) <EOL> for act in self . get_action_list ( ) : <EOL> deps = act . get_implicit_deps ( self . get_all_targets ( ) , <EOL> self . get_all_sources ( ) , <EOL> build_env ) <EOL> result . extend ( deps ) <EOL> return result <EOL> _batch_executors = { } <EOL> def GetBatchExecutor ( key ) : <EOL> return _batch_executors [ key ] <EOL> def AddBatchExecutor ( key , executor ) : <EOL> assert not _batch_executors . has_key ( key ) <EOL> _batch_executors [ key ] = executor <EOL> nullenv = None <EOL> def get_NullEnvironment ( ) : <EOL> """<STR_LIT>""" <EOL> global nullenv <EOL> import SCons . Util <EOL> class NullEnvironment ( SCons . Util . Null ) : <EOL> import SCons . CacheDir <EOL> _CacheDir_path = None <EOL> _CacheDir = SCons . CacheDir . CacheDir ( None ) <EOL> def get_CacheDir ( self ) : <EOL> return self . _CacheDir <EOL> if not nullenv : <EOL> nullenv = NullEnvironment ( ) <EOL> return nullenv <EOL> class Null : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * args , ** kw ) : <EOL> if __debug__ : logInstanceCreation ( self , '<STR_LIT>' ) <EOL> self . batches = [ Batch ( kw [ '<STR_LIT>' ] [ : ] , [ ] ) ] <EOL> def get_build_env ( self ) : <EOL> return get_NullEnvironment ( ) <EOL> def get_build_scanner_path ( self ) : <EOL> return None <EOL> def cleanup ( self ) : <EOL> pass <EOL> def prepare ( self ) : <EOL> pass <EOL> def get_unignored_sources ( self , * args , ** kw ) : <EOL> return tuple ( ( ) ) <EOL> def get_action_targets ( self ) : <EOL> return [ ] <EOL> def get_action_list ( self ) : <EOL> return [ ] <EOL> def get_all_targets ( self ) : <EOL> return self . batches [ <NUM_LIT:0> ] . targets <EOL> def get_all_sources ( self ) : <EOL> return self . batches [ <NUM_LIT:0> ] . targets [ <NUM_LIT:0> ] . sources <EOL> def get_all_children ( self ) : <EOL> return self . get_all_sources ( ) <EOL> def get_all_prerequisites ( self ) : <EOL> return [ ] <EOL> def get_action_side_effects ( self ) : <EOL> return [ ] <EOL> def __call__ ( self , * args , ** kw ) : <EOL> return <NUM_LIT:0> <EOL> def get_contents ( self ) : <EOL> return '<STR_LIT>' <EOL> def _morph ( self ) : <EOL> """<STR_LIT>""" <EOL> batches = self . batches <EOL> self . __class__ = Executor <EOL> self . __init__ ( [ ] ) <EOL> self . batches = batches <EOL> def add_pre_action ( self , action ) : <EOL> self . _morph ( ) <EOL> self . add_pre_action ( action ) <EOL> def add_post_action ( self , action ) : <EOL> self . _morph ( ) <EOL> self . add_post_action ( action ) <EOL> def set_action_list ( self , action ) : <EOL> self . _morph ( ) <EOL> self . set_action_list ( action ) </s>
