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 ddlmZ ddl	mZmZmZmZ d	d
lmZ d	dlmZmZmZmZmZmZ d	dlmZ d	dlmZ ejrddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z% ddlm&Z& ddl	m'Z' eZ(ne)Z(ddddddddddddddddZ*g g g dgd gd!gd"gd#Z+g g g d$gd$gd$gd$gd#Z,G d%d& d&e(Z-G d'd( d(eZ.G d)d* d*eZ/G d+d, d,ee/Z0d6d0d1Z1G d2d3 d3e-e/Z2G d4d5 d5e-e/Z3dS )7    )annotationsN   )mesonlib)mlog)CompilerArgs)RSPFileSyntax)EnvironmentExceptionversion_compare	OptionKey
is_windows   )	compilers)d_dmd_buildtype_argsd_gdc_buildtype_argsd_ldc_buildtype_argsclike_debug_argsCompilerCompileCheckMode)GnuCompiler)gnu_common_warning_args)
Dependency)ExternalProgram)MachineInfo)Environment)DynamicLinker)MachineChoicez
-funittestz-fdebugz	-fversionz-J)unittestdebugversion
import_dirz	-unittestz-d-debugz
-d-versionz-debugz-version)gccllvmdmdz-O1z-O2z-O3z-Oz)plain0g123sz-Oc                      sJ  e Zd ZdZdbddZejri Zdcdd	Zd
Z	ddddZ
ddddZdeddZdfddZdgddZdcddZdcdd Zdcd!d"Zdcd#d$Zdcd%d&Zdhd'd(Zdid+d,Zdcd-d.Zdjd2d3Zdkd5d6Zdld8d9Zdm fdBdCZedndHdIZedodKdLZedodMdNZedpdndPdQZdqdSdTZ drdVdWZ!ds fd^d_Z"dcd`daZ#  Z$S )tDmdLikeCompilerMixinzMixin class for DMD and LDC.

    LDC has a number of DMD like arguments, and this class allows for code
    sharing between them as makes sense.
    dmd_frontend_versionT.Optional[str]c                 C  s"   |d u r	d| _ d S t|d| _ d S )NFz	>=2.095.0)_dmd_has_depfiler	   )selfr+    r/   uhome/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/lib/python3.10/site-packages/mesonbuild/compilers/d.py__init__a   s   
zDmdLikeCompilerMixin.__init__returnT.List[str]c                 C  s   d S Nr/   r.   r/   r/   r0   _get_target_arch_argsk   s    z*DmdLikeCompilerMixin._get_target_arch_args-L=
outputnamestrc                 C  
   d| gS Nz-of=r/   r.   r8   r/   r/   r0   get_output_argso      
z$DmdLikeCompilerMixin.get_output_argsc                 C  r:   r;   r/   r<   r/   r/   r0   get_linker_output_argsr   r>   z+DmdLikeCompilerMixin.get_linker_output_argspath	is_systemboolc                 C  s   |dkrd}d| gS )N .-I=r/   )r.   r@   rA   r/   r/   r0   get_include_argsu   s   
z%DmdLikeCompilerMixin.get_include_argsparameter_list	build_dirc              
   C  s  t |D ]\}}|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   ||< |d d dkre|d d tjtj||dd   ||< |d d dkr|d d tjtj||dd   ||< q|S )	N   rE      z-L-L   z-L=-L   z-Wl,-L	enumerateosr@   normpathjoinr.   rG   rH   idxir/   r/   r0   &compute_parameters_with_absolute_pathsz   s   ....z;DmdLikeCompilerMixin.compute_parameters_with_absolute_pathslevelc                 C     dgS )N-wir/   r.   rV   r/   r/   r0   get_warn_args      z"DmdLikeCompilerMixin.get_warn_argsc                 C  rW   )Nz-wr/   r5   r/   r/   r0   get_werror_args   r[   z$DmdLikeCompilerMixin.get_werror_argsc                 C  rW   )Nz-covr/   r5   r/   r/   r0   get_coverage_args   r[   z&DmdLikeCompilerMixin.get_coverage_argsc                 C     g S r4   r/   r5   r/   r/   r0   get_coverage_link_args      z+DmdLikeCompilerMixin.get_coverage_link_argsc                 C  rW   )Nz-Er/   r5   r/   r/   r0   get_preprocess_only_args   r[   z-DmdLikeCompilerMixin.get_preprocess_only_argsc                 C  rW   )Nz-cr/   r5   r/   r/   r0   get_compile_only_args   r[   z*DmdLikeCompilerMixin.get_compile_only_argsc                 C     dS Ndepsr/   r5   r/   r/   r0   get_depfile_suffix   r`   z'DmdLikeCompilerMixin.get_depfile_suffix	outtargetoutfilec                 C  s   | j r	d| gS g S )Nz
