� {fc@s�dZdZddlZddlZddlZddlZddlmZmZm Z m Z m Z ddl m Z mZddlmZddlmZddlZejZejZejZejZejejejejfZ ej!dkoej"d%kZ#e#r'd Z$d Z%d Z&dZ'ndZ$dZ%dZ&dZ'idd6dd6dd6Z(dd&d��YZ)dd'd��YZ*d�Z+d�Z,d�Z-d�Z.dd �Z/e+�Z0e0d!kr�ed"e0��nd#e fd$��YZ1dS((s distutils.msvc9compiler Contains MSVCCompiler, an implementation of the abstract CCompiler class for the Microsoft Visual Studio 2008. The module is compatible with VS 2005 and VS 2008. You can find legacy support for older versions of VS in distutils.msvccompiler. s$Id$i����N(tDistutilsExecErrortDistutilsPlatformErrort CompileErrortLibErrort LinkError(t CCompilertgen_lib_options(tlog(t get_platformtwin32ii s1Software\Wow6432Node\Microsoft\VisualStudio\%0.1fs.Software\Wow6432Node\Microsoft\VCExpress\%0.1fs5Software\Wow6432Node\Microsoft\Microsoft SDKs\Windowss,Software\Wow6432Node\Microsoft\.NETFrameworks%Software\Microsoft\VisualStudio\%0.1fs"Software\Microsoft\VCExpress\%0.1fs)Software\Microsoft\Microsoft SDKs\Windowss Software\Microsoft\.NETFrameworktx86tamd64s win-amd64tia64swin-ia64tRegcBsbeZdZd�Zee�Zd�Zee�Zd�Zee�Zd�Zee�ZRS(s2Helper class to read values from the registry cCsMx:tD]2}|j||�}|r||kr||SqWt|��dS(N(tHKEYSt read_valuestKeyError(tclstpathtkeytbasetd((s//usr/lib64/python2.7/distutils/msvc9compiler.pyt get_valueDs   cCs�yt||�}Wntk r'dSXg}d}xItryt||�}Wntk rdPnX|j|�|d7}q7W|S(sReturn list of registry keys.iiN(t RegOpenKeyExtRegErrortNonetTruet RegEnumKeytappend(RRRthandletLtitk((s//usr/lib64/python2.7/distutils/msvc9compiler.pyt read_keysLs    c Cs�yt||�}Wntk r'dSXi}d}xmtr�yt||�\}}}Wntk rmPnX|j�}|j|�||j|�<|d7}q7W|S(s`Return dict of registry keys and values. All names are converted to lowercase. iiN(RRRRt RegEnumValuetlowert convert_mbcs( RRRRRRtnametvaluettype((s//usr/lib64/python2.7/distutils/msvc9compiler.pyR^s    cCsIt|dd�}|dk rEy|d�}WqEtk rAqEXn|S(Ntdecodetmbcs(tgetattrRt UnicodeError(tstdec((s//usr/lib64/python2.7/distutils/msvc9compiler.pyR$ts  ( t__name__t __module__t__doc__Rt classmethodR!RR$t staticmethod(((s//usr/lib64/python2.7/distutils/msvc9compiler.pyR @s       t MacroExpandercBs,eZd�Zd�Zd�Zd�ZRS(cCs'i|_t||_|j|�dS(N(tmacrostVS_BASEtvsbaset load_macros(tselftversion((s//usr/lib64/python2.7/distutils/msvc9compiler.pyt__init__�s  cCs!tj||�|jd|s%Unable to find productdir in registrysVS%0.f0COMNTOOLStVCs%s is not a valid directorys Env var %s is not set or invalidsNo productdir founds vcvarsall.batsUnable to find vcvarsall.batN(R5R RRRtVSEXPRESS_BASERtdebugRYRtisdirtenvirontgetR`tpardirtabspathtisfile(R9R6R>ttoolskeyttoolsdirt vcvarsall((s//usr/lib64/python2.7/distutils/msvc9compiler.pytfind_vcvarsall�s@           !  c Cs�t|�}td�}i}|dkr9td��ntjd||�tjd||fdtjd tj�}z�|j �\}}|j �d kr�t|j d ���n|j d �}x�|j d �D]�}t j|�}d |kr�q�n|j�}|j d d�\} } | j�} | |kr�| jtj�rW| d } nt| �|| |dkrd}ng}x|D]}tjj|�\}}tjj|�d}|tjj|�}||jkr�td|��n|r�tjj|�}n||j kr�|j tjj |||j ��q"||j kr|j tjj |||j ��q"|j tjj |||j��q"W|S(NR�isDon't know how to compile %s(RRYRtsplitextt splitdrivetisabstsrc_extensionsRtbasenamet_rc_extensionsRR`t res_extensiont_mc_extensionst obj_extension(R8tsource_filenamest strip_dirt output_dirt obj_namestsrc_nameRtext((s//usr/lib64/python2.7/distutils/msvc9compiler.pytobject_filenames�s(  c Cs�|js|j�n|j||||||�} | \}} }} } |pRg} | jd�|r{| j|j�n| j|j�xV| D]N}y| |\}}Wntk r�q�nX|r�tj j |�}n||j kr�d|}n�||j krd|}nq||j kr�|}d|}y)|j|jg| |g|g�Wq�tk r}t|��q�Xq�n||jkrqtj j|�}tj j|�}y�|j|jgd|d|g|g�tj jtj j|��\}}tj j||d�}|j|jgd|g|g�Wq�tk rj}t|��q�Xq�ntd||f��d |}y-|j|jg| | ||g|�Wq�tk r�}t|��q�Xq�W| S( Ns/cs/Tcs/Tps/fos-hs-rs.rcs"Don't know how to compile %s to %ss/Fo(R�R�t_setup_compileRtextendR�R�RRYRRmt _c_extensionst_cpp_extensionsR�tspawnR�RRR�tdirnameR�R�R�R`R�(R8tsourcesR�R4t include_dirsRht extra_preargstextra_postargstdependst compile_infotobjectstpp_optstbuildt compile_optstobjtsrcR�t input_optt output_opttmsgth_dirtrc_dirRR�trc_file((s//usr/lib64/python2.7/distutils/msvc9compiler.pytcompile�sj         # $$#  c Cs�|js|j�n|j||�\}}|j|d|�}|j||�r�|d|g}|rony|j|jg|�Wq�tk r�}t|��q�Xnt j d|�dS(NR�s/OUT:sskipping %s (up-to-date)( R�R�t_fix_object_argstlibrary_filenamet _need_linkR�RtRRRRh( R8R�toutput_libnameR�Rht target_langtoutput_filenametlib_argsR�((s//usr/lib64/python2.7/distutils/msvc9compiler.pytcreate_static_lib)s    cCs�|js|j�n|j||�\}}|j|||�}|\}}}|rr|jdt|��nt||||�}|dk r�tj j ||�}n|j ||�r�|t j kr�| r�|jd}q |jd}n| r|j}n |j}g}x%|pgD]}|jd|�q W||||d|g}tj j|d�} |dk r�tj jtj j|��\}}tj j | |j|��}|jd|�n|j|| |�| r�| |d*n| r |j| �n|jtj j|��y|j|jg|�Wntk ra}t|��nX|j||�}|dk r�|\}}d||f}y |jdd d ||g�Wq�tk r�}t|��q�Xq�ntjd |�dS( Ns5I don't know what to do with 'runtime_library_dirs': is/EXPORT:s/OUT:is/IMPLIB:s-outputresource:%s;%ssmt.exes-nologos -manifestsskipping %s (up-to-date)(R�R�R�t _fix_lib_argstwarnR�RRRYRR`R�Rt EXECUTABLER�R�RR�R�R�R�tmanifest_setup_ldargsR�tmkpathR�R�RRtmanifest_get_embed_infoRRh(R8t target_descR�R�R�t librariest library_dirstruntime_library_dirstexport_symbolsRhR�R�t build_tempR�t fixed_argstlib_optstldflagst export_optstsymtld_argstdll_nametdll_extt implib_fileR�tmfinfot mffilenametmfidtout_arg((s//usr/lib64/python2.7/distutils/msvc9compiler.pytlinkBsl               cCs:tjj|tjj|�d�}|jd|�dS(Ns .manifests/MANIFESTFILE:(RYRR`R�R(R8R�R�R�t temp_manifest((s//usr/lib64/python2.7/distutils/msvc9compiler.pyR��s cCs�x;|D]/}|jd�r|jdd�d}PqqWdS|tjkrVd}nd}|j|�}|dkr{dS||fS(Ns/MANIFESTFILE:t:ii(t startswithRRRRR�t_remove_visual_c_ref(R8R�R�targR�R�((s//usr/lib64/python2.7/distutils/msvc9compiler.pyR��s   cCs�y�t|�}z|j�}Wd|j�Xtjdtj�}tj|d|�}d}tj|d|�}tjdtj�}tj||�dkr�dSt|d�}z|j |�|SWd|j�XWnt k r�nXdS(NsU|)R�s*\s*sI|)tw( topentreadR�treR�tDOTALLRMtsearchRtwritetIOError(R8t manifest_filet manifest_ft manifest_buftpattern((s//usr/lib64/python2.7/distutils/msvc9compiler.pyR��s.      cCsd|S(Ns /LIBPATH:((R8tdir((s//usr/lib64/python2.7/distutils/msvc9compiler.pytlibrary_dir_option�scCstd��dS(Ns<don't know how to set runtime library search path for MSVC++(R(R8R ((s//usr/lib64/python2.7/distutils/msvc9compiler.pytruntime_library_dir_option�scCs |j|�S(N(R�(R8Rt((s//usr/lib64/python2.7/distutils/msvc9compiler.pytlibrary_option�scCs�|r|d|g}n |g}xW|D]K}xB|D]:}tjj||j|��}tjj|�r6|Sq6Wq)WdSdS(Nt_d(RYRR`R�texistsR(R8tdirsRtRht try_namesR R%tlibfile((s//usr/lib64/python2.7/distutils/msvc9compiler.pytfind_library_file�s    cCs�xH|jD]=}tjjtjj|�|�}tjj|�r |Sq WxUtjdjd�D]=}tjjtjj|�|�}tjj|�rb|SqbW|S(s�Return path to an MSVC executable program. Tries to find the program in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute path that is known to exist. If none of them work, just return the original program name, 'exe'. tPathR�(R�RYRR`RmRnRjRR(R8texeRHtfn((s//usr/lib64/python2.7/distutils/msvc9compiler.pyR� s !!N( R.R/R0t compiler_typet executablesR�R�R�R�R�R�R�tstatic_lib_extensiontshared_lib_extensiontstatic_lib_formattshared_lib_formatt exe_extensionR:RR�R�R�R�R�R�R�R�RRRRR�(((s//usr/lib64/python2.7/distutils/msvc9compiler.pyR�5sR     Y  V  R  +    I(((2R0t __revision__RYRzRORtdistutils.errorsRRRRRtdistutils.ccompilerRRt distutilsRtdistutils.utilRt_winregt OpenKeyExRtEnumKeyRt EnumValueR"terrorRt HKEY_USERStHKEY_CURRENT_USERtHKEY_LOCAL_MACHINEtHKEY_CLASSES_ROOTRtplatformtmaxsizet NATIVE_WIN64R5RgRGRFR�R R3RXR^ReRrR�R�R�(((s//usr/lib64/python2.7/distutils/msvc9compiler.pytsV    (        >.   , )