B � f \� @s�dZddlZddlZddlmZmZmZmZmZddl m Z m Z m Z ddl mZdZy,ddlZdZeZejZejZejZejZWnhek r�y4ddlZddlZdZeZejZejZejZejZWnek r�e�d�YnXYnXe�rejejej ej!fZ"d d �Z#d d �Z$d d�Z%Gdd�d�Z&dd�Z'dd�Z(dd�Z)Gdd�de �Z*e'�dk�r�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)�logFTz�Warning: 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 k�r>|}d|}y"|�|jg| |g|g�Wqhtk �r8}z t|��Wdd}~XYqhXqhn�||jk�rtj �|�}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)r�Zoutput_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_descr�r�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�r�r�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