o
    e                     @  sx   d dl mZ 	 d dlZddlmZ ddlmZmZm	Z	 ddl
mZ ejr2ddlmZmZ dd	lmZ G d
d deZdS )    )annotationsN   )coredata)EnvironmentException	OptionKeyversion_compare   )Compiler)MutableKeyedOptionDictTypeKeyedOptionDictType)Environmentc                      s   e Zd ZdZdZdZd/ddZd0dd	Zd0d
dZd1ddZ	d2ddZ
d3ddZd4ddZd5ddZd6d d!Zd0d"d#Zd7d&d'Zd8 fd)d*Zd9d-d.Z  ZS ):CythonCompilerzCython Compiler.Zcythonreturnboolc                 C     dS )NF selfr   r   @/usr/lib/python3.10/site-packages/mesonbuild/compilers/cython.pyneeds_static_linker      z"CythonCompiler.needs_static_linkerT.List[str]c                 C     dgS )Nz--fast-failr   r   r   r   r   get_always_args      zCythonCompiler.get_always_argsc                 C  r   )Nz-Werrorr   r   r   r   r   get_werror_args    r   zCythonCompiler.get_werror_args
outputnamestrc                 C  s   d|gS )Nz-or   )r   r   r   r   r   get_output_args#   s   zCythonCompiler.get_output_argsoptimization_levelc                 C     g S Nr   )r   r   r   r   r   get_optimization_args&   s   z$CythonCompiler.get_optimization_args	outtargetoutfilec                 C  s   t | jdr	dgS g S )Nz	>=0.29.33z-M)r   version)r   r#   r$   r   r   r   get_dependency_gen_args+   s   z&CythonCompiler.get_dependency_gen_argsc                 C  r   )Ndepr   r   r   r   r   get_depfile_suffix0   s   z!CythonCompiler.get_depfile_suffixwork_direnvironment'Environment'Nonec                 C  sT   d}|  ||j}|jdkrtd| jdW d    d S 1 s#w   Y  d S )Nzprint("hello world")r   zCython compiler z cannot compile programs)Zcached_compiler   
returncoder   id)r   r)   r*   codepr   r   r   sanity_check3   s   
"zCythonCompiler.sanity_check	buildtypec                 C  r    r!   r   )r   r2   r   r   r   get_buildtype_args9   r   z!CythonCompiler.get_buildtype_argsc                 C  r    r!   r   r   r   r   r   get_pic_args=   r   zCythonCompiler.get_pic_argsparameter_list	build_dirc                 C  s   g }|D ]}| | q|S r!   )append)r   r5   r6   newir   r   r   &compute_parameters_with_absolute_pathsA   s   z5CythonCompiler.compute_parameters_with_absolute_paths'MutableKeyedOptionDictType'c              
     sX   t   }|td| j| jdtdddgdtd| j| jdtddd	gdi |S )
Nr%   machinelangzPython version to target23languagezOutput C or C++ filesccpp)superget_optionsupdater   for_machinerA   r   ZUserComboOption)r   opts	__class__r   r   rE   I   s   
zCythonCompiler.get_optionsoptions'KeyedOptionDictType'c                 C  sZ   g }|t d| j| jd }|d|j  |t d| j| jd }|jdkr+|d |S )Nr%   r<   -rA   rC   z--cplus)r   rG   rA   r7   value)r   rK   argskeyr>   r   r   r   get_option_compile_argsY   s   

z&CythonCompiler.get_option_compile_args)r   r   )r   r   )r   r   r   r   )r   r   r   r   )r#   r   r$   r   r   r   )r   r   )r)   r   r*   r+   r   r,   )r2   r   r   r   )r5   r   r6   r   r   r   )r   r;   )rK   rL   r   r   )__name__
__module____qualname____doc__rA   r.   r   r   r   r   r"   r&   r(   r1   r3   r4   r:   rE   rQ   __classcell__r   r   rI   r   r      s"    










r   )
__future__r   typingT r   Zmesonlibr   r   r   	compilersr	   TYPE_CHECKINGr
   r   r*   r   r   r   r   r   r   <module>   s   