3 \\@sdZddlZddlZddlmZmZmZmZmZddl m Z m Z m Z ddl mZdZy,ddlZdZeZejZejZejZejZWnhek ry4ddlZddlZdZeZejZejZejZejZWnek rejdYnXYnXerejejej ej!fZ"d d Z#d d Z$d dZ%GdddZ&ddZ'ddZ(ddZ)Gddde Z*e'dkrej+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_preprocess_optionsgen_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)rXrlZ_setup_compilerextendrirhr/rMr-abspath _c_extensions_cpp_extensionsrsspawnrcrrrudirnamerdrnrrrgra)r)Zsourcesrwr'Z include_dirsdebug extra_preargsextra_postargsZdependsZ compile_infoobjectsZpp_optsZbuildZ compile_optsobjsrcrxZ 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)rwz/OUT:zskipping %s (up-to-date)) rXrl_fix_object_argslibrary_filename _need_linkr~r[rrr r) r)rZoutput_libnamerwr 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))rXrlrZ _fix_lib_argswarnstrr rMr-rgrrZ EXECUTABLErkrjrrnrrrrrzZmkpathr~rbrrr r)r)Z target_descrrrwZ librariesZ library_dirsZruntime_library_dirsZexport_symbolsrrrZ build_temprZ fixed_argsZlib_optsZldflagsZ export_optsZsymZld_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'. ZPathr])r^rMr-rgr{isfiler_rD)r)Zexer1fnrrrr`5s   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 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.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_regrSrUr,r rVr6rDr)r)r-platformrrrrrrreKs(        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[Zlibraryr]N)rergrMr_)r)rr1rrrrfos   zMSVCCompiler.set_path_env_var)rrr)rrm)NNNrNNN)NrN) NNNNNrNNNN)r)r)r7r8r9__doc__Z compiler_typeZ executablesr|r}rsrurqrtrvZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionr+rlryrrrrrrrr`rerfrrrrrQsP  B  V  F  $rQg @z3Importing new compiler from distutils.msvc9compiler)rQ)r&).rrArMZdistutils.errorsrrrrrZdistutils.ccompilerrrr Z distutilsr rwinregZhkey_modZ OpenKeyExr ZEnumKeyrZ EnumValuererrorr ImportErrorZwin32apiZwin32coninfoZ HKEY_USERSHKEY_CURRENT_USERHKEY_LOCAL_MACHINEZHKEY_CLASSES_ROOTr,rr rr&rHrLrPrQrZOldMSVCCompilerZdistutils.msvc9compilerrrrrs^      - 9