B ŒÛ™\ \ã @sˆdZddlZddlZddlmZmZmZmZmZddl m Z m Z m Z ddl mZdZy,ddlZdZeZejZejZejZejZWnhek rèy4ddlZddlZdZeZejZejZejZejZWnek râe d¡YnXYnXerejejej ej!fZ"d d „Z#d d „Z$d d„Z%Gdd„dƒZ&dd„Z'dd„Z(dd„Z)Gdd„de ƒZ*e'ƒdkr„e +d¡e*Z,ddl-m*Z*ddl-m&Z&dS)z‚distutils.msvccompiler Contains MSVCCompiler, an implementation of the abstract CCompiler class for the Microsoft Visual Studio. éN)ÚDistutilsExecErrorÚDistutilsPlatformErrorÚ CompileErrorÚLibErrorÚ LinkError)Ú CCompilerÚgen_preprocess_optionsÚgen_lib_options)ÚlogFTzWarning: Can't read registry to find the necessary compiler setting Make sure that Python modules winreg, win32api or win32con are installed.cCsnyt||ƒ}Wntk r"dSXg}d}x||j kr>|}d|}y"| |jg| |g|g¡Wqhtk r8}z t|ƒ‚Wdd}~XYqhXqhnÒ||jkrtj  |¡}tj  |¡}yl| |jgd|d|g|g¡tj  tj  |¡¡\}}tj  ||d¡}| |jgd|g|g¡Wqhtk rú}z t|ƒ‚Wdd}~XYqhXqhntd||fƒ‚d |}y&| |jg| | ||g|¡Wqhtk rj}z t|ƒ‚Wdd}~XYqhXqhW| S) Nz/cz/Tcz/Tpz/foz-hz-rz.rcz"Don't know how to compile %s to %sz/Fo)rXrjZ_setup_compilerÚextendrgrfr/rMr-ÚabspathÚ _c_extensionsÚ_cpp_extensionsrqÚspawnrarrrsÚdirnamerbrlrprer_)r)Zsourcesrur'Z include_dirsÚdebugÚ extra_preargsÚextra_postargsZdependsZ compile_infoÚobjectsZpp_optsZbuildZ compile_optsÚobjÚsrcrvZ input_optZ output_optÚmsgZh_dirZrc_dirrÚ_Zrc_filerrrÚcompileWsj              zMSVCCompiler.compilec Csž|js| ¡| ||¡\}}|j||d}| ||¡rŽ|d|g}|rJy| |jg|¡Wqštk rŠ}z t|ƒ‚Wdd}~XYqšXn t   d|¡dS)N)ruz/OUT:zskipping %s (up-to-date)) rXrjÚ_fix_object_argsÚlibrary_filenameÚ _need_linkr|rZrrr r~) r)rZoutput_libnamerur~Ú target_langÚoutput_filenameZlib_argsr„rrrÚcreate_static_lib¬s zMSVCCompiler.create_static_libc CsÖ|js| ¡| ||¡\}}| |||¡}|\}}}|rL| dt|ƒ¡t||||ƒ}|dk rptj  ||¡}|  ||¡rÆ|t j kr¬| rœ|j dd…}q¾|jdd…}n| r¸|j }n|j}g}x|pÊgD]}| d|¡qÌW||||d|g}|dk rLtj tj |¡¡\}}tj  tj |d¡| |¡¡}| d|¡| r^| |dd…<| rn| | ¡| tj |¡¡y| |jg|¡Wn,tk rÂ}z t|ƒ‚Wdd}~XYnXn t d|¡dS)Nz5I don't know what to do with 'runtime_library_dirs': r z/EXPORT:z/OUT:rz/IMPLIB:zskipping %s (up-to-date))rXrjr‡Z _fix_lib_argsÚwarnÚstrr rMr-rer‰rZ EXECUTABLErirhrrlrpr}rˆrxZmkpathr|r`rrr r~)r)Z target_descrr‹ruZ librariesZ library_dirsZruntime_library_dirsZexport_symbolsr~rr€Z build_temprŠZ fixed_argsZlib_optsZldflagsZ export_optsZsymZld_argsZdll_nameZdll_extZ implib_filer„rrrÚlinkÅsV       zMSVCCompiler.linkcCsd|S)Nz /LIBPATH:r)r)ÚdirrrrÚlibrary_dir_optionszMSVCCompiler.library_dir_optioncCs tdƒ‚dS)Nztjd d¡D]*}tj tj |¡|¡}tj |¡rH|SqHW|S)aŒ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'. ZPathr[)r\rMr-reryÚisfiler]rD)r)Zexer1Úfnrrrr^5s   zMSVCCompiler.find_exeÚx86cCsÀtsgS|d}|jdkr,d|j|jf}nd|j|f}xHtD]@}t||ƒ}|r@|jdkrr|j ||¡ d¡S|| d¡Sq@W|jdkr¼x,tD]$}t|d|jƒdk r”| d ¡Pq”WgS) zÐGet a list of devstudio directories (include, lib or path). Return a list of strings. The list will be empty if unable to access the registry or appropriate registry keys not found. z dirsrRz6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz?%s\6.0\Build System\Components\Platforms\Win32 (%s)\Directoriesr[r;z%s\6.0Nz´It seems you have Visual Studio 6 installed, but the expected registry settings are not present. You must at least run the Visual Studio GUI once so that these entries are created.) Ú _can_read_regrSrUr,r rVr6rDr)r)r-ÚplatformrrrrrrrcKs(        zMSVCCompiler.get_msvc_pathscCs6|dkr| d¡}n | |¡}|r2d |¡tj|<dS)z¡Set environment variable 'name' to an MSVC path type value. This is equivalent to a SET command prior to execution of spawned commands. rZZlibraryr[N)rcrerMr])r)rr1rrrrdos   zMSVCCompiler.set_path_env_var)rrr)rrk)NNNrNNN)NrN) NNNNNrNNNN)r)r™)r7r8r9Ú__doc__Z compiler_typeZ executablesrzr{rqrsrorrrtZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr+rjrwr†rŒrr‘r’r“r–r^rcrdrrrrrQÈsP  B  V  F  $rQg @z3Importing new compiler from distutils.msvc9compiler)rQ)r&).rœrArMZdistutils.errorsrrrrrZdistutils.ccompilerrrr Z distutilsr ršÚwinregZhkey_modZ OpenKeyExr ZEnumKeyrZ EnumValuerÚerrorr Ú ImportErrorZwin32apiZwin32conÚinfoZ HKEY_USERSÚHKEY_CURRENT_USERÚHKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr,rr rr&rHrLrPrQr~ZOldMSVCCompilerZdistutils.msvc9compilerrrrrÚs^      - 9