<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import os <EOL> import shutil <EOL> import sys <EOL> from anvil . cache import RuleCache , FileRuleCache <EOL> from anvil . context import BuildEnvironment , BuildContext <EOL> from anvil . project import FileModuleResolver , Project <EOL> from anvil . task import InProcessTaskExecutor , MultiProcessTaskExecutor <EOL> def clean_output ( cwd ) : <EOL> """<STR_LIT>""" <EOL> nuke_paths = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> any_failed = False <EOL> for path in nuke_paths : <EOL> full_path = os . path . join ( cwd , path ) <EOL> if os . path . isdir ( full_path ) : <EOL> try : <EOL> shutil . rmtree ( full_path ) <EOL> except Exception as e : <EOL> print '<STR_LIT>' % ( full_path , e ) <EOL> any_failed = True <EOL> return not any_failed <EOL> def run_build ( cwd , parsed_args ) : <EOL> """<STR_LIT>""" <EOL> if not len ( parsed_args . targets ) : <EOL> return ( True , [ ] ) <EOL> build_env = BuildEnvironment ( root_path = cwd ) <EOL> module_resolver = FileModuleResolver ( cwd ) <EOL> project = Project ( module_resolver = module_resolver ) <EOL> if parsed_args . jobs is None : <EOL> if ( sys . platform == '<STR_LIT>' or <EOL> sys . platform == '<STR_LIT:win32>' ) : <EOL> parsed_args . jobs = <NUM_LIT:1> <EOL> if parsed_args . jobs == <NUM_LIT:1> : <EOL> task_executor = InProcessTaskExecutor ( ) <EOL> else : <EOL> task_executor = MultiProcessTaskExecutor ( worker_count = parsed_args . jobs ) <EOL> print '<STR_LIT>' % ( parsed_args . targets ) <EOL> if not parsed_args . force : <EOL> cache_path = os . getcwd ( ) <EOL> rule_cache = FileRuleCache ( cache_path ) <EOL> else : <EOL> rule_cache = RuleCache ( ) <EOL> all_target_outputs = set ( [ ] ) <EOL> with BuildContext ( build_env , project , <EOL> rule_cache = rule_cache , <EOL> task_executor = task_executor , <EOL> force = parsed_args . force , <EOL> stop_on_error = parsed_args . stop_on_error , <EOL> raise_on_error = False ) as build_ctx : <EOL> result = build_ctx . execute_sync ( parsed_args . targets ) <EOL> if result : <EOL> for target in parsed_args . targets : <EOL> ( state , target_outputs ) = build_ctx . get_rule_results ( target ) <EOL> all_target_outputs . update ( target_outputs ) <EOL> return ( result == True , all_target_outputs ) </s>
