<s> """<STR_LIT>""" <EOL> __revision__ = "<STR_LIT>" <EOL> import os <EOL> import os . path <EOL> import sys <EOL> import tempfile <EOL> from SCons . Platform . posix import exitvalmap <EOL> from SCons . Platform import TempFileMunge <EOL> import SCons . Util <EOL> try : <EOL> import msvcrt <EOL> import win32api <EOL> import win32con <EOL> msvcrt . get_osfhandle <EOL> win32api . SetHandleInformation <EOL> win32con . HANDLE_FLAG_INHERIT <EOL> except ImportError : <EOL> parallel_msg = "<STR_LIT>" + "<STR_LIT>" <EOL> except AttributeError : <EOL> parallel_msg = "<STR_LIT>" + "<STR_LIT>" <EOL> else : <EOL> parallel_msg = None <EOL> import builtins <EOL> _builtin_file = builtins . file <EOL> _builtin_open = builtins . open <EOL> class _scons_file ( _builtin_file ) : <EOL> def __init__ ( self , * args , ** kw ) : <EOL> _builtin_file . __init__ ( self , * args , ** kw ) <EOL> win32api . SetHandleInformation ( msvcrt . get_osfhandle ( self . fileno ( ) ) , <EOL> win32con . HANDLE_FLAG_INHERIT , <NUM_LIT:0> ) <EOL> def _scons_open ( * args , ** kw ) : <EOL> fp = _builtin_open ( * args , ** kw ) <EOL> win32api . SetHandleInformation ( msvcrt . get_osfhandle ( fp . fileno ( ) ) , <EOL> win32con . HANDLE_FLAG_INHERIT , <EOL> <NUM_LIT:0> ) <EOL> return fp <EOL> builtins . file = _scons_file <EOL> builtins . open = _scons_open <EOL> try : <EOL> import threading <EOL> spawn_lock = threading . Lock ( ) <EOL> def spawnve ( mode , file , args , env ) : <EOL> spawn_lock . acquire ( ) <EOL> try : <EOL> if mode == os . P_WAIT : <EOL> ret = os . spawnve ( os . P_NOWAIT , file , args , env ) <EOL> else : <EOL> ret = os . spawnve ( mode , file , args , env ) <EOL> finally : <EOL> spawn_lock . release ( ) <EOL> if mode == os . P_WAIT : <EOL> pid , status = os . waitpid ( ret , <NUM_LIT:0> ) <EOL> ret = status >> <NUM_LIT:8> <EOL> return ret <EOL> except ImportError : <EOL> def spawnve ( mode , file , args , env ) : <EOL> return os . spawnve ( mode , file , args , env ) <EOL> def piped_spawn ( sh , escape , cmd , args , env , stdout , stderr ) : <EOL> if not sh : <EOL> sys . stderr . write ( "<STR_LIT>" ) <EOL> return <NUM_LIT> <EOL> else : <EOL> tmpFileStdout = os . path . normpath ( tempfile . mktemp ( ) ) <EOL> tmpFileStderr = os . path . normpath ( tempfile . mktemp ( ) ) <EOL> stdoutRedirected = <NUM_LIT:0> <EOL> stderrRedirected = <NUM_LIT:0> <EOL> for arg in args : <EOL> if ( arg . find ( "<STR_LIT:>>" , <NUM_LIT:0> , <NUM_LIT:1> ) != - <NUM_LIT:1> or <EOL> arg . find ( "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:2> ) != - <NUM_LIT:1> ) : <EOL> stdoutRedirected = <NUM_LIT:1> <EOL> if arg . find ( "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:2> ) != - <NUM_LIT:1> : <EOL> stderrRedirected = <NUM_LIT:1> <EOL> if stdoutRedirected == <NUM_LIT:0> : <EOL> args . append ( "<STR_LIT:>>" + str ( tmpFileStdout ) ) <EOL> if stderrRedirected == <NUM_LIT:0> : <EOL> args . append ( "<STR_LIT>" + str ( tmpFileStderr ) ) <EOL> try : <EOL> args = [ sh , '<STR_LIT>' , escape ( '<STR_LIT:U+0020>' . join ( args ) ) ] <EOL> ret = spawnve ( os . P_WAIT , sh , args , env ) <EOL> except OSError , e : <EOL> try : <EOL> ret = exitvalmap [ e [ <NUM_LIT:0> ] ] <EOL> except KeyError : <EOL> sys . stderr . write ( "<STR_LIT>" % ( e [ <NUM_LIT:0> ] , cmd , e [ <NUM_LIT:1> ] ) ) <EOL> if stderr is not None : <EOL> stderr . write ( "<STR_LIT>" % ( cmd , e [ <NUM_LIT:1> ] ) ) <EOL> if stdout is not None and stdoutRedirected == <NUM_LIT:0> : <EOL> try : <EOL> stdout . write ( open ( tmpFileStdout , "<STR_LIT:r>" ) . read ( ) ) <EOL> os . remove ( tmpFileStdout ) <EOL> except ( IOError , OSError ) : <EOL> pass <EOL> if stderr is not None and stderrRedirected == <NUM_LIT:0> : <EOL> try : <EOL> stderr . write ( open ( tmpFileStderr , "<STR_LIT:r>" ) . read ( ) ) <EOL> os . remove ( tmpFileStderr ) <EOL> except ( IOError , OSError ) : <EOL> pass <EOL> return ret <EOL> def exec_spawn ( l , env ) : <EOL> try : <EOL> result = spawnve ( os . P_WAIT , l [ <NUM_LIT:0> ] , l , env ) <EOL> except OSError , e : <EOL> try : <EOL> result = exitvalmap [ e [ <NUM_LIT:0> ] ] <EOL> sys . stderr . write ( "<STR_LIT>" % ( l [ <NUM_LIT:0> ] , e [ <NUM_LIT:1> ] ) ) <EOL> except KeyError : <EOL> result = <NUM_LIT> <EOL> if len ( l ) > <NUM_LIT:2> : <EOL> if len ( l [ <NUM_LIT:2> ] ) < <NUM_LIT:1000> : <EOL> command = '<STR_LIT:U+0020>' . join ( l [ <NUM_LIT:0> : <NUM_LIT:3> ] ) <EOL> else : <EOL> command = l [ <NUM_LIT:0> ] <EOL> else : <EOL> command = l [ <NUM_LIT:0> ] <EOL> sys . stderr . write ( "<STR_LIT>" % ( e [ <NUM_LIT:0> ] , command , e [ <NUM_LIT:1> ] ) ) <EOL> return result <EOL> def spawn ( sh , escape , cmd , args , env ) : <EOL> if not sh : <EOL> sys . stderr . write ( "<STR_LIT>" ) <EOL> return <NUM_LIT> <EOL> return exec_spawn ( [ sh , '<STR_LIT>' , escape ( '<STR_LIT:U+0020>' . join ( args ) ) ] , env ) <EOL> def escape ( x ) : <EOL> if x [ - <NUM_LIT:1> ] == '<STR_LIT:\\>' : <EOL> x = x + '<STR_LIT:\\>' <EOL> return '<STR_LIT:">' + x + '<STR_LIT:">' <EOL> _system_root = None <EOL> def get_system_root ( ) : <EOL> global _system_root <EOL> if _system_root is not None : <EOL> return _system_root <EOL> val = os . environ . get ( '<STR_LIT>' , "<STR_LIT>" ) <EOL> if SCons . Util . can_read_reg : <EOL> try : <EOL> k = SCons . Util . RegOpenKeyEx ( SCons . Util . hkey_mod . HKEY_LOCAL_MACHINE , <EOL> '<STR_LIT>' ) <EOL> val , tok = SCons . Util . RegQueryValueEx ( k , '<STR_LIT>' ) <EOL> except SCons . Util . RegError : <EOL> try : <EOL> k = SCons . Util . RegOpenKeyEx ( SCons . Util . hkey_mod . HKEY_LOCAL_MACHINE , <EOL> '<STR_LIT>' ) <EOL> val , tok = SCons . Util . RegQueryValueEx ( k , '<STR_LIT>' ) <EOL> except KeyboardInterrupt : <EOL> raise <EOL> except : <EOL> pass <EOL> _system_root = val <EOL> return val <EOL> def get_program_files_dir ( ) : <EOL> val = '<STR_LIT>' <EOL> if SCons . Util . can_read_reg : <EOL> try : <EOL> k = SCons . Util . RegOpenKeyEx ( SCons . Util . hkey_mod . HKEY_LOCAL_MACHINE , <EOL> '<STR_LIT>' ) <EOL> val , tok = SCons . Util . RegQueryValueEx ( k , '<STR_LIT>' ) <EOL> except SCons . Util . RegError : <EOL> val = '<STR_LIT>' <EOL> pass <EOL> if val == '<STR_LIT>' : <EOL> val = os . path . join ( os . path . dirname ( get_system_root ( ) ) , "<STR_LIT>" ) <EOL> return val <EOL> class ArchDefinition ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , arch , synonyms = [ ] ) : <EOL> self . arch = arch <EOL> self . synonyms = synonyms <EOL> SupportedArchitectureList = [ <EOL> ArchDefinition ( <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> ) , <EOL> ArchDefinition ( <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> ) , <EOL> ArchDefinition ( <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' ] , <EOL> ) , <EOL> ] <EOL> SupportedArchitectureMap = { } <EOL> for a in SupportedArchitectureList : <EOL> SupportedArchitectureMap [ a . arch ] = a <EOL> for s in a . synonyms : <EOL> SupportedArchitectureMap [ s ] = a <EOL> def get_architecture ( arch = None ) : <EOL> """<STR_LIT>""" <EOL> if arch is None : <EOL> arch = os . environ . get ( '<STR_LIT>' ) <EOL> if not arch : <EOL> arch = os . environ . get ( '<STR_LIT>' ) <EOL> return SupportedArchitectureMap . get ( arch , ArchDefinition ( '<STR_LIT>' , [ '<STR_LIT>' ] ) ) <EOL> def generate ( env ) : <EOL> cmd_interp = '<STR_LIT>' <EOL> if SCons . Util . can_read_reg : <EOL> try : <EOL> k = SCons . Util . RegOpenKeyEx ( SCons . Util . hkey_mod . HKEY_LOCAL_MACHINE , <EOL> '<STR_LIT>' ) <EOL> val , tok = SCons . Util . RegQueryValueEx ( k , '<STR_LIT>' ) <EOL> cmd_interp = os . path . join ( val , '<STR_LIT>' ) <EOL> except SCons . Util . RegError : <EOL> try : <EOL> k = SCons . Util . RegOpenKeyEx ( SCons . Util . hkey_mod . HKEY_LOCAL_MACHINE , <EOL> '<STR_LIT>' ) <EOL> val , tok = SCons . Util . RegQueryValueEx ( k , '<STR_LIT>' ) <EOL> cmd_interp = os . path . join ( val , '<STR_LIT>' ) <EOL> except KeyboardInterrupt : <EOL> raise <EOL> except : <EOL> pass <EOL> if not cmd_interp : <EOL> systemroot = get_system_root ( ) <EOL> tmp_path = systemroot + os . pathsep + os . path . join ( systemroot , '<STR_LIT>' ) <EOL> tmp_pathext = '<STR_LIT>' <EOL> if '<STR_LIT>' in os . environ : <EOL> tmp_pathext = os . environ [ '<STR_LIT>' ] <EOL> cmd_interp = SCons . Util . WhereIs ( '<STR_LIT>' , tmp_path , tmp_pathext ) <EOL> if not cmd_interp : <EOL> cmd_interp = SCons . Util . WhereIs ( '<STR_LIT>' , tmp_path , tmp_pathext ) <EOL> if not cmd_interp : <EOL> cmd_interp = env . Detect ( '<STR_LIT>' ) <EOL> if not cmd_interp : <EOL> cmd_interp = env . Detect ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' not in env : <EOL> env [ '<STR_LIT>' ] = { } <EOL> import_env = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> for var in import_env : <EOL> v = os . environ . get ( var ) <EOL> if v : <EOL> env [ '<STR_LIT>' ] [ var ] = v <EOL> if '<STR_LIT>' not in env [ '<STR_LIT>' ] : <EOL> v = os . environ . get ( "<STR_LIT>" ) <EOL> if v : <EOL> env [ '<STR_LIT>' ] [ '<STR_LIT>' ] = v <EOL> env . AppendENVPath ( '<STR_LIT>' , get_system_root ( ) + '<STR_LIT>' ) <EOL> env [ '<STR_LIT>' ] [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> env [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> env [ '<STR_LIT>' ] = [ '<STR_LIT>' ] <EOL> env [ '<STR_LIT>' ] = piped_spawn <EOL> env [ '<STR_LIT>' ] = spawn <EOL> env [ '<STR_LIT>' ] = cmd_interp <EOL> env [ '<STR_LIT>' ] = TempFileMunge <EOL> env [ '<STR_LIT>' ] = '<STR_LIT:@>' <EOL> env [ '<STR_LIT>' ] = <NUM_LIT> <EOL> env [ '<STR_LIT>' ] = escape <EOL> env [ '<STR_LIT>' ] = '<STR_LIT:win32>' <EOL> env [ '<STR_LIT>' ] = get_architecture ( ) . arch </s>
