
    eT                    F   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:                  r-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) 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,e+      Z1 G d- d.e      Z2 G d/ d0e      Z3 G d1 d2ee3      Z4d8d3Z5 G d4 d5e1e3      Z6 G d6 d7e1e3      Z7y)9    )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                  n    e Zd ZU dZddZej                  ri Zded<   d dZ	dZ
d!dZd!dZd"d	Z	 	 	 	 d#d
Zd$dZd dZd dZd dZd dZd dZd%dZd&dZd dZd'dZd(dZ	 	 	 	 	 	 	 	 d) fdZed*d       Zed+d       Zed+d       Zed,d*d       Zd-dZ d.dZ!	 	 	 	 	 	 	 	 d/ fdZ"d dZ# xZ$S )0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.
    c                :    |d| _         y t        |d      | _         y )NFz	>=2.095.0)_dmd_has_depfiler
   )selfdmd_frontend_versions     8/usr/lib/python3/dist-packages/mesonbuild/compilers/d.py__init__zDmdLikeCompilerMixin.__init__h   s"    '$)D! %44H+$VD!    r-   
mscrt_argsc                     y N r4   s    r6   _get_target_arch_argsz*DmdLikeCompilerMixin._get_target_arch_argsr   s    r8   -L=c                    d|z   gS Nz-of=r<   r4   
outputnames     r6   get_output_argsz$DmdLikeCompilerMixin.get_output_argsv       #$$r8   c                    d|z   gS rA   r<   rB   s     r6   get_linker_output_argsz+DmdLikeCompilerMixin.get_linker_output_argsy   rE   r8   c                    |dk(  rd}d|z   gS )N .-I=r<   )r4   path	is_systems      r6   get_include_argsz%DmdLikeCompilerMixin.get_include_args|   s    2:D~r8   c           
        t        |      D ]L  \  }}|d d dk(  rI|d d t        j                  j                  t        j                  j	                  ||dd              z   ||<   |d d dk(  rI|d d t        j                  j                  t        j                  j	                  ||dd              z   ||<   |d d dk(  rI|d d t        j                  j                  t        j                  j	                  ||dd              z   ||<   |d d dk(  s|d d t        j                  j                  t        j                  j	                  ||dd              z   ||<   O |S )	N   rK      z-L-L   z-L=-L   z-Wl,-L	enumerateosrL   normpathjoinr4   parameter_list	build_diridxis        r6   &compute_parameters_with_absolute_pathsz;DmdLikeCompilerMixin.compute_parameters_with_absolute_paths   sN   / 	_FC!u~&'ebgg.>.>rww||IWXYZY[W\?].^&^s#!u&'ebgg.>.>rww||IWXYZY[W\?].^&^s#!u&'ebgg.>.>rww||IWXYZY[W\?].^&^s#!u &'ebgg.>.>rww||IWXYZY[W\?].^&^s#	_ r8   c                    dgS )N-wir<   r4   levels     r6   get_warn_argsz"DmdLikeCompilerMixin.get_warn_args   s	    wr8   c                    dgS )Nz-wr<   r=   s    r6   get_werror_argsz$DmdLikeCompilerMixin.get_werror_args   	    vr8   c                    dgS )Nz-covr<   r=   s    r6   get_coverage_argsz&DmdLikeCompilerMixin.get_coverage_args   s	    xr8   c                    g S r;   r<   r=   s    r6   get_coverage_link_argsz+DmdLikeCompilerMixin.get_coverage_link_args       	r8   c                    dgS )Nz-Er<   r=   s    r6   get_preprocess_only_argsz-DmdLikeCompilerMixin.get_preprocess_only_args   rf   r8   c                    dgS )Nz-cr<   r=   s    r6   get_compile_only_argsz*DmdLikeCompilerMixin.get_compile_only_args   rf   r8   c                     yNdepsr<   r=   s    r6   get_depfile_suffixz'DmdLikeCompilerMixin.get_depfile_suffix       r8   c                *    | j                   rd| gS g S )Nz
-makedeps=)r3   )r4   	outtargetoutfiles      r6   get_dependency_gen_argsz,DmdLikeCompilerMixin.get_dependency_gen_args   s        	*++	r8   c                @    | j                   j                         rg S dgS Nz-fPICinfor   r=   s    r6   get_pic_argsz!DmdLikeCompilerMixin.get_pic_args       99!Iyr8   c                0    |dk7  r| j                         S g S Nr&   r>   r4   	buildtypes     r6   get_buildtype_linker_argsz.DmdLikeCompilerMixin.get_buildtype_linker_args       --//	r8   c                8    | j                   j                  |      S r;   )linkerimport_library_args)r4   
implibnames     r6   gen_import_library_argsz,DmdLikeCompilerMixin.gen_import_library_args   s    {{..z::r8   c                   | j                   j                         rg t               fS | j                  j                  j                  d      rg }t        |   ||||||      \  }}	|D ]]  }
d|
v rF|
j                  dd      \  }}|j                  |       |j                  | j                  |z          M|j                  |
       _ ||	fS t        |   ||||||      S )Nld,r   maxsplit)r|   r   setr   id