-makedeps=)r-   r.   rg   rh   r/   r/   r0   get_dependency_gen_args      z,DmdLikeCompilerMixin.get_dependency_gen_argsc                 C     | j  rg S dgS Nz-fPICinfor   r5   r/   r/   r0   get_pic_args      
z!DmdLikeCompilerMixin.get_pic_argskwargsT.Dict[str, T.Any]build_to_srcc                 C    g }|  }d|v r'|d}t| j d }|s td|   |r'|| d|v rd}|d}t|ts:|g}t| j d }|sKtd|   |D ],}	t|	t	r[|	|krZ|	}qMt|	t
ro|	 rot	|	|krnt	|	}qM|| d|	  qM|dkr|| d|  d|v rd}
|d}t|ts|g}t| j d	 }|std
|   |D ],}t|t	r||
kr|}
qt|t
r| rt	||
krt	|}
q|| d|  q|
dkr|| d|
  d|v rI|d}t|ts|g}t| j d }|std|   |D ]9}| }| D ]-}tj||}|dvr*|}n|}tj||}|| |  || |  qq|rWtdd|  |S Nr   z6D compiler %s does not support the "unittest" feature.r   z=D compiler %s does not support conditional debug identifiers.=r   versionsr   z?D compiler %s does not support conditional version identifiers.import_dirsr   zGD compiler %s does not support the "string import directories" feature.)rC   rD   z*Unknown D compiler feature(s) selected: %sz, copypopd_feature_argsidr   name_stringappend
isinstancelistintr9   isdigitZ
get_curdirZget_incdirsrO   r@   rQ   keysr.   rr   rt   resr   Zunittest_argZdebug_levelZdebugsZ	debug_argdZversion_levelry   Zversion_argvrz   Zimport_dir_argZidir_objZbasedirZidirZ
bldtreedirZexpdirZ
srctreedirr/   r/   r0   get_feature_args      











z%DmdLikeCompilerMixin.get_feature_args	buildtypec                 C     |dkr|   S g S Nr#   r6   r.   r   r/   r/   r0   get_buildtype_linker_args      z.DmdLikeCompilerMixin.get_buildtype_linker_args
implibnamec                 C  s   | j |S r4   )linkerZimport_library_args)r.   r   r/   r/   r0   gen_import_library_args     z,DmdLikeCompilerMixin.gen_import_library_argsenv'Environment'from_dirrpath_pathsT.Tuple[str, ...]build_rpathinstall_rpath"T.Tuple[T.List[str], T.Set[bytes]]c                   s   | j  r
g t fS | jjdrIg }t ||||||\}}	|D ]"}
d|
v r?|
jddd\}}|	| |	| j
|  q"|	|
 q"||	fS t ||||||S )Nld,r   maxsplit)ro   r   setr   r   
startswithsuperbuild_rpath_argssplitr   LINKER_PREFIX)r.   r   rH   r   r   r   r   argsZ
rpath_argsZrpath_dirs_to_removerab	__class__r/   r0   r     s"   


z%DmdLikeCompilerMixin.build_rpath_argsr   ro   r   link_idc                 C  s  g }d}g d}|D ]G}g }|  r| |}n	| r"| |}|r*|| q
|dkr/q
|dr5q
|drD|dksD|dsDq
|drf||dd	 d  d}	|	D ]}
|d
|
	   qYq
|drq|| q
|dr~|d
|  q
|dr|dr|d|dd    n|d|dd    q
|dr|dr|d|dd    n|d|dd    q
|dr9|d
r|dd  }n|dd  }|r|| d}q
||v rd}|ds|dr|| q
|  r|dkr|dr|| q
|
ds|
d r1t|d!kr1|ds1|d
|  q
|d
|  q
|dsM|
d"rM|d
|  q
|| q
|S )#NF)z-rpathz-rpath-linkz-sonamez-compatibility_versionz-current_versionz-pthreadz-fstack-protectorz-D)z-Ddz-Df-Wl,r   r   r7   )z-link-defaultlibz-linkerz-link-internallyz-linkonce-templatesz-libz-lz-isystemz	-isystem=rE   	   -I   z
-idirafterz-idirafter=   
   -LrI   r   T-@link/.a.libr   )r   r   )r   translate_arg_to_windows	is_darwin_translate_arg_to_osxextendr   indexr   r   stripendswithlen)clsr   ro   r   ZdcargsZlink_expect_argZlink_flags_with_argargZosargslinkargslasuffixr/   r/   r0   _translate_args_to_nongnu!  s   














 
z.DmdLikeCompilerMixin._translate_args_to_nongnur   c                 C  s   g }| dr.||dd d  d}|D ]}| dr+|d|dd     q|S | dr\|| |dd   }| tu r\|d	krR|d
 |d | dr\|d |S )Nr   r   r   z--out-implib=z-L=/IMPLIB:   
-mscrtlib=r   Zlibcmtz-L=/NODEFAULTLIB:libcmtz-L=/NODEFAULTLIB:libvcruntimemsvcrtz+-L=/DEFAULTLIB:legacy_stdio_definitions.lib)r   r   r   r   r   lowerLLVMDCompiler)r   r   r   r   r   Zmscrtlibr/   r/   r0   r     s$   







z-DmdLikeCompilerMixin.translate_arg_to_windowsc                 C  s    g }| dr|d|  |S )Nz-install_namer7   )r   r   )r   r   r   r/   r/   r0   r     s   
z*DmdLikeCompilerMixin._translate_arg_to_osxrC   c                 C  s   |  |||S r4   )r   )r   r   ro   r   r/   r/   r0   _unix_args_to_native  s   z)DmdLikeCompilerMixin._unix_args_to_nativeis_debugc                 C  s$   g }|rt | j d g}t| | S )Nr   )r~   r   r   )r.   r   Zddebug_argsr/   r/   r0   get_debug_args  s   z#DmdLikeCompilerMixin.get_debug_argscrt_valc                 C  s   | j  sg S || jv r| j| S |dv sJ d}d}|dkr#d}d}|dkr)g S |dkr2| j| S |d	kr;| j| S |d
krD| j| S |dkrM| j| S |dksSJ td)N>   static_from_buildtypeZfrom_buildtypemddmdr   mtdmtr#   r   ZdebugoptimizedreleaseZminsizeZcustomzBRequested C runtime based on buildtype, but buildtype is "custom".)ro   r   
mscrt_argsr   )r.   r   r   Zdbgrelr/   r/   r0   _get_crt_args  s,   






z"DmdLikeCompilerMixin._get_crt_argsprefix
shlib_namer   	soversiondarwin_versionsT.Tuple[str, str]c                   s   t  ||||||}| jjdr1g }|D ]}	|	jddd\}
}||
 || j|  q|S | jjdrUg }|D ]}	|	| jsM|| j|	  q<||	 q<|S |S )Nzld.r   r   r   Zld64)r   get_soname_argsr   r   r   r   r   r   )r.   r   r   r   r   r   r   ZsargsZsoargsr   r   r   r   r/   r0   r     s$   
z$DmdLikeCompilerMixin.get_soname_argsc                 C  s&   | j  }| j rdd |D }|S )Nc                 S  s   g | ]}| d dqS )r7   z	-Xcc=-Wl,)replace).0r   r/   r/   r0   
<listcomp>  s    zFDmdLikeCompilerMixin.get_allow_undefined_link_args.<locals>.<listcomp>)r   get_allow_undefined_argsro   r   r.   r   r/   r/   r0   get_allow_undefined_link_args  s   

z2DmdLikeCompilerMixin.get_allow_undefined_link_args)r+   r,   r2   r3   )r8   r9   r2   r3   )r@   r9   rA   rB   r2   r3   rG   r3   rH   r9   r2   r3   rV   r9   r2   r3   r2   r9   rg   r9   rh   r9   r2   r3   rr   rs   rt   r9   r2   r3   r   r9   r2   r3   )r   r9   r2   r3   )r   r   rH   r9   r   r9   r   r   r   r9   r   r9   r2   r   )r   r3   ro   r   r   r9   r2   r3   )r   r9   r2   r3   )rC   )r   rB   r2   r3   r   r9   r   r9   r2   r3   )r   r   r   r9   r   r9   r   r9   r   r9   r   r   r2   r3   )%__name__
__module____qualname____doc__r1   TTYPE_CHECKINGr   r6   r   r=   r?   rF   rU   rZ   r\   r]   r_   ra   rb   rf   rj   rp   r   r   r   r   classmethodr   r   r   r   r   r   r   r   __classcell__r/   r/   r   r0   r*   Y   sH    
















X
~

r*   c                   @  s   e Zd ZdZdZdS )DCompilerArgs)r   r   )r   N)r   r   r   Zprepend_prefixesZdedup2_prefixesr/   r/   r/   r0   r     s    r   c                      s  e Zd ZdgdgdgdgdgdZdZdddd	d
d^ fddZd_d#d$Zd`d%d&Zdad'd(Zdbd)d*Z	dcd.d/Z
ddd1d2Zdedfd6d7Zdgd:d;Zdbd<d=Zdhd?d@ZdhdAdBZdedidEdFZdddGdjdMdNZdddGdkdSdTZdddGdldVdWZddd	dXdmd\d]Z  ZS )n	DCompilerr   z-mscrtlib=msvcrtz-mscrtlib=msvcrtdz-mscrtlib=libcmtz-mscrtlib=libcmtd)noner   r   r   r   r   NFexe_wrapperr   full_versionis_crossexelistr3   r   r9   for_machiner   ro   'MachineInfo'archr   T.Optional['ExternalProgram']r   T.Optional['DynamicLinker']r   r,   r   rB   c          
   
     s,   t  jg |||||||	d || _|| _d S )N)r   r   r   )r   r1   r  r   
r.   r  r   r  ro   r  r   r   r   r   r   r/   r0   r1     s
   
zDCompiler.__init__work_direnvironmentr   r2   Nonec                 C  s   t j|d}t j|d}t|ddd}|d W d    n1 s%w   Y  tj| j| | | 	  |g |d}|
  |jdkrOtd	|   | jrb| jd u rYd S | j |g }n|g}t|dkrttd
|   d S )Nzsanity.dZdtestwzutf-8)encodingzvoid main() { })cwdr   z'D compiler %s can not compile programs.z6Executables created by D compiler %s are not runnable.)rO   r@   rQ   openwrite
subprocessPopenr  r=   r6   wait
returncoder   r   r   r   get_commandcall)r.   r  r	  Zsource_nameoutput_nameZofileZpccmdlistr/   r/   r0   sanity_check*  s"   (

zDCompiler.sanity_checkc                 C  rc   )NTr/   r5   r/   r/   r0   needs_static_linker=  r`   zDCompiler.needs_static_linkerc                 C  rc   rd   r/   r5   r/   r/   r0   rf   @  r`   zDCompiler.get_depfile_suffixc                 C  rl   rm   rn   r5   r/   r/   r0   rp   C  rq   zDCompiler.get_pic_argsrr   rs   rt   c                 C  ru   rv   r{   r   r/   r/   r0   r   H  r   zDCompiler.get_feature_argsr   c                 C  r   r   r   r   r/   r/   r0   r     r   z#DCompiler.get_buildtype_linker_argsr   T.Optional[T.Iterable[str]]r   c                 C  s
   t | |S r4   )r   r   r/   r/   r0   compiler_args  r>   zDCompiler.compiler_argsr   T.Tuple[bool, bool]c                 C  s   | j d||dS )Nzint i;
)
extra_args)compiles)r.   r   r   r/   r/   r0   has_multi_arguments  s   zDCompiler.has_multi_argumentsc                 C  s$   | j  r| jdkrdgS dgS g S )Nx86_64-m64-m32ro   r   r  r5   r/   r/   r0   r6     s
   

zDCompiler._get_target_arch_argsr   c                 C  r^   r4   r/   r.   r   r   r/   r/   r0   get_crt_compile_args  r`   zDCompiler.get_crt_compile_argsc                 C  r^   r4   r/   r$  r/   r/   r0   get_crt_link_args  r`   zDCompiler.get_crt_link_argsr  GT.Union[T.List[str], T.Callable[[CompileCheckMode], T.List[str]], None]c                 C  sN   |   }|r%t|r|tj}t|tr|| |S t|tr%|| |S r4   )	r6   callabler   ZCOMPILEr   r   r   r9   r   )r.   r  r   r/   r/   r0   _get_compile_extra_args  s   




z!DCompiler._get_compile_extra_argsr  dependenciescode'mesonlib.FileOrString'r+   T.Optional[T.List['Dependency']]compilers.RunResultc                C  sf  | | j}|r| jd u rtd| |}| j||||dddl}|jdkrBt	d|j
 d|j d td	W  d    S |rN| j |jg }n|jg}z
t|\}}	}
W n* ty } zt	d
| d| d td	W  Y d }~W  d    S d }~ww W d    n1 sw   Y  t	d t	|	 t	d t	|
 td|j|	|
S )Nz8Can not run test applications in this cross environment.r   T)modeZwant_outputr   zCould not compile test file z: 
FzCould not run: z	 (error: z)
zProgram stdout:
zProgram stderr:
)need_exe_wrapperr  r   r   ZCrossNoRunExceptionr)  Z_build_wrapperr  r   r   Z
input_nameZ	RunResultr  r  r   Z
Popen_safe	Exception)r.   r,  r   r  r+  r2  pr  pesoseer/   r/   r0   run  s6   







zDCompiler.runtypenamer   GT.Union[None, T.List[str], T.Callable[[CompileCheckMode], T.List[str]]]T.Tuple[int, bool]c                C  s^   |d u rg }d| d| d}| j ||||d}|jsdS |jdkr'tdt|j|jfS )N-
        import std.stdio : writeln;
        ,
        void main() {
            writeln((z).sizeof);
        }
        r*  )rw   Fr   z!Could not run sizeof test binary.)Z
cached_runcompiledr  r   r   r   stdoutcached)r.   r:  r   r   r  r+  tr   r/   r/   r0   sizeof  s   


zDCompiler.sizeofT.Optional[T.List[str]]c          	      C  s   |d u rg }d| d| d}| j ||||d}|js td|jdkr*tdt|j}|dkr<td| d	||jfS )
Nr=  r>  z).alignof);
        }
        r*  z!Could not compile alignment test.r   z$Could not run alignment test binary.z!Could not determine alignment of z&. Sorry. You might want to file a bug.)r9  r?  r   r   r  r   r@  rA  )	r.   r:  r   r   r  r+  rB  r   Zalignr/   r/   r0   	alignment  s$   





zDCompiler.alignment)r  r+  disable_cachehnameIT.Union[None, T.List[str], T.Callable[['CompileCheckMode'], T.List[str]]]rF  c                C  s0   |  |}| d| d}| j||||d|dS )Nz
        import z
;
        compile)r  r+  r0  rF  )r)  r  )r.   rG  r   r   r  r+  rF  r,  r/   r/   r0   
has_header  s   

zDCompiler.has_headerr  r3   r   r9   r  r   ro   r  r  r9   r   r  r   r  r   r,   r   rB   )r  r9   r	  r   r2   r
  r2   rB   r   r   r   r   r4   )r   r  r2   r   )r   r3   r   r   r2   r  r   )r  r'  r2   r3   )
r,  r-  r   r   r  r'  r+  r.  r2   r/  )r:  r9   r   r9   r   r   r  r;  r+  r.  r2   r<  )r:  r9   r   r9   r   r   r  rD  r+  r.  r2   r<  )rG  r9   r   r9   r   r   r  rH  r+  r.  rF  rB   r2   r  )r   r   r   r   languager1   r  r  rf   rp   r   r   r  r  r6   r%  r&  r)  r9  rC  rE  rJ  r   r/   r/   r   r0   r     sL    





X


	
r   c                      s   e Zd ZejZdZdddddd0ddZd1 fddZd2 fddZd3d!d"Z	d4d$d%Z
d5d(d)Zd6d*d+Zd6 fd,d-Zd6d.d/Z  ZS )7GnuDCompilerr    NFr   r  r3   r   r9   r  r   ro   r  r  r   r  r   r  r   r,   r   rB   c                C  s   t j| |||||||||	d
 t| i  ddg}
g |
|
dg |
ddg |
ddg | t d| _dd d	D | _t| jd
| _	t| jd| _
d S )Nr   z-Wallz-Wdeprecatedz-Wextraz
-Wpedantic)r$   r&   r'   r(   Z
everythingc                 S     h | ]}t |qS r/   r
   r   or/   r/   r0   	<setcomp>/  s    z(GnuDCompiler.__init__.<locals>.<setcomp>)
b_coloroutZ
b_sanitizeZb_staticpicb_vscrt
b_coverageZb_pgob_ndebugz>=4.9z>=7.1)r   r1   r   Zsupported_warn_argsr   	warn_argsbase_optionsr	   r   _has_color_support_has_deps_support)r.   r  r   r  ro   r  r   r   r   r   Zdefault_warn_argsr/   r/   r0   r1     s&   

zGnuDCompiler.__init__	colortyper2   c                   s   | j r	t | g S r4   )rZ  r   get_colorout_argsr.   r\  r   r/   r0   r]  9  rk   zGnuDCompiler.get_colorout_argsrg   rh   c                   s   | j r
t ||S g S r4   )r[  r   rj   ri   r   r/   r0   rj   >  s   z$GnuDCompiler.get_dependency_gen_argsrV   c                 C  s
   | j | S r4   )rX  rY   r/   r/   r0   rZ   C  r>   zGnuDCompiler.get_warn_argsr   c                 C     t | S r4   )r   r   r/   r/   r0   get_buildtype_argsF     zGnuDCompiler.get_buildtype_argsrG   rH   c              
   C  sd   t |D ]+\}}|d d dks|d d dkr/|d d tjtj||dd   ||< q|S )Nr   r   r   rM   rR   r/   r/   r0   rU   I  s
    .z3GnuDCompiler.compute_parameters_with_absolute_pathsc                 C  s
   | j  S r4   )r   r   r5   r/   r/   r0   r   Q  r>   z*GnuDCompiler.get_allow_undefined_link_argsc                   "   t   }| j r|S |dg S )Nz-shared-libphobosr   get_linker_always_argsro   r   r   r   r/   r0   rd  T     


z#GnuDCompiler.get_linker_always_argsc                 C  rW   )Nz	-freleaser/   r5   r/   r/   r0   get_disable_assert_argsZ  r[   z$GnuDCompiler.get_disable_assert_argsrK  r\  r9   r2   r3   r   r   r   r   r   )r   r   r   r   r   r   r1   r]  rj   rZ   r`  rU   r   rd  rf  r   r/   r/   r   r0   rN    s     



rN  version_outputr,   r2   c                 C  s*   | d u rd S t d| }|r|dS d S )NzDMD v(\d+\.\d+\.\d+)r   )researchgroup)rh  Zversion_regexr/   r/   r0   find_ldc_dmd_frontend_versionc  s   
rl  c                      s   e Zd ZdZddddddd7ddZd8ddZd9ddZd:d!d"Zd;d#d$Zd<d&d'Z	d=d)d*Z
d>d,d-Zed?d.d/Zd; fd0d1Zd;d2d3Zd@d5d6Z  ZS )Ar   r!   NF)r   r   r   r   rh  r  r3   r   r9   r  r   ro   r  r  r   r  r   r  r   r,   r   rB   rh  c                C  sD   t j| |||||||||	d
 tj| t|
d dd dD | _d S )Nr   )r+   c                 S  rO  r/   rP  rQ  r/   r/   r0   rS  y      z)LLVMDCompiler.__init__.<locals>.<setcomp>rV  rT  rU  rW  )r   r1   r*   rl  rY  )r.   r  r   r  ro   r  r   r   r   r   rh  r/   r/   r0   r1   o  s   zLLVMDCompiler.__init__r\  r2   c                 C     |dkrdgS g S )Nalwaysz-enable-colorr/   r^  r/   r/   r0   r]  {     zLLVMDCompiler.get_colorout_argsrV   c                 C  s"   |dv rddgS |dkrdgS g S )N>   r(   r'   rX   z-dwr&   r/   rY   r/   r/   r0   rZ     s
   zLLVMDCompiler.get_warn_argsr   c                 C      |dkr|   t|  S t| S r   )r6   r   r   r/   r/   r0   r`       z LLVMDCompiler.get_buildtype_argsc                 C  rW   )Nz-relocation-model=picr/   r5   r/   r/   r0   rp     r[   zLLVMDCompiler.get_pic_argsr   c                 C     |  ||S r4   r   r$  r/   r/   r0   r&    r   zLLVMDCompiler.get_crt_link_argsr   c                 C     |  || j| jjS r4   r   ro   r   r   r   r/   r/   r0   unix_args_to_native     z!LLVMDCompiler.unix_args_to_nativeoptimization_levelc                 C  r_  r4   )ldc_optimization_argsr.   rz  r/   r/   r0   get_optimization_args  ra  z#LLVMDCompiler.get_optimization_argsc                 C  s   d| gS )Nz-linker=r/   )r   r   r   r/   r/   r0   use_linker_args  s   zLLVMDCompiler.use_linker_argsc                   rb  )Nz-link-defaultlib-sharedrc  r   r   r/   r0   rd    re  z$LLVMDCompiler.get_linker_always_argsc                 C  rW   )Nz	--releaser/   r5   r/   r/   r0   rf    r[   z%LLVMDCompiler.get_disable_assert_argsr   c                 C  s   t  rtjS tjS r4   )r   r   MSVCZGCCr5   r/   r/   r0   rsp_file_syntax  s   zLLVMDCompiler.rsp_file_syntax)r  r3   r   r9   r  r   ro   r  r  r9   r   r  r   r  r   r,   r   rB   rh  r,   rg  r   r   r   r   r   r3   r2   r3   rz  r9   r2   r3   )r   r9   r   r9   r2   r3   r2   r   )r   r   r   r   r1   r]  rZ   r`  rp   r&  rx  r}  r   r~  rd  rf  r  r   r/   r/   r   r0   r   k  s&    







r   c                      s   e Zd ZdZdddddd7ddZd8ddZd9d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d>d.d/Zd: fd0d1Zd:d2d3Zd?d5d6Z  ZS )@DmdDCompilerr"   NFr   r  r3   r   r9   r  r   ro   r  r  r   r  r   r  r   r,   r   rB   c          
      C  s>   t j| |||||||||	d
 t| | dd dD | _d S )Nr   c                 S  rO  r/   rP  rQ  r/   r/   r0   rS    rm  z(DmdDCompiler.__init__.<locals>.<setcomp>rn  )r   r1   r*   rY  r  r/   r/   r0   r1     s   zDmdDCompiler.__init__r\  r2   c                 C  ro  )Nrp  z	-color=onr/   r^  r/   r/   r0   r]    rq  zDmdDCompiler.get_colorout_argsr   c                 C  rr  r   )r6   r   r   r/   r/   r0   r`    rs  zDmdDCompiler.get_buildtype_argsc                 C  4   | j  r| jdkrdgS | jdkrdgS dgS g S )Nr   phobos64.lib
x86_mscoffphobos32mscoff.lib
phobos.libr#  r5   r/   r/   r0   get_std_exe_link_args  s   


z"DmdDCompiler.get_std_exe_link_argsc                 C  s>   d}| j  r| jdkrd}n
| jdkrd}nd}dd| gS )	Nzlibphobos2.sor   r  r  r  r  z-sharedz-defaultlib=r#  )r.   libnamer/   r/   r0   get_std_shared_lib_link_args  s   


z)DmdDCompiler.get_std_shared_lib_link_argsc                 C  r  )Nr   r!  r  z
-m32mscoffr"  r#  r5   r/   r/   r0   r6     s   


z"DmdDCompiler._get_target_arch_argsr   c                 C  rt  r4   ru  r$  r/   r/   r0   r%    r   z!DmdDCompiler.get_crt_compile_argsr   c                 C  rv  r4   rw  r   r/   r/   r0   rx    ry  z DmdDCompiler.unix_args_to_nativerz  c                 C  r_  r4   )dmd_optimization_argsr|  r/   r/   r0   r}    ra  z"DmdDCompiler.get_optimization_argsc                 C  rc   )NFr/   r5   r/   r/   r0   can_linker_accept_rsp  r`   z"DmdDCompiler.can_linker_accept_rspc                   s$   t   }| j r|S |ddg S )Nz-defaultlib=phobos2z-debuglib=phobos2rc  r   r   r/   r0   rd    s   

z#DmdDCompiler.get_linker_always_argsc                 C  rW   )Nz-releaser/   r5   r/   r/   r0   rf    r[   z$DmdDCompiler.get_disable_assert_argsr   c                 C  s   t jS r4   )r   r  r5   r/   r/   r0   r    r[   zDmdDCompiler.rsp_file_syntaxrK  rg  r   r   r   r  r  rL  r  )r   r   r   r   r1   r]  r`  r  r  r6   r%  rx  r}  r  rd  rf  r  r   r/   r/   r   r0   r    s&    









r  )rh  r,   r2   r,   )4
__future__r   os.pathrO   ri  r  typingr   rC   r   r   Zarglistr   Zlinkersr   r   r	   r
   r   r   r   r   r   r   r   r   Z
mixins.gnur   r   r   r+  r   Zprogramsr   Z	envconfigr   r	  r   r   r   ZCompilerMixinBaseobjectr~   r{  r  r*   r   r   rN  rl  r   r  r/   r/   r/   r0   <module>   s    	
   9  
LA