[[@sdZddlZddlZddlmZmZmZmZmZddl m Z m Z m Z ddl mZdZy@ddlZdZeZejZejZejZejZWnek r:yLddlZddlZdZeZejZejZejZejZWnek r5ejdYnXYnXerbejejej ej!fZ"nd d Z#d d Z$d dZ%GdddZ&ddZ'ddZ(ddZ)Gddde Z*e'dkrej+de*Z,ddl-m*Z*ddl-m&Z&ndS)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.cCsyt||}Wntk r+dSYnXg}d}xDyt||}Wntk rcPYnX|j||d7}q;W|S)zReturn list of registry keys.Nr) RegOpenKeyExRegError RegEnumKeyappend)basekeyhandleLikr,/usr/lib/python3.4/distutils/msvccompiler.py read_keys7s    rcCsyt||}Wntk r+dSYnXi}d}xbyt||\}}}Wntk rlPYnX|j}t||t|<|d7}q;W|S)zXReturn dict of registry keys and values. All names are converted to lowercase. Nrr )r r RegEnumValuelower convert_mbcs)rrrdrnamevaluetyperrr read_valuesHs    r c CsJt|dd}|dk rFy|d}WqFtk rBYqFXn|S)Ndecodembcs)getattr UnicodeError)sZdecrrrr]s  rc@s@eZdZddZddZddZddZd S) MacroExpandercCsi|_|j|dS)N)macros load_macros)selfversionrrr__init__gs zMacroExpander.__init__cCsCx<tD]4}t||}|r|||jd|)r@r*rArB)rErjrrrget_build_architectures  rKcCsIg}x<|D]4}tjj|}||kr |j|q q W|S)znReturn a list of normalized paths with duplicates removed. The current order of paths is maintained. )osr-normpathr)ZpathsZ reduced_pathsr1Znprrrnormalize_and_reduce_pathss   rNc @sseZdZdZdZiZdgZdddgZdgZdgZ eeee Z d Z d Z d Z d Zd ZZdZdddddZddZddddZdddddddddZdddddZdddddddddddd ZddZd d!Zd"d#Zdd$d%Zd&d'Zd(d)d*Zd+d,ZdS)- MSVCCompilerzwConcrete class that implements an interface to Microsoft Visual C++, as defined by the CCompiler abstract class.Zmsvcz.cz.ccz.cppz.cxxz.rcz.mcz.resz.objz.libz.dllz%s%sz.exercCstj||||t|_t|_|jdkr|jdkrjd|_t|j|_n d|_d|j|_ nd|jd|_ d|_ dS) NrHzSoftware\Microsoft\VisualStudiozSoftware\Microsoft\DevstudiozVisual Studio version %szMicrosoft SDK compiler %sr:F) rr+rG_MSVCCompiler__versionrK_MSVCCompiler__arch_MSVCCompiler__rootr&_MSVCCompiler__macros_MSVCCompiler__product initialized)r)verboseZdry_runZforcerrrr+s    zMSVCCompiler.__init__cCsg|_dtjkrfdtjkrf|jdrfd|_d|_d|_d|_d|_n|j d|_t |jd krt d |j n|jd|_|jd|_|jd|_|jd|_|jd|_|j d |j d y5x.tjdjd D]}|jj|q1WWntk r`YnXt|j|_d j|jtjdtD]3}t|d|jdk r|jd PqqWngS) 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 dirsrPz6%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directoriesz?%s\6.0\Build System\Components\Platforms\Win32 (%s)\DirectoriesrYr: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_regrQrSr,r rTr6rCr)r)r-platformrrrrrrraHs(     zMSVCCompiler.get_msvc_pathscCsP|dkr|jd}n|j|}|rLdj|tj|sZ(                  -