qfc@sdZdZddlZddlZddlZddlZddlmZmZm 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&dYZ)dd'dYZ*dZ+dZ,dZ-dZ.dd Z/e+Z0e0d!kred"e0nd#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$iN(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-ia64tRegcBsbeZdZdZeeZdZeeZdZeeZdZeeZRS(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   cCsyt||}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 Csyt||}Wntk r'dSXi}d}xmtryt||\}}}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,eZdZdZdZdZRS(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_vcvarsalls@           !  c Cst|}td}i}|dkr9tdntjd||tjd||fdtjd tj}z|j \}}|j d krt|j d n|j d }x|j d D]}t j|}d |krqn|j}|j d d\} } | j} | |kr| jtjrW| d } nt| || |dkrd}ng}x|D]}tjj|\}}tjj|d}|tjj|}||jkrtd|n|rtjj|}n||j kr|j tjj |||j q"||j kr|j tjj |||j q"|j tjj |||jq"W|S(NRisDon'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_filenamess(  c Cs|js|jn|j||||||} | \}} }} } |pRg} | jd|r{| j|jn| j|jxV| D]N}y| |\}}Wntk rqnX|rtj j |}n||j krd|}n||j krd|}nq||j kr|}d|}y)|j|jg| |g|gWqtk r}t|qXqn||jkrqtj j|}tj j|}y|j|jgd|d|g|gtj jtj j|\}}tj j||d}|j|jgd|g|gWqtk rj}t|qXqntd||fd |}y-|j|jg| | ||g|Wqtk r}t|qXqW| S( Ns/cs/Tcs/Tps/fos-hs-rs.rcs"Don't know how to compile %s to %ss/Fo(RRt_setup_compileRtextendRRRRYRRmt _c_extensionst_cpp_extensionsRtspawnRRRRtdirnameRRRR`R(R8tsourcesRR4t include_dirsRht extra_preargstextra_postargstdependst compile_infotobjectstpp_optstbuildt compile_optstobjtsrcRt input_optt output_opttmsgth_dirtrc_dirRRtrc_file((s//usr/lib64/python2.7/distutils/msvc9compiler.pytcompilesj         # $$#  c Cs|js|jn|j||\}}|j|d|}|j||r|d|g}|rony|j|jg|Wqtk r}t|qXnt j d|dS(NRs/OUT:sskipping %s (up-to-date)( RRt_fix_object_argstlibrary_filenamet _need_linkRRtRRRRh( R8Rtoutput_libnameRRht target_langtoutput_filenametlib_argsR((s//usr/lib64/python2.7/distutils/msvc9compiler.pytcreate_static_lib)s    cCs|js|jn|j||\}}|j|||}|\}}}|rr|jdt|nt||||}|dk rtj 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 rtj 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 ||gWqtk r}t|qXqntjd |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)(RRRt _fix_lib_argstwarnRRRRYRR`RRt EXECUTABLERRRRRRRtmanifest_setup_ldargsRtmkpathRRRRtmanifest_get_embed_infoRRh(R8t target_descRRRt librariest library_dirstruntime_library_dirstexport_symbolsRhRRt build_tempRt fixed_argstlib_optstldflagst export_optstsymtld_argstdll_nametdll_extt implib_fileRtmfinfot mffilenametmfidtout_arg((s//usr/lib64/python2.7/distutils/msvc9compiler.pytlinkBsl               cCs:tjj|tjj|d}|jd|dS(Ns .manifests/MANIFESTFILE:(RYRR`RR(R8RRRt temp_manifest((s//usr/lib64/python2.7/distutils/msvc9compiler.pyRs cCsx;|D]/}|jdr|jddd}PqqWdS|tjkrVd}nd}|j|}|dkr{dS||fS(Ns/MANIFESTFILE:t:ii(t startswithRRRRRt_remove_visual_c_ref(R8RRtargRR((s//usr/lib64/python2.7/distutils/msvc9compiler.pyRs   cCsyt|}z|j}Wd|jXtjdtj}tj|d|}d}tj|d|}tjdtj}tj||dkrdSt|d}z|j ||SWd|jXWnt k rnXdS(NsU|)Rs*\s*sI|)tw( topentreadRtreRtDOTALLRMtsearchRtwritetIOError(R8t manifest_filet manifest_ft manifest_buftpattern((s//usr/lib64/python2.7/distutils/msvc9compiler.pyRs.      cCsd|S(Ns /LIBPATH:((R8tdir((s//usr/lib64/python2.7/distutils/msvc9compiler.pytlibrary_dir_optionscCstddS(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_optionscCs |j|S(N(R(R8Rt((s//usr/lib64/python2.7/distutils/msvc9compiler.pytlibrary_optionscCs|r|d|g}n |g}xW|D]K}xB|D]:}tjj||j|}tjj|r6|Sq6Wq)WdSdS(Nt_d(RYRR`RtexistsR(R8tdirsRtRht try_namesR R%tlibfile((s//usr/lib64/python2.7/distutils/msvc9compiler.pytfind_library_files    cCsxH|jD]=}tjjtjj||}tjj|r |Sq WxUtjdjdD]=}tjjtjj||}tjj|rb|SqbW|S(sReturn 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(RRYRR`RmRnRjRR(R8texeRHtfn((s//usr/lib64/python2.7/distutils/msvc9compiler.pyR s !!N( R.R/R0t compiler_typet executablesRRRRRRRtstatic_lib_extensiontshared_lib_extensiontstatic_lib_formattshared_lib_formatt exe_extensionR:RRRRRRRRRR RRRR(((s//usr/lib64/python2.7/distutils/msvc9compiler.pyR5sR     Y  V  R  +    I(((2R0t __revision__RYRzRORtdistutils.errorsRRRRRtdistutils.ccompilerRRt distutilsRtdistutils.utilRt_winregt OpenKeyExRtEnumKeyRt EnumValueR"terrorRt HKEY_USERStHKEY_CURRENT_USERtHKEY_LOCAL_MACHINEtHKEY_CLASSES_ROOTRtplatformtmaxsizet NATIVE_WIN64R5RgRGRFRR R3RXR^ReRrRRR(((s//usr/lib64/python2.7/distutils/msvc9compiler.pytsV    (        >.   , )