o
    uJAfT                     @  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 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) 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-d e.d!< g g g d"gd#gd$gd%gd&Z/d'e.d(< g g g d)gd)gd)gd)gd&Z0d'e.d*< G d+d, d,e+Z1G d-d. d.eZ2G d/d0 d0eZ3G d1d2 d2ee3Z4d<d6d7Z5G d8d9 d9e1e3Z6G d:d; d;e1e3Z7dS )=    )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)	DFeatures)
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T.Dict[str, T.Dict[str, str]]d_feature_argsz-O1z-O2z-O3z-Oz)plain0g123sT.Dict[str, T.List[str]]ldc_optimization_argsz-Odmd_optimization_argsc                      sJ  e Zd ZU dZd_ddZejri Zded< d`d
dZ	dZ
daddZdaddZdbddZdcddZddddZd`dd Zd`d!d"Zd`d#d$Zd`d%d&Zd`d'd(Zded)d*Zdfd-d.Zd`d/d0Zdgd2d3Zdhd5d6Zdi fd?d@ZedjdEdFZedkdHdIZedkdJdKZedldjdMdNZdmdPdQZ dndSdTZ!do fd[d\Z"d`d]d^Z#  Z$S )p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	   )selfr0    r4   ;/usr/lib/python3.10/site-packages/mesonbuild/compilers/d.py__init__h   s   
zDmdLikeCompilerMixin.__init__r,   
mscrt_argsreturnT.List[str]c                 C  s   d S Nr4   r3   r4   r4   r5   _get_target_arch_argsr   s    z*DmdLikeCompilerMixin._get_target_arch_args-L=
outputnamestrc                 C  
   d| gS Nz-of=r4   r3   r>   r4   r4   r5   get_output_argsv      
z$DmdLikeCompilerMixin.get_output_argsc                 C  r@   rA   r4   rB   r4   r4   r5   get_linker_output_argsy   rD   z+DmdLikeCompilerMixin.get_linker_output_argspath	is_systemboolc                 C  s   |dkrd}d| gS )N .-I=r4   )r3   rF   rG   r4   r4   r5   get_include_args|   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   rK      z-L-L   z-L=-L   z-Wl,-L	enumerateosrF   normpathjoinr3   rM   rN   idxir4   r4   r5   &compute_parameters_with_absolute_paths   s   ....z;DmdLikeCompilerMixin.compute_parameters_with_absolute_pathslevelc                 C     dgS )N-wir4   r3   r\   r4   r4   r5   get_warn_args      z"DmdLikeCompilerMixin.get_warn_argsc                 C  r]   )Nz-wr4   r;   r4   r4   r5   get_werror_args   ra   z$DmdLikeCompilerMixin.get_werror_argsc                 C  r]   )Nz-covr4   r;   r4   r4   r5   get_coverage_args   ra   z&DmdLikeCompilerMixin.get_coverage_argsc                 C     g S r:   r4   r;   r4   r4   r5   get_coverage_link_args      z+DmdLikeCompilerMixin.get_coverage_link_argsc                 C  r]   )Nz-Er4   r;   r4   r4   r5   get_preprocess_only_args   ra   z-DmdLikeCompilerMixin.get_preprocess_only_argsc                 C  r]   )Nz-cr4   r;   r4   r4   r5   get_compile_only_args   ra   z*DmdLikeCompilerMixin.get_compile_only_argsc                 C     dS Ndepsr4   r;   r4   r4   r5   get_depfile_suffix   rf   z'DmdLikeCompilerMixin.get_depfile_suffix	outtargetoutfilec                 C  s   | j r	d| gS g S )Nz
-makedeps=)r2   r3   rm   rn   r4   r4   r5   get_dependency_gen_args      z,DmdLikeCompilerMixin.get_dependency_gen_argsc                 C     | j  rg S dgS Nz-fPICinfor   r;   r4   r4   r5   get_pic_args      
z!DmdLikeCompilerMixin.get_pic_args	buildtypec                 C     |dkr|   S g S Nr%   r<   r3   rx   r4   r4   r5   get_buildtype_linker_args      z.DmdLikeCompilerMixin.get_buildtype_linker_args
implibnamec                 C  s   | j |S r:   )linkerimport_library_args)r3   r   r4   r4   r5   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)ru   r   setr   id
startswithsuperbuild_rpath_argssplitappendLINKER_PREFIX)r3   r   rN   r   r   r   r   argsZ
rpath_argsrpath_dirs_to_removerab	__class__r4   r5   r      s"   


z%DmdLikeCompilerMixin.build_rpath_argsr   ru   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   r=   )z-link-defaultlibz-linkerz-link-internallyz-linkonce-templatesz-libz-lz-isystemz	-isystem=rK   	   -I   z
-idirafterz-idirafter=   
   -LrO   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   ru   r   ZdcargsZlink_expect_argZlink_flags_with_argargZosargslinkargslasuffixr4   r4   r5   _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mscrtlibr4   r4   r5   r   O  s$   







z-DmdLikeCompilerMixin.translate_arg_to_windowsc                 C  s    g }| dr|d|  |S )Nz-install_namer=   )r   r   )r   r   r   r4   r4   r5   r   i  s   
z*DmdLikeCompilerMixin._translate_arg_to_osxrI   c                 C  s   |  |||S r:   )r   )r   r   ru   r   r4   r4   r5   _unix_args_to_nativep  s   z)DmdLikeCompilerMixin._unix_args_to_nativeis_debugc                 C  s$   g }|rt | j d g}t| | S )Nr   )r$   r   r   )r3   r   Zddebug_argsr4   r4   r5   get_debug_argst  s   z#DmdLikeCompilerMixin.get_debug_argscrt_valc                 C  s    | j  sg S | j| || S r:   )ru   r   r7   get_crt_valr3   r   rx   r4   r4   r5   _get_crt_args{  s   
z"DmdLikeCompilerMixin._get_crt_argsprefix
shlib_namer   	soversiondarwin_versionsT.Tuple[str, str]c                   s   t  ||||||}g }| jjdr1|D ]}	|	jddd\}
}||
 || j|  q|S | jjdrS|D ]}	|	| jsK|| j|	  q:||	 q:|S |S )Nzld.r   r   r   ld64)r   get_soname_argsr   r   r   r   r   r   )r3   r   r   r   r   r   r   ZsargsZsoargsr   r   r   r   r4   r5   r     s"   
z$DmdLikeCompilerMixin.get_soname_argsc                 C  s&   | j  }| j rdd |D }|S )Nc                 S  s   g | ]}| d dqS )r=   z	-Xcc=-Wl,)replace).0r   r4   r4   r5   
<listcomp>  s    zFDmdLikeCompilerMixin.get_allow_undefined_link_args.<locals>.<listcomp>)r   get_allow_undefined_argsru   r   r3   r   r4   r4   r5   get_allow_undefined_link_args  s   

z2DmdLikeCompilerMixin.get_allow_undefined_link_args)r0   r1   r8   r9   )r>   r?   r8   r9   )rF   r?   rG   rH   r8   r9   rM   r9   rN   r?   r8   r9   r\   r?   r8   r9   r8   r?   rm   r?   rn   r?   r8   r9   rx   r?   r8   r9   )r   r?   r8   r9   )r   r   rN   r?   r   r?   r   r   r   r?   r   r?   r8   r   )r   r9   ru   r   r   r?   r8   r9   )r   r?   r8   r9   )rI   )r   rH   r8   r9   r   r?   rx   r?   r8   r9   )r   r   r   r?   r   r?   r   r?   r   r?   r   r   r8   r9   )%__name__
__module____qualname____doc__r6   TTYPE_CHECKINGr7   __annotations__r<   r   rC   rE   rL   r[   r`   rb   rc   re   rg   rh   rl   rp   rv   r}   r   r   classmethodr   r   r   r   r   r   r   r   __classcell__r4   r4   r   r5   r/   `   sF   
 
















~

r/   c                   @  s   e Zd ZdZdZdS )DCompilerArgs)r   r   )r   N)r   r   r   prepend_prefixesdedup2_prefixesr4   r4   r4   r5   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)nonemdmddmtmtddNFexe_wrapperr   full_versionis_crossexelistr9   r   r?   for_machiner   ru   'MachineInfo'archr   T.Optional['ExternalProgram']r   T.Optional['DynamicLinker']r   r1   r   rH   c          
   
     s,   t  jg |||||||	d || _|| _d S )N)r   r   r   )r   r6   r   r   
r3   r   r   r   ru   r   r   r   r   r   r   r4   r5   r6     s
   
zDCompiler.__init__work_direnvironmentr   r8   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 cannot compile programs.z6Executables created by D compiler %s are not runnable.)rU   rF   rW   openwrite
subprocessPopenr   rC   r<   wait
returncoder   name_stringr   r   get_commandcall)r3   r   r   source_nameoutput_nameofilepccmdlistr4   r4   r5   sanity_check  s"   (

zDCompiler.sanity_checkc                 C  ri   )NTr4   r;   r4   r4   r5   needs_static_linker  rf   zDCompiler.needs_static_linkerc                 C  ri   rj   r4   r;   r4   r4   r5   rl     rf   zDCompiler.get_depfile_suffixc                 C  rr   rs   rt   r;   r4   r4   r5   rv     rw   zDCompiler.get_pic_argskwargsr   build_to_srcc                 C  s  g }t | j d }|std|   |d r|| d}t | j d }|s/td|   |d D ],}t|trA||kr@|}q3t|trU| rUt||krTt|}q3|| d|  q3|dkrn|| d|  d}t | j d }	|	std	|   |d
 D ],}
t|
tr|
|kr|
}qt|
tr|
 rt|
|krt|
}q||	 d|
  q|dkr||	 d|  t | j d }|std|   |d D ]6}|	 }|
 D ]+}tj||}|dvr|}n|}tj||}|| |  || |  qq|S )Nr   z6D compiler %s does not support the "unittest" feature.r   z=D compiler %s does not support conditional debug identifiers.=r   r   z?D compiler %s does not support conditional version identifiers.versionsr    zGD compiler %s does not support the "string import directories" feature.import_dirs)rI   rJ   )r$   r   r   r  r   
isinstanceintr?   isdigit
get_curdirget_incdirsrU   rF   rW   )r3   r  r  resZunittest_argZdebug_levelZ	debug_argr   Zversion_levelZversion_argvZimport_dir_argZidir_objbasediridirZ
bldtreedirZexpdirZ
srctreedirr4   r4   r5   get_feature_args  sj   


zDCompiler.get_feature_argsrx   c                 C  ry   rz   r{   r|   r4   r4   r5   r}      r~   z#DCompiler.get_buildtype_linker_argsr   T.Optional[T.Iterable[str]]r   c                 C  s
   t | |S r:   )r   r   r4   r4   r5   compiler_args%  rD   zDCompiler.compiler_argsr   T.Tuple[bool, bool]c                 C  s   | j d||dS )Nzint i;
)
extra_args)compiles)r3   r   r   r4   r4   r5   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ru   r   r   r;   r4   r4   r5   r<   +  s
   

zDCompiler._get_target_arch_argsr   c                 C  rd   r:   r4   r   r4   r4   r5   get_crt_compile_args4  rf   zDCompiler.get_crt_compile_argsc                 C  rd   r:   r4   r   r4   r4   r5   get_crt_link_args7  rf   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 r:   )	r<   callabler   COMPILEr  listr   r?   r   )r3   r"  r   r4   r4   r5   _get_compile_extra_args:  s   




z!DCompiler._get_compile_extra_argsr"  dependenciescode'mesonlib.FileOrString'r1   T.Optional[T.List['Dependency']]compilers.RunResultc                C  sh  | | j}|r| jd u rtd| |}| j||||tjddl}|j	dkrCt
d|j d|j	 d tdW  d    S |rO| 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.T)mode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   CrossNoRunExceptionr/  _build_wrapperr   LINKr  r   r   
input_name	RunResultr  r	  r   
Popen_safe	Exception)r3   r2  r   r"  r1  r9  pr  pesoseer4   r4   r5   runE  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);
        }
        r0  )r  Fr   z!Could not run sizeof test binary.)
cached_runcompiledr  r   r   r  stdoutcached)r3   rG  r   r   r"  r1  tr  r4   r4   r5   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 )
NrJ  rK  z).alignof);
        }
        r0  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.)rF  rM  r   r   r  r  rN  rO  )	r3   rG  r   r   r"  r1  rP  r  alignr4   r4   r5   	alignmentt  s$   





zDCompiler.alignment)r"  r1  disable_cachehnameIT.Union[None, T.List[str], T.Callable[['CompileCheckMode'], T.List[str]]]rU  c                C  s2   |  |}| d| d}| j||||tj|dS )Nz
        import z
;
        )r"  r1  r6  rU  )r/  r#  r   r-  )r3   rV  r   r   r"  r1  rU  r2  r4   r4   r5   
has_header  s   

zDCompiler.has_headerr   r9   r   r?   r   r   ru   r   r   r?   r   r   r   r   r   r1   r   rH   )r   r?   r   r   r8   r   r8   rH   r   r   )r  r   r  r?   r8   r9   r   r:   )r   r  r8   r   )r   r9   r   r   r8   r!  r   )r"  r+  r8   r9   )
r2  r3  r   r   r"  r+  r1  r4  r8   r5  )rG  r?   r   r?   r   r   r"  rH  r1  r4  r8   rI  )rG  r?   r   r?   r   r   r"  rR  r1  r4  r8   rI  )rV  r?   r   r?   r   r   r"  rW  r1  r4  rU  rH   r8   r!  )r   r   r   r7   languager6   r  r  rl   rv   r  r}   r   r$  r<   r)  r*  r/  rF  rQ  rT  rX  r   r4   r4   r   r5   r     sL    





B


	
r   c                      s   e Zd ZejZdZdddddd1ddZd2 fddZd3 fddZd4d!d"Z	d5d$d%Z
d6d(d)Zd7d*d+Zd7 fd,d-Zd8d/d0Z  ZS )9GnuDCompilerr!   NFr   r   r9   r   r?   r   r   ru   r   r   r   r   r   r   r   r1   r   rH   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*   
everythingc                 S     h | ]}t |qS r4   r
   r   or4   r4   r5   	<setcomp>  s    z(GnuDCompiler.__init__.<locals>.<setcomp>)
b_colorout
b_sanitizeb_staticpicb_vscrt
b_coverageb_pgob_ndebugz>=4.9z>=7.1)r   r6   r   supported_warn_argsr   	warn_argsbase_optionsr	   r   _has_color_support_has_deps_support)r3   r   r   r   ru   r   r   r   r   r   default_warn_argsr4   r4   r5   r6     s&   

zGnuDCompiler.__init__	colortyper8   c                   s   | j r	t | g S r:   )rm  r   get_colorout_argsr3   rp  r   r4   r5   rq    rq   zGnuDCompiler.get_colorout_argsrm   rn   c                   s   | j r
t ||S g S r:   )rn  r   rp   ro   r   r4   r5   rp     s   z$GnuDCompiler.get_dependency_gen_argsr\   c                 C  s
   | j | S r:   )rk  r_   r4   r4   r5   r`     rD   zGnuDCompiler.get_warn_argsrx   c                 C     t | S r:   )r   r|   r4   r4   r5   get_buildtype_args     zGnuDCompiler.get_buildtype_argsrM   rN   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   rS   rX   r4   r4   r5   r[     s
    .z3GnuDCompiler.compute_parameters_with_absolute_pathsc                 C  s
   | j  S r:   )r   r   r;   r4   r4   r5   r     rD   z*GnuDCompiler.get_allow_undefined_link_argsc                   "   t   }| j r|S |dg S )Nz-shared-libphobosr   get_linker_always_argsru   r   r   r   r4   r5   rx       


z#GnuDCompiler.get_linker_always_argsdisablec                 C     |rdgS g S )Nz	-freleaser4   r3   rz  r4   r4   r5   get_assert_args     zGnuDCompiler.get_assert_argsrY  rp  r?   r8   r9   r   r   r   r   r   rz  rH   r8   r9   )r   r   r   r   r   r   r6   rq  rp   r`   rt  r[   r   rx  r}  r   r4   r4   r   r5   r\    s     



r\  version_outputr1   r8   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)r  version_regexr4   r4   r5   find_ldc_dmd_frontend_version  s   
r  c                      s   e Zd ZdZdddddd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ed@d.d/Zd< fd0d1ZdAd3d4ZdBd6d7Z  ZS )Cr   r"   NF)r   r   r   r   r  r   r9   r   r?   r   r   ru   r   r   r   r   r   r   r   r1   r   rH   r  c                C  sD   t j| |||||||||	d
 tj| t|
d dd dD | _d S )Nr   )r0   c                 S  r^  r4   r_  r`  r4   r4   r5   rb        z)LLVMDCompiler.__init__.<locals>.<setcomp>rg  rc  rf  ri  )r   r6   r/   r  rl  )r3   r   r   r   ru   r   r   r   r   r   r  r4   r4   r5   r6     s   zLLVMDCompiler.__init__rp  r8   c                 C     |dkrdgS g S )Nalwaysz-enable-colorr4   rr  r4   r4   r5   rq       zLLVMDCompiler.get_colorout_argsr\   c                 C  s"   |dv rddgS |dkrdgS g S )N>   r*   r)   r^   z-dwr(   r4   r_   r4   r4   r5   r`     s
   zLLVMDCompiler.get_warn_argsrx   c                 C      |dkr|   t|  S t| S rz   )r<   r   r|   r4   r4   r5   rt  	     z LLVMDCompiler.get_buildtype_argsc                 C  r]   )Nz-relocation-model=picr4   r;   r4   r4   r5   rv     ra   zLLVMDCompiler.get_pic_argsr   c                 C     |  ||S r:   r   r   r4   r4   r5   r*    r   zLLVMDCompiler.get_crt_link_argsr   c                 C     |  || j| jjS r:   r   ru   r   r   r   r4   r4   r5   unix_args_to_native     z!LLVMDCompiler.unix_args_to_nativeoptimization_levelc                 C  rs  r:   )r-   r3   r  r4   r4   r5   get_optimization_args  ru  z#LLVMDCompiler.get_optimization_argsc                 C  s   d| gS )Nz-linker=r4   )r   r   r   r4   r4   r5   use_linker_args  s   zLLVMDCompiler.use_linker_argsc                   rv  )Nz-link-defaultlib-sharedrw  r   r   r4   r5   rx    ry  z$LLVMDCompiler.get_linker_always_argsrz  c                 C  r{  )Nz	--releaser4   r|  r4   r4   r5   r}  $  r~  zLLVMDCompiler.get_assert_argsr   c                 C  s   t  rtjS tjS r:   )r   r   MSVCGCCr;   r4   r4   r5   rsp_file_syntax)  s   zLLVMDCompiler.rsp_file_syntax)r   r9   r   r?   r   r   ru   r   r   r?   r   r   r   r   r   r1   r   rH   r  r1   r  r   r   r   r   r   r9   r8   r9   r  r?   r8   r9   )r   r?   r   r?   r8   r9   r  r8   r   )r   r   r   r   r6   rq  r`   rt  rv   r*  r  r  r   r  rx  r}  r  r   r4   r4   r   r5   r     s&    







r   c                      s   e Zd ZdZddddd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?d.d/Zd; fd0d1Zd@d3d4ZdAd6d7Z  ZS )BDmdDCompilerr#   NFr   r   r9   r   r?   r   r   ru   r   r   r   r   r   r   r   r1   r   rH   c          
      C  s>   t j| |||||||||	d
 t| | dd dD | _d S )Nr   c                 S  r^  r4   r_  r`  r4   r4   r5   rb  >  r  z(DmdDCompiler.__init__.<locals>.<setcomp>r  )r   r6   r/   rl  r   r4   r4   r5   r6   4  s   zDmdDCompiler.__init__rp  r8   c                 C  r  )Nr  z	-color=onr4   rr  r4   r4   r5   rq  @  r  zDmdDCompiler.get_colorout_argsrx   c                 C  r  rz   )r<   r   r|   r4   r4   r5   rt  E  r  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(  r;   r4   r4   r5   get_std_exe_link_argsJ  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(  )r3   libnamer4   r4   r5   get_std_shared_lib_link_argsU  s   


z)DmdDCompiler.get_std_shared_lib_link_argsc                 C  r  )Nr%  r&  r  z
-m32mscoffr'  r(  r;   r4   r4   r5   r<   `  s   


z"DmdDCompiler._get_target_arch_argsr   c                 C  r  r:   r  r   r4   r4   r5   r)  l  r   z!DmdDCompiler.get_crt_compile_argsr   c                 C  r  r:   r  r   r4   r4   r5   r  o  r  z DmdDCompiler.unix_args_to_nativer  c                 C  rs  r:   )r.   r  r4   r4   r5   r  r  ru  z"DmdDCompiler.get_optimization_argsc                 C  ri   )NFr4   r;   r4   r4   r5   can_linker_accept_rspu  rf   z"DmdDCompiler.can_linker_accept_rspc                   s$   t   }| j r|S |ddg S )Nz-defaultlib=phobos2z-debuglib=phobos2rw  r   r   r4   r5   rx  x  s   

z#DmdDCompiler.get_linker_always_argsrz  c                 C  r{  )Nz-releaser4   r|  r4   r4   r5   r}  ~  r~  zDmdDCompiler.get_assert_argsr   c                 C  s   t jS r:   )r   r  r;   r4   r4   r5   r    ra   zDmdDCompiler.rsp_file_syntaxrY  r  r   r   r   r  r  rZ  r  r  )r   r   r   r   r6   rq  rt  r  r  r<   r)  r  r  r  rx  r}  r  r   r4   r4   r   r5   r  0  s&    









r  )r  r1   r8   r1   )8
__future__r   Zos.pathrU   r  r  typingr   rI   r   r   arglistr   linkersr   r   r	   r
   r   r   r   r   r   r   r   r   Z
mixins.gnur   r   r   buildr   r1  r   programsr   	envconfigr   r   r   linkers.linkersr   r   CompilerMixinBaseobjectr$   r   r-   r.   r/   r   r   r\  r  r   r  r4   r4   r4   r5   <module>   s      G n
NC