B
    0a                 @   sh   d dl Z d dlZd dlmZmZmZmZmZ d dlm	Z	m
Z
 d dlmZ dd ZG dd dejjZdS )	    N)DistutilsExecErrorCompileErrorLibError	LinkErrorUnknownFileError)	CCompilergen_preprocess_options)newerc               C   s   t  S )N)MSVCCompiler r   r   8/usr/lib/gobject-introspection/giscanner/msvccompiler.pyget_msvc_compiler!   s    r   c               @   s(   e Zd Zd	ddZd
ddZdd ZdS )r
   r   c             C   sN   t | ||| g | _d | _tjdkr>t| tjj	r>tjj
| _d| _d | _d S )NntF)r   __init__Z_MSVCCompiler__pathsZ_MSVCCompiler__archosname
isinstance	distutilsZmsvc9compilerr
   ZVERSIONZ_MSVCCompiler__versioninitializedpreprocess_options)selfverboseZdry_runforcer   r   r   r   '   s    

zMSVCCompiler.__init__Nc          
   C   s&  | j dkr|   | d ||\}}}t||}dg}	d }
|d k	rV|	d | |}
| j }|d k	rt||d d< |d k	r|	| ||	 || || | j	s|d kst
||ry| | W n. tk
r } zt| tW d d }~X Y nX |d k	r"||
d kr"t|
d | d S )NFz-Ez-Pr   z.i)r   Z
initializeZ_fix_compile_argsr   append_get_file_basenameZccsplitextendr   r	   Zspawnr   printr   r   rename)r   sourceZoutput_fileZmacrosZinclude_dirsZextra_preargsZextra_postargs_Zpp_optsr   Zsource_basenameZcpp_argsmsgr   r   r   
preprocess1   s4    









zMSVCCompiler.preprocessc             C   sP   |d krd S | ddkr0|| dd d  S || dd | d S d S )N.\   )rfind)r   filenamer   r   r   r   _   s
    zMSVCCompiler._get_file_basename)r   r   r   )NNNNN)__name__
__module____qualname__r   r"   r   r   r   r   r   r
   %   s   
    
(r
   )r   r   Zdistutils.errorsr   r   r   r   r   Zdistutils.ccompilerr   r   Zdistutils.dep_utilr	   r   Zmsvccompilerr
   r   r   r   r   <module>   s   