startswithsuperbuild_rpath_argssplitappendLINKER_PREFIX)r4   envr[   from_dirrpath_pathsbuild_rpathinstall_rpathargs
rpath_argsrpath_dirs_to_removerab	__class__s                r6   r   z%DmdLikeCompilerMixin.build_rpath_args   s     99!; ;;>>$$T* !#D161IHk;2W.Z- #!877373DAqKKNKK 2 2Q 67KKN# .//w'Hk;O 	Or8   c                   g }d}g d}|D ]]  }g }|j                         r| j                  |      }n!|j                         r| j                  |      }|r|j	                  |       ]|dk(  rc|j                  d      ru|j                  d      r|dk(  s|j                  d      s|j                  d      rP||j                  d      d	z   d  j                  d      }	|	D ]$  }
|j                  d
|
j                         z          & |j                  d      r|j                  |       "|j                  d      r|j                  d
|z          I|j                  d      rB|j                  d      r|j                  d|dd  z          n|j                  d|dd  z          |j                  d      rB|j                  d      r|j                  d|dd  z          n|j                  d|dd  z          |j                  d      r|j                  d
      r|dd  }n|dd  }|r|j                  |       d}4||v rd}|j                  d      s|j                  d      r|j                  |       o|j                         r)|dk(  r$|j                  d      r|j                  |       |j                  d      s|j                  d       r5t        |      d!kD  r'|j                  d      s|j                  d
|z          |j                  d
|z          |j                  d      s'|j                  d"      r|j                  d
|z          M|j                  |       ` |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=   
   -LrP   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   r|   link_iddcargslink_expect_arglink_flags_with_argargosargslinkargslasuffixs               r6   _translate_args_to_nongnuz.DmdLikeCompilerMixin._translate_args_to_nongnu   s$    !  
  n	#C"$F 55c:!2237f% j ~~12~~d#SD[CNN><Z ~~f%syy~12399#>" 6BMM%"((*"456 rs c"%eck*
+ >>+.MM%#ab'/2MM$QR.1->>-0MM%#bc("23MM$RS/2%  >>%( WF WF" MM#&&+O00&*O$$S)V->->s-CMM#& ??$F):v?P?PQT?UMM#& <<%f)=6{Qv/@/@/Eefn5 eck*^^C(S\\.-Ieck*c"]n	#` r8   c                   g }|j                  d      rf||j                  d      dz   d  j                  d      }|D ]9  }|j                  d      s|j                  d|dd  j	                         z          ; |S |j                  d      ru|j                  |       |dd  j                         }| t        u rI|d	k7  r"|j                  d
       |j                  d       |j                  d      r|j                  d       |S )Nr   r   r   z--out-implib=z-L=/IMPLIB:   
