o
    Wod}                     @  s   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rEd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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sc                      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__ vhome/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/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:   r/   z!CsCompiler.get_linker_always_argsfnamec                 C  
   d| gS )Nz-out:r%   r"   r1   r%   r%   r&   get_output_args=      
zCsCompiler.get_output_argsc                 C  r2   )Nz-r:r%   r3   r%   r%   r&   get_link_args@   r5   zCsCompiler.get_link_argsc                 C  r+   )Nz-warnaserrorr%   r-   r%   r%   r&   get_werror_argsC   r/   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  r8   r   r%   )r"   rF   rG   r%   r%   r&   get_pch_use_argsS   r:   zCsCompiler.get_pch_use_argsheader_namec                 C  r(   )N r%   )r"   rI   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 can not compile programs.z9Executables created by Mono compiler %s are not runnable.)r?   r@   rB   openwritetextwrapdedent
subprocessPopenr   r.   wait
returncoder   Zname_stringr   )
r"   rL   rM   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"   ra   r%   r%   r&   get_buildtype_argst      zCsCompiler.get_buildtype_argsis_debugc                 C  s   |rdgS g S )N-debugr%   )r"   re   r%   r%   r&   get_debug_argsw   s   zCsCompiler.get_debug_argsoptimization_levelc                 C  rb   r   )cs_optimization_args)r"   rh   r%   r%   r&   get_optimization_argsz   rd   z CsCompiler.get_optimization_argsr   )
r   r   r   r   r   r   r   r   r   r   )r'   r   )r'   r   )r1   r   r'   r   )r;   r   r<   r   r'   r   )rF   r   rG   r   r'   r   )rI   r   r'   r   )rL   r   rM   rN   r'   rO   )r'   r_   ra   r   r'   r   )re   r_   r'   r   )rh   r   r'   r   )__name__
__module____qualname__languager!   classmethodr*   r.   r0   r4   r6   r7   r9   rE   rH   rK   r^   r`   rc   rg   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   r/   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cscra   r   r'   r   c                 C  s>   t | }| j sg }|D ]}|dkrd}|| q|}|S )Nrf   z-debug:portable)r   r   Z
is_windowsappend)r"   ra   restmpflagr%   r%   r&   rc      s   
z)VisualStudioCsCompiler.get_buildtype_argsrt   c                 C  ru   r   )r   MSVCr-   r%   r%   r&   rv      r/   z&VisualStudioCsCompiler.rsp_file_syntaxNrk   rw   )rl   rm   rn   rx   rc   rv   r%   r%   r%   r&   ry      s    
ry   )
__future__r   os.pathr?   rW   rU   typingTZmesonlibr   Zlinkersr   	compilersr   r   Zmixins.islinkerr	   TYPE_CHECKINGZ	envconfigr
   rM   r   r   ri   r   rr   ry   r%   r%   r%   r&   <module>   s.   T