o
    et                     @  s   U d dl mZ d dlZd dlZd dlZd dlZddlm	Z	 ddl
mZ ddlmZmZ ddlmZ ejrFdd	lmZ dd
lmZ ddlmZ g g g dgdgdgdgdZded< G dd deeZG dd deZG dd deZdS )    )annotationsN   )EnvironmentException)RSPFileSyntax   )Compilermono_buildtype_args)BasicLinkerIsCompilerMixin)MachineInfo)Environment)MachineChoicez
-optimize+)plain0g123szT.Dict[str, T.List[str]]cs_optimization_argsc                      s   e Zd ZdZ	d<d= fddZed>ddZd?ddZd?ddZd@ddZ	d@ddZ
d?ddZd?ddZdAd!d"ZdBd%d&ZdCd(d)ZdDd.d/ZdEd1d2ZdFd4d5ZdGd7d8ZdHd:d;Z  ZS )I
CsCompilercsNexelistT.List[str]versionstrfor_machiner   info'MachineInfo'runnerT.Optional[str]c                   s   t  g |||| || _d S N)super__init__r   )selfr   r   r   r   r   	__class__ </usr/lib/python3.10/site-packages/mesonbuild/compilers/cs.pyr"   .   s   
zCsCompiler.__init__returnc                 C     dS )NzC sharpr&   )clsr&   r&   r'   get_display_language3   s   zCsCompiler.get_display_languagec                 C     dgS Nz/nologor&   r#   r&   r&   r'   get_always_args7      zCsCompiler.get_always_argsc                 C  r,   r-   r&   r.   r&   r&   r'   get_linker_always_args:   r0   z!CsCompiler.get_linker_always_argsfnamec                 C  
   d| gS )Nz-out:r&   r#   r2   r&   r&   r'   get_output_args=      
zCsCompiler.get_output_argsc                 C  r3   )Nz-r:r&   r4   r&   r&   r'   get_link_args@   r6   zCsCompiler.get_link_argsc                 C  r,   )Nz-warnaserrorr&   r.   r&   r&   r'   get_werror_argsC   r0   zCsCompiler.get_werror_argsc                 C     g S r    r&   r.   r&   r&   r'   get_pic_argsF      zCsCompiler.get_pic_argsparameter_list	build_dirc              
   C  s   t |D ]B\}}|d d dkr'|d d tjtj||dd   ||< |d d dkrF|d d tjtj||dd   ||< q|S )Nr   z-L   z-lib:)	enumerateospathnormpathjoin)r#   r<   r=   idxir&   r&   r'   &compute_parameters_with_absolute_pathsI   s   ..z1CsCompiler.compute_parameters_with_absolute_pathspch_dirheaderc                 C  r9   r    r&   )r#   rG   rH   r&   r&   r'   get_pch_use_argsS   r;   zCsCompiler.get_pch_use_argsheader_namec                 C  r)   )N r&   )r#   rJ   r&   r&   r'   get_pch_nameV   r;   zCsCompiler.get_pch_namework_direnvironment'Environment'Nonec           
      C  s   d}d}t j||}t|ddd}|td W d    n1 s%w   Y  tj| j	| 
  |g |d}|  |jdkrJtd	|   | jrS| j|g}nt j||g}tj||d}	|	  |	jdkrstd
|   d S )Nz	sanity.csz
sanity.exewzutf-8)encodingz
                public class Sanity {
                    static public void Main () {
                    }
                }
                )cwdr   z'C# compiler %s cannot compile programs.z9Executables created by Mono compiler %s are not runnable.)r@   rA   rC   openwritetextwrapdedent
subprocessPopenr   r/   wait
returncoder   Zname_stringr   )
r#   rM   rN   srcobjZsource_nameZofileZpcZcmdlistper&   r&   r'   sanity_checkY   s$   

zCsCompiler.sanity_checkboolc                 C  r)   )NFr&   r.   r&   r&   r'   needs_static_linkerq   r;   zCsCompiler.needs_static_linker	buildtypec                 C     t | S r    )r   )r#   rb   r&   r&   r'   get_buildtype_argst      zCsCompiler.get_buildtype_argsis_debugc                 C  s   |rdgS g S )N-debugr&   )r#   rf   r&   r&   r'   get_debug_argsw   s   zCsCompiler.get_debug_argsoptimization_levelc                 C  rc   r    )r   )r#   ri   r&   r&   r'   get_optimization_argsz   re   z CsCompiler.get_optimization_argsr    )
r   r   r   r   r   r   r   r   r   r   )r(   r   )r(   r   )r2   r   r(   r   )r<   r   r=   r   r(   r   )rG   r   rH   r   r(   r   )rJ   r   r(   r   )rM   r   rN   rO   r(   rP   )r(   r`   rb   r   r(   r   )rf   r`   r(   r   )ri   r   r(   r   )__name__
__module____qualname__languager"   classmethodr+   r/   r1   r5   r7   r8   r:   rF   rI   rL   r_   ra   rd   rh   rj   __classcell__r&   r&   r$   r'   r   *   s(    













r   c                      s,   e Zd ZdZd fd
dZdddZ  ZS )MonoCompilermonor   r   r   r   r   r   r   r   c                   s   t  j||||dd d S )Nrs   )r   )r!   r"   )r#   r   r   r   r   r$   r&   r'   r"      s   zMonoCompiler.__init__r(   'RSPFileSyntax'c                 C     t jS r    )r   ZGCCr.   r&   r&   r'   rsp_file_syntax   r0   zMonoCompiler.rsp_file_syntax)r   r   r   r   r   r   r   r   r(   rt   )rl   rm   rn   idr"   rv   rq   r&   r&   r$   r'   rr   ~   s    rr   c                   @  s$   e Zd ZdZdddZdd	d
ZdS )VisualStudioCsCompilerZcscrb   r   r(   r   c                 C  s>   t | }| j sg }|D ]}|dkrd}|| q|}|S )Nrg   z-debug:portable)r   r   Z
is_windowsappend)r#   rb   restmpflagr&   r&   r'   rd      s   
z)VisualStudioCsCompiler.get_buildtype_argsrt   c                 C  ru   r    )r   MSVCr.   r&   r&   r'   rv      r0   z&VisualStudioCsCompiler.rsp_file_syntaxNrk   rw   )rl   rm   rn   rx   rd   rv   r&   r&   r&   r'   ry      s    
ry   )
__future__r   os.pathr@   rX   rV   typingTZmesonlibr   Zlinkersr   	compilersr   r   Zmixins.islinkerr	   TYPE_CHECKINGZ	envconfigr
   rN   r   r   r   __annotations__r   rr   ry   r&   r&   r&   r'   <module>   s.   T