-mscrtlib=r   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   mscrtlibs         r6   r   z-DmdLikeCompilerMixin.translate_arg_to_windowsO  s    >>&!399S>A-./55c:H A==1KK23 ?@A$  ^^L)KK23x~~'Hm# x'KK 9:KK ?@ &&x0KK MNr8   c                T    g }|j                  d      r|j                  d|z          |S )Nz-install_namer?   )r   r   )r   r   r   s      r6   r   z*DmdLikeCompilerMixin._translate_arg_to_osxi  s(    >>/*KK$r8   c                (    | j                  |||      S r;   )r   )r   r   r|   r   s       r6   _unix_args_to_nativez)DmdLikeCompilerMixin._unix_args_to_nativep  s    ,,T4AAr8   c                P    g }|rt         | j                     d   g}t        |   |z   S )Nr   )r%   r   r   )r4   is_debugddebug_argss      r6   get_debug_argsz#DmdLikeCompilerMixin.get_debug_argst  s0    )$''27;<K)K77r8   c                x    | j                   j                         sg S | j                  | j                  ||         S r;   )r|   r   r9   get_crt_valr4   crt_valr   s      r6   _get_crt_argsz"DmdLikeCompilerMixin._get_crt_args{  s3    yy##%It//CDDr8   c                   t         |   ||||||      }g }| j                  j                  j	                  d      rN|D ]G  }	|	j                  dd      \  }
}|j                  |
       |j                  | j                  |z          I |S | j                  j                  j	                  d      rT|D ]M  }	|	j	                  | j                        s|j                  | j                  |	z          =|j                  |	       O |S |S )Nzld.r   r   r   ld64)r   get_soname_argsr   r   r   r   r   r   )r4   r   prefix
shlib_namer   	soversiondarwin_versionssargssoargsr   r   r   r   s               r6   r   z$DmdLikeCompilerMixin.get_soname_args  s     'VZ(1?D
 !;;>>$$U+ 6yyqy11a d001456 M[[^^&&v. '~~d&8&89MM$"4"4s":;MM#&	'
 MLr8   c                    | j                   j                         }| j                  j                         r|D cg c]  }|j	                  dd       }}|S c c}w )Nr?   z	-Xcc=-Wl,)r   get_allow_undefined_argsr|   r   replace)r4   r   r   s      r6   get_allow_undefined_link_argsz2DmdLikeCompilerMixin.get_allow_undefined_link_args  sP    {{33599  <@@aAIIe[1@D@ As   A)r5   T.Optional[str]returnT.List[str])rC   strr   r   )rL   r   rM   boolr   r   rZ   r   r[   r   r   r   rb   r   r   r   r   r   rv   r   rw   r   r   r   r   r   r   r   )r   r   r   r   )r   'Environment'r[   r   r   r   r   zT.Tuple[str, ...]r   r   r   r   r   z"T.Tuple[T.List[str], T.Set[bytes]])r   r   r|   r   r   r   r   r   )r   r   r   r   )rI   )r   r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   zT.Tuple[str, str]r   r   )%__name__
__module____qualname____doc__r7   TTYPE_CHECKINGr9   __annotations__r>   r   rD   rG   rN   r^   rc   re   rh   rj   rm   ro   rs   rx   r}   r   r   r   classmethodr   r   r   r   r   r   r   r   __classcell__r   s   @r6   r1   r1   `   s9   W 	/1
,1;M%%
:=BM


;O&7OFIO(+O0RO4 | ||  2   B B8E
 #03):?J2	r8   r1   c                      e Zd ZdZdZy)DCompilerArgs)r   r   )r   N)r   r   r   prepend_prefixesdedup2_prefixesr<   r8   r6   r   r     s    #Or8   r   c                  2    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ZddZd dZd!dZd"dZ	d#dZ
d$dZd%d&dZd'dZd"dZd(dZd(dZd%d)dZddd	 	 	 	 	 d*dZddd	 	 	 	 	 d+dZddd	 	 	 	 	 d,dZddd	d	 	 	 	 	 	 	 d-dZ xZS ).	DCompilerr   z-mscrtlib=msvcrtz-mscrtlib=msvcrtdz-mscrtlib=libcmtz-mscrtlib=libcmtd)nonemdmddmtmtddNFexe_wrapperr   full_versionis_crossc          
     P    t         
|   g |||||||	       || _        || _        y )N)r   r  r  )r   r7   archr
  )r4   exelistr    for_machiner|   r  r
  r   r  r  r   s             r6   r7   zDCompiler.__init__  s8     	Wg{D&2X 	 	G	&r8   c                   t         j                  j                  |d      }t         j                  j                  |d      }t        |dd      5 }|j	                  d       d d d        t        j                  | j                  | j                  |      z   | j                         z   |gz   |      }|j                          |j                  dk7  rt        d	| j                         z        | j                  r,| j                  y | j                  j!                         |gz   }n|g}t        j"                  |      dk7  rt        d
| j                         z        y # 1 sw Y   xY w)Nzsanity.ddtestwzutf-8)encodingzvoid main() { })cwdr   z&D compiler %s cannot compile programs.z6Executables created by D compiler %s are not runnable.)rV   rL   rX   openwrite
subprocessPopenr  rD   r>   wait
returncoder	   name_stringr  r
  get_commandcall)r4   work_direnvironmentsource_nameoutput_nameofilepccmdlists           r6   sanity_checkzDCompiler.sanity_check  s9   ggll8Z8ggll8W5+sW5 	/KK-.	/dllT-A-A+-NNQUQkQkQmmq|p}}  DL  M
	==A&'ORVRbRbRd'dee=='&&224}DG"mG??7#q(&'_bfbrbrbt'tuu )	/ 	/s   EE%c                     y)NTr<   r=   s    r6   needs_static_linkerzDCompiler.needs_static_linker  s    r8   c                     yrq   r<   r=   s    r6   rs   zDCompiler.get_depfile_suffix  rt   r8   c                @    | j                   j                         rg S dgS rz   r{   r=   s    r6   r}   zDCompiler.get_pic_args  r~   r8   c                ^   g }t         | j                     d   }|st        d| j                         z        |d   r|j	                  |       d}t         | j                     d   }|st        d| j                         z        |d   D ]l  }t        |t              r	||kD  s|}t        |t              r+|j                         rt        |      |kD  sKt        |      }W|j	                  | d|        n |dk\  r|j	                  | d|        d}t         | j                     d   }	|	st        d	| j                         z        |d
   D ]l  }
t        |
t              r	|
|kD  s|
}t        |
t              r+|
j                         rt        |
      |kD  sKt        |
      }W|j	                  |	 d|
        n |dk\  r|j	                  |	 d|        t         | j                     d   }|st        d| j                         z        |d   D ]  }|j                         }|j                         D ]u  }t        j                  j                  ||      }|dvr|}n|}t        j                  j                  ||      }|j	                  | |        |j	                  | |        w  |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_incdirsrV   rL   rX   )r4   kwargsbuild_to_srcresunittest_argdebug_level	debug_argr  version_levelversion_argvimport_dir_argidir_objbasediridir
bldtreedirexpdir
srctreedirs                     r6   get_feature_argszDCompiler.get_feature_args  s   %dgg.z:&'_bfbrbrbt'tuu*JJ|$"477+G4	&'fimiyiyi{'{||  	/A!S!{?"#KAs#		q6K'"%a&K

i[!-.	/ !JJ)Ak]34$TWW-i8&'hkok{k{k}'}~~ 
# 	1A!S!}$$%MAs#		q6M)$'FM

k]!A3/0	1 AJJ+a78'0>&'psw  tD  tD  tF  (F  G  G }- 	<H))+G ,,. 	<WW\\'48
y('F$FWW\\,?


n-j\:;

n-j\:;	<	< 
r8   c                0    |dk7  r| j                         S g S r   r   r   s     r6   r   z#DCompiler.get_buildtype_linker_args   r   r8   c                    t        | |      S r;   )r   r4   r   s     r6   compiler_argszDCompiler.compiler_args%  s    T4((r8   c                *    | j                  d||      S )Nzint i;
)
extra_args)compiles)r4   r   r   s      r6   has_multi_argumentszDCompiler.has_multi_arguments(  s    }}Z}>>r8   c                d    | j                   j                         r| j                  dk(  rdgS dgS g S )Nx86_64-m64-m32r|   r   r  r=   s    r6   r>   zDCompiler._get_target_arch_args+  s3     99!yyH$x8O	r8   c                    g S r;   r<   r   s      r6   get_crt_compile_argszDCompiler.get_crt_compile_args4  rk   r8   c                    g S r;   r<   r   s      r6   get_crt_link_argszDCompiler.get_crt_link_args7  rk   r8   c                    | j                         }|ret        |      r |t        j                        }t	        |t
              r|j                  |       |S t	        |t              r|j                  |       |S r;   )	r>   callabler   COMPILEr0  listr   r   r   )r4   rK  r   s      r6   _get_compile_extra_argsz!DCompiler._get_compile_extra_args:  sf    ))+
#'(8(@(@A
*d+J'  J,J'r8   rK  dependenciesc          	         |j                  | j                        }|r!| j                  t        j                  d      | j                  |      }| j                  ||||t        j                  d      5 }|j                  dk7  rNt        j                  d|j                   d|j                   d       t        j                  d      cd d d        S |r)| j                  j                         |j                  gz   }n|j                  g}	 t!        j"                  |      \  }}	}
	 d d d        t        j                  d       t        j                  	       t        j                  d       t        j                  
       t        j                  dj                  |	|
      S # t$        $ rD}t        j                  d	| d
| d       t        j                  d      cY d }~cd d d        S d }~ww xY w# 1 sw Y   xY w)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)r4   coder   rK  r]  rb  pr%  pesosees               r6   runzDCompiler.runE  s    //0@0@A 0 0 8//0jkk11*=
  sJK[K`K`nr s 	2wx||q 

9!,,r!,,WYZ[ **51	2 	2  **668AMM?J==/2%009
B	2 	

&'

2

&'

2""4B??  2

_WIYqcEF **511	2 	22	2 	2s=   5AG48G4F$$	G1-0G,G1G4,G11G44G=c                   |g }d| d| d}| j                  ||||      }|j                  sy|j                  dk7  rt        j                  d      t        |j                        |j                  fS )N-
        import std.stdio : writeln;
        ,
        void main() {
            writeln((z).sizeof);
        }
        r\  )r,  Fr   z!Could not run sizeof test binary.)
cached_runcompiledr  r   r	   r1  stdoutcached)r4   typenamer   r   rK  r]  tr7  s           r6   sizeofzDCompiler.sizeof`  s     J		 Z  		 ooa+7  9||>>Q//0STT3::

**r8   c               R   |g }d| d| d}| j                  ||||      }|j                  st        j                  d      |j                  dk7  rt        j                  d      t        |j                        }|dk(  rt        j                  d| d	      ||j                  fS )
Nrr  rs  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.)rp  ru  r   r	   r  r1  rv  rw  )	r4   rx  r   r   rK  r]  ry  r7  aligns	            r6   	alignmentzDCompiler.alignmentt  s     J		 Z  		 hhq#*$0  2||//0STT>>Q//0VWWCJJA://2ST\S]  ^D  1E  F  Fcjj  r8   )rK  r]  disable_cachec               ~    | j                  |      }| d| d}| j                  ||||t        j                  |      S )Nz
        import z
;
        )rK  r]  r_  r~  )r[  rL  r   rY  )r4   hnamer   r   rK  r]  r~  rj  s           r6   
has_headerzDCompiler.has_header  s^    
 11*=
8 w 	 }}T3:*6=M=U=Uer  t 	tr8   r  r   r    r   r  r   r|   'MachineInfo'r  r   r
  T.Optional['ExternalProgram']r   T.Optional['DynamicLinker']r  r   r  r   )r  r   r   r   r   Noner   r   r   r   )r5  r   r6  r   r   r   r   r;   )r   zT.Optional[T.Iterable[str]]r   r   )r   r   r   r   r   T.Tuple[bool, bool]r   )rK  GT.Union[T.List[str], T.Callable[[CompileCheckMode], T.List[str]], None]r   r   )
rj  z'mesonlib.FileOrString'r   r   rK  r  r]   T.Optional[T.List['Dependency']]r   zcompilers.RunResult)rx  r   r   r   r   r   rK  zGT.Union[None, T.List[str], T.Callable[[CompileCheckMode], T.List[str]]]r]  r  r   T.Tuple[int, bool])rx  r   r   r   r   r   rK  zT.Optional[T.List[str]]r]  r  r   r  )r  r   r   r   r   r   rK  zIT.Union[None, T.List[str], T.Callable[['CompileCheckMode'], T.List[str]]]r]  r  r~  r   r   r  )r   r   r   r9   languager7   r&  r(  rs   r}   rE  r   rI  rM  r>   rT  rV  r[  rp  rz  r}  r  r   r   s   @r6   r  r    sj   !"#$!"#$J H ?C7;15"'	'$	',/	';	' 5	'  /		'
  	'v&
@D
)?	 cg=A@_@:@FY@8 fj@D+b+=+I[+* 9=CG!5! @!L^!0 lpDH).
th
t!A
t #'
t 4G
tr8   r  c                       e Zd Zej                  ZdZddddd	 	 	 	 	 	 	 	 	 	 	 ddZd fdZd fdZddZ	dd	Z
	 	 	 	 dd
ZddZd fdZddZ xZS )GnuDCompilerr"   NFr	  c                  t         j                  | |||||||||	
       t        j                  | i        ddg}
g |
|
dgz   |
ddgz   |
ddgz   | j                  t              z   d| _        dD ch c]  }t        |       c}| _        t        | j                  d      | _
        t        | j                  d	      | _        y c c}w )
Nr	  z-Wallz-Wdeprecatedz-Wextraz
-Wpedantic)r'   r)   r*   r+   
everything)
b_colorout
b_sanitizeb_staticpicb_vscrt
b_coverageb_pgob_ndebugz>=4.9z>=7.1)r  r7   r   supported_warn_argsr   	warn_argsr   base_optionsr
   r    _has_color_support_has_deps_support)r4   r  r    r  r|   r  r
  r   r  r  default_warn_argsos               r6   r7   zGnuDCompiler.__init__  s     	4';d'26(4x 	 	I 	T2&$n5!00I;>0I|3LL):i=V)V)-)A)ABY)Z*[	]#01IaL1
 #2$,,"H "1w!G1s   /C c                >    | j                   rt        | 	  |       g S r;   )r  r   get_colorout_args)r4   	colortyper   s     r6   r  zGnuDCompiler.get_colorout_args  s    ""G%i0	r8   c                @    | j                   rt        | 	  ||      S g S r;   )r  r   rx   )r4   rv   rw   r   s      r6   rx   z$GnuDCompiler.get_dependency_gen_args  s#    !!729gFF	r8   c                     | j                   |   S r;   )r  ra   s     r6   rc   zGnuDCompiler.get_warn_args  s    ~~e$$r8   c                    t         |   S r;   )r   r   s     r6   get_buildtype_argszGnuDCompiler.get_buildtype_args  s    #I..r8   c           
         t        |      D ]_  \  }}|d d dk(  s	|d d dk(  s|d d t        j                  j                  t        j                  j	                  ||dd              z   ||<   a |S )Nr   r   r   rT   rY   s        r6   r^   z3GnuDCompiler.compute_parameters_with_absolute_paths  sz    / 	_FC!u}"1&'ebgg.>.>rww||IWXYZY[W\?].^&^s#	_ r8   c                6    | j                   j                         S r;   )r   r   r=   s    r6   r   z*GnuDCompiler.get_allow_undefined_link_args  s    {{3355r8   c                d    t         |          }| j                  j                         r|S |dgz   S )Nz-shared-libphobosr   get_linker_always_argsr|   r   r4   r   r   s     r6   r  z#GnuDCompiler.get_linker_always_args  s4    w-/99!K*+++r8   c                    |rdgS g S )Nz	-freleaser<   r4   disables     r6   get_assert_argszGnuDCompiler.get_assert_args      = 	r8   r  r  r   r   r   r   r   r   r   r   r  r   r   r   )r   r   r   r   r   r   r7   r  rx   rc   r  r^   r   r  r  r   r   s   @r6   r  r    s      --M	B ?C7;15"'H$H,/H;H 5H  /	H
  H8

%/:=BM6,r8   r  c                \    | y t        j                  d|       }|r|j                  d      S y )NzDMD v(\d+\.\d+\.\d+)r   )researchgroup)version_outputversion_regexs     r6   find_ldc_dmd_frontend_versionr    s3    II5~FM""1%%r8   c                       e Zd ZdZdddddd	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZddZddZdd	Zdd
Z	ddZ
ddZedd       Zd fdZddZddZ xZS )r   r#   NF)r
  r   r  r  r  c                   t         j                  | |||||||||	
       t        j                  | t        |
             dD ch c]  }t	        |       c}| _        y c c}w )Nr	  )r5   r  r  r  r  )r  r7   r1   r  r   r  )r4   r  r    r  r|   r  r
  r   r  r  r  r  s               r6   r7   zLLVMDCompiler.__init__  sd     	4';d'26(4x 	 	I 	%%dA^_mAn%o3fgaYq\ggs   Ac                    |dk(  rdgS g S )Nalwaysz-enable-colorr<   r4   r  s     r6   r  zLLVMDCompiler.get_colorout_args  s     #$$	r8   c                &    |dv rddgS |dk(  rdgS g S )N>   r*   r+   r`   z-dwr)   r<   ra   s     r6   rc   zLLVMDCompiler.get_warn_args  s'    J5>!c\7N	r8   c                R    |dk7  r| j                         t        |   z   S t        |   S r   )r>   r   r   s     r6   r  z LLVMDCompiler.get_buildtype_args	  /    --/2Fy2QQQ#I..r8   c                    dgS )Nz-relocation-model=picr<   r=   s    r6   r}   zLLVMDCompiler.get_pic_args  s    '((r8   c                &    | j                  ||      S r;   r   r   s      r6   rV  zLLVMDCompiler.get_crt_link_args      !!'955r8   c                d    | j                  || j                  | j                  j                        S r;   r   r|   r   r   rH  s     r6   unix_args_to_nativez!LLVMDCompiler.unix_args_to_native  #    ((tyy$++..IIr8   c                    t         |   S r;   )r.   r4   optimization_levels     r6   get_optimization_argsz#LLVMDCompiler.get_optimization_args      $%788r8   c                    d| gS )Nz-linker=r<   )r   r   r    s      r6   use_linker_argszLLVMDCompiler.use_linker_args  s    6(#$$r8   c                d    t         |          }| j                  j                         r|S |dgz   S )Nz-link-defaultlib-sharedr  r  s     r6   r  z$LLVMDCompiler.get_linker_always_args  s4    w-/99!K0111r8   c                    |rdgS g S )Nz	--releaser<   r  s     r6   r  zLLVMDCompiler.get_assert_args$  r  r8   c                V    t               rt        j                  S t        j                  S r;   )r   r   MSVCGCCr=   s    r6   rsp_file_syntaxzLLVMDCompiler.rsp_file_syntax)  s     &0\}!!H}7H7HHr8   )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   r   r   r   r  r   r   r   )r   r   r    r   r   r   r  r   r   )r   r   r   r   r7   r  rc   r  r}   rV  r  r  r   r  r  r  r  r   r   s   @r6   r   r     s    	B ?C7;15"'4
h$
h,/
h;
h 5
h  /	
h
  
h
 :I
h
/
)6J9 % %2
Ir8   r   c                       e Zd ZdZddddd	 	 	 	 	 	 	 	 	 	 	 ddZddZddZddZdd	Zdd
Z	ddZ
ddZddZddZd fdZddZddZ xZS )DmdDCompilerr$   NFr	  c                   t         j                  | |||||||||	
       t        j                  | |       dD 
ch c]  }
t        |
       c}
| _        y c c}
w )Nr	  r  )r  r7   r1   r   r  )r4   r  r    r  r|   r  r
  r   r  r  r  s              r6   r7   zDmdDCompiler.__init__4  sZ     	4';d'26(4x 	 	I 	%%dG43fgaYq\ggs   Ac                    |dk(  rdgS g S )Nr  z	-color=onr<   r  s     r6   r  zDmdDCompiler.get_colorout_args@  s     = 	r8   c                R    |dk7  r| j                         t        |   z   S t        |   S r   )r>   r   r   s     r6   r  zDmdDCompiler.get_buildtype_argsE  r  r8   c                    | j                   j                         r'| j                  dk(  rdgS | j                  dk(  rdgS dgS g S )NrO  phobos64.lib
x86_mscoffphobos32mscoff.lib
phobos.librR  r=   s    r6   get_std_exe_link_argsz"DmdDCompiler.get_std_exe_link_argsJ  sK    99! yyH$&''l*,-- >!	r8   c                    d}| j                   j                         r&| j                  dk(  rd}n| j                  dk(  rd}nd}dd|z   gS )	Nzlibphobos2.sorO  r  r  r  r  z-sharedz-defaultlib=rR  )r4   libnames     r6   get_std_shared_lib_link_argsz)DmdDCompiler.get_std_shared_lib_link_argsU  sN    !99!yyH$(l*.&>G344r8   c                    | j                   j                         r'| j                  dk(  rdgS | j                  dk(  rdgS dgS g S )NrO  rP  r  z
-m32mscoffrQ  rR  r=   s    r6   r>   z"DmdDCompiler._get_target_arch_args`  sG     99!yyH$xl*$~%8O	r8   c                &    | j                  ||      S r;   r  r   s      r6   rT  z!DmdDCompiler.get_crt_compile_argsl  r  r8   c                d    | j                  || j                  | j                  j                        S r;   r  rH  s     r6   r  z DmdDCompiler.unix_args_to_nativeo  r  r8   c                    t         |   S r;   )r/   r  s     r6   r  z"DmdDCompiler.get_optimization_argsr  r  r8   c                     y)NFr<   r=   s    r6   can_linker_accept_rspz"DmdDCompiler.can_linker_accept_rspu  s    r8   c                f    t         |          }| j                  j                         r|S |ddgz   S )Nz-defaultlib=phobos2z-debuglib=phobos2r  r  s     r6   r  z#DmdDCompiler.get_linker_always_argsx  s7    w-/99!K,.ABBBr8   c                    |rdgS g S )Nz-releaser<   r  s     r6   r  zDmdDCompiler.get_assert_args~  s    <	r8   c                "    t         j                  S r;   )r   r  r=   s    r6   r  zDmdDCompiler.rsp_file_syntax  s    !!!r8   r  r  r   r   r   r  r  r  r  r  )r   r   r   r   r7   r  r  r  r  r>   rT  r  r  r  r  r  r  r   r   s   @r6   r  r  0  s    	B ?C7;15"'
h$
h,/
h;
h 5
h  /	
h
  
h
/
		5
6J9C
"r8   r  )r  r   r   r   )8
__future__r   os.pathrV   r  r  typingr   rI   r   r   arglistr   linkersr   r	   r
   r   r   r   r   r   r   r   r   r   
mixins.gnur   r   r   buildr   r]  r   programsr   	envconfigr   r   r   linkers.linkersr   r   CompilerMixinBaseobjectr%   r   r.   r/   r1   r   r  r  r  r   r  r<   r8   r6   <module>r     sy   #  	     " #    $ /??!)*')/(  !	  	  	1- , 		



3 /  		



3 / B, BJ
L 
kt ktZF;	 F\@I() @IFT"' T"r8   