<s> """<STR_LIT>""" <EOL> __revision__ = "<STR_LIT>" <EOL> import imp <EOL> import os <EOL> import string <EOL> import sys <EOL> import tempfile <EOL> import SCons . Errors <EOL> import SCons . Tool <EOL> def platform_default ( ) : <EOL> """<STR_LIT>""" <EOL> osname = os . name <EOL> if osname == '<STR_LIT>' : <EOL> osname = os . _osType <EOL> if osname == '<STR_LIT>' : <EOL> if sys . platform == '<STR_LIT>' : <EOL> return '<STR_LIT>' <EOL> elif string . find ( sys . platform , '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> return '<STR_LIT>' <EOL> elif string . find ( sys . platform , '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> return '<STR_LIT>' <EOL> elif string . find ( sys . platform , '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> return '<STR_LIT>' <EOL> elif string . find ( sys . platform , '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> return '<STR_LIT>' <EOL> elif string . find ( sys . platform , '<STR_LIT>' ) != - <NUM_LIT:1> : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return '<STR_LIT>' <EOL> elif os . name == '<STR_LIT>' : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return sys . platform <EOL> def platform_module ( name = platform_default ( ) ) : <EOL> """<STR_LIT>""" <EOL> full_name = '<STR_LIT>' + name <EOL> if not sys . modules . has_key ( full_name ) : <EOL> if os . name == '<STR_LIT>' : <EOL> eval ( full_name ) <EOL> else : <EOL> try : <EOL> file , path , desc = imp . find_module ( name , <EOL> sys . modules [ '<STR_LIT>' ] . __path__ ) <EOL> try : <EOL> mod = imp . load_module ( full_name , file , path , desc ) <EOL> finally : <EOL> if file : <EOL> file . close ( ) <EOL> except ImportError : <EOL> try : <EOL> import zipimport <EOL> importer = zipimport . zipimporter ( sys . modules [ '<STR_LIT>' ] . __path__ [ <NUM_LIT:0> ] ) <EOL> mod = importer . load_module ( full_name ) <EOL> except ImportError : <EOL> raise SCons . Errors . UserError , "<STR_LIT>" % name <EOL> setattr ( SCons . Platform , name , mod ) <EOL> return sys . modules [ full_name ] <EOL> def DefaultToolList ( platform , env ) : <EOL> """<STR_LIT>""" <EOL> return SCons . Tool . tool_list ( platform , env ) <EOL> class PlatformSpec : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __str__ ( self ) : <EOL> return self . name <EOL> class TempFileMunge : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , cmd ) : <EOL> self . cmd = cmd <EOL> def __call__ ( self , target , source , env , for_signature ) : <EOL> if for_signature : <EOL> return self . cmd <EOL> cmd = env . subst_list ( self . cmd , <NUM_LIT:0> , target , source ) [ <NUM_LIT:0> ] <EOL> try : <EOL> maxline = int ( env . subst ( '<STR_LIT>' ) ) <EOL> except ValueError : <EOL> maxline = <NUM_LIT> <EOL> if ( reduce ( lambda x , y : x + len ( y ) , cmd , <NUM_LIT:0> ) + len ( cmd ) ) <= maxline : <EOL> return self . cmd <EOL> tmp = os . path . normpath ( tempfile . mktemp ( '<STR_LIT>' ) ) <EOL> native_tmp = SCons . Util . get_native_path ( tmp ) <EOL> if env [ '<STR_LIT>' ] and env [ '<STR_LIT>' ] == '<STR_LIT>' : <EOL> native_tmp = string . replace ( native_tmp , '<STR_LIT:\\>' , r'<STR_LIT>' ) <EOL> rm = env . Detect ( '<STR_LIT>' ) or '<STR_LIT>' <EOL> else : <EOL> rm = '<STR_LIT>' <EOL> prefix = env . subst ( '<STR_LIT>' ) <EOL> if not prefix : <EOL> prefix = '<STR_LIT:@>' <EOL> args = map ( SCons . Subst . quote_spaces , cmd [ <NUM_LIT:1> : ] ) <EOL> open ( tmp , '<STR_LIT:w>' ) . write ( string . join ( args , "<STR_LIT:U+0020>" ) + "<STR_LIT:\n>" ) <EOL> if SCons . Action . print_actions : <EOL> print ( "<STR_LIT>" + native_tmp + "<STR_LIT>" + <EOL> str ( cmd [ <NUM_LIT:0> ] ) + "<STR_LIT:U+0020>" + string . join ( args , "<STR_LIT:U+0020>" ) ) <EOL> return [ cmd [ <NUM_LIT:0> ] , prefix + native_tmp + '<STR_LIT:\n>' + rm , native_tmp ] <EOL> def Platform ( name = platform_default ( ) ) : <EOL> """<STR_LIT>""" <EOL> module = platform_module ( name ) <EOL> spec = PlatformSpec ( name ) <EOL> spec . __call__ = module . generate <EOL> return spec </s>
