3 e[@sdZddlZddlZddlmZmZmZmZmZddl m Z m Z ddl m Z dZy,ddlZdZeZejZejZejZejZWnhek ry4ddlZddlZdZeZejZejZejZejZWnek re jdYnXYnXerejejejej fZ!d d Z"d d Z#d dZ$GdddZ%ddZ&ddZ'ddZ(Gddde Z)e&dkr~e j*de)Z+ddl,m)Z)ddl,m%Z%dS)zdistutils.msvccompiler Contains MSVCCompiler, an implementation of the abstract CCompiler class for the Microsoft Visual Studio. N)DistutilsExecErrorDistutilsPlatformError CompileErrorLibError LinkError) CCompilergen_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"|j|jg| |g|gWqhtk r8}zt|WYdd}~XqhXqhn||jkrtj j|}tj j|}yl|j|jgd|d|g|gtj jtj j|\}}tj j||d}|j|jgd|g|gWqhtk r}zt|WYdd}~XqhXqhntd||fd |}y&|j|jg| | ||g|Wqhtk rj}zt|WYdd}~XqhXqhW| S) Nz/cz/Tcz/Tpz/foz-hz-rz.rcz"Don't know how to compile %s to %sz/Fo)r[rpZ_setup_compilerextendrmrlr0rOr.abspath _c_extensions_cpp_extensionsrwspawnrgrrrydirnamerhrrrvrkre)r)sourcesr{r' include_dirsdebug extra_preargsextra_postargsdependsZ compile_infoobjectsZpp_optsbuildZ compile_optsobjsrcr}Z input_optZ output_optmsgZh_dirZrc_dirr_Zrc_filerrrcompileWsj              zMSVCCompiler.compilec Cs|js|j|j||\}}|j||d}|j||r|d|g}|rJy|j|jg|Wqtk r}zt|WYdd}~XqXn t j d|dS)N)r{z/OUT:zskipping %s (up-to-date)) r[rp_fix_object_argslibrary_filename _need_linkrr_rrr r) r)rZoutput_libnamer{r target_langoutput_filenameZlib_argsrrrrcreate_static_libs zMSVCCompiler.create_static_libcCs|js|j|j||\}}|j|||}|\}}}|rL|jdt|t||||}|dk rptjj ||}|j ||r|t j kr| r|j dd}q|jdd}n| r|j }n|j}g}x|pgD]}|jd|qW||||d|g}|dk rLtjjtjj|\}}tjj tjj|d|j|}|jd|| r^| |dd<| rn|j| |jtjj|y|j|jg|Wn,tk r}zt|WYdd}~XnXn tjd|dS)Nz5I don't know what to do with 'runtime_library_dirs': r z/EXPORT:z/OUT:rz/IMPLIB:zskipping %s (up-to-date))r[rprZ _fix_lib_argswarnstrrrOr.rkrrZ EXECUTABLErornrrrrvrrrmkpathrrfrrr r)r)Z target_descrrr{ libraries library_dirsruntime_library_dirsexport_symbolsrrr build_temprZ fixed_argsZlib_optsZldflagsZ export_optssymZld_argsZdll_nameZdll_extZ implib_filerrrrlinksV       zMSVCCompiler.linkcCsd|S)Nz /LIBPATH:r)r)dirrrrlibrary_dir_optionszMSVCCompiler.library_dir_optioncCs tddS)NztjdjdD]*}tjjtjj||}tjj|rH|SqHW|S)aReturn 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'. Pathra)rbrOr.rkrisfilercrF)r)Zexer3fnrrrrd5s   zMSVCCompiler.find_exex86cCstsgS|d}|jdkr,d|j|jf}nd|j|f}xHtD]@}t||}|r@|jdkrr|jj||jdS||jdSq@W|jdkrx,tD]$}t|d|jdk r|jd PqWgS) zGet 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 dirsrUz6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz?%s\6.0\Build System\Components\Platforms\Win32 (%s)\Directoriesrar<z%s\6.0NzIt 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_regrVrXr,rrYr8rFr)r)r.platformrrrrrrriKs(        zMSVCCompiler.get_msvc_pathscCs6|dkr|jd}n |j|}|r2dj|tj|<dS)zSet environment variable 'name' to an MSVC path type value. This is equivalent to a SET command prior to execution of spawned commands. r_libraryraN)rirkrOrc)r)rr3rrrrjos   zMSVCCompiler.set_path_env_var)rrr)rrq)NNNrNNN)NrN) NNNNNrNNNN)r)r)r9r:r;__doc__ compiler_typeZ executablesrrrwryrurxrzZstatic_lib_extensionshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr+rpr~rrrrrrrrdrirjrrrrrTsP  B  V  F  $rTg @z3Importing new compiler from distutils.msvc9compiler)rT)r&)-rrCrOZdistutils.errorsrrrrrdistutils.ccompilerrr distutilsr rwinregZhkey_mod OpenKeyExr EnumKeyr Z EnumValuererrorr ImportErrorwin32apiZwin32coninfoZ HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEHKEY_CLASSES_ROOTr,rrrr&rJrNrSrTrZOldMSVCCompilerZdistutils.msvc9compilerrrrrs^      - 9