o
    uJAf                     @  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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mZmZmZ dd	lmZ e
jrdd
lmZmZ ddlmZ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
j+dddZ,e
+dZ-	 h dZ.h dZ/h dZ0dddddddd d!d"d#d$d%d&d'd(Z1e12 Z3d)hZ4e5e1d* e4B Z6e5e1d+ e4B Z7h d,Z8d-hZ9e5ej:g e1; e8e9e4R  Z<e<e. Z=d.Z>d/e> Z?e@ej:d0d1 e1A D  ZBh d2ZCh d3ZDeEd4ZFd5d6d7d8d9d:d;d<d=d>d?d@ZGdAeHdB< ddGdHZIddLdMZJddOdPZKddQdRZLddSdTZMddUdVZNeddWddXdYZOddZd[ZPdd\d]ZQdd^d_ZRG d`da daejSZTg dbdcgdbddgg g g deZUdfeHdg< g dbgdbgg g g deZVdfeHdh< g g g g g g deZWdfeHdi< g g djgdjgg g deZXdfeHdk< g g dldmgdldmgg g deZYdfeHdn< g g dogdogg g deZZdfeHdp< g g dqgdqgg g deZ[dfeHdr< g g g g g g deZ\dfeHds< g dtZ]g duZ^g g g dvgdwgdxgdygdzZ_dfeHd{< g g d|gdvgdwgdxgdxgdzZ`dfeHd}< g dbgd~ZadeHd< g dbgd~ZbdeHd< g dZci ededddededddedeeddedefdddgdededddedegddedefdg ddededddededddedefdg ddededddedefdg ddedefdg ddededddededddededddedefdecddg dZhdeHd< dddZidddZjdddńZkdddʄZldddτZmG ddф deZnG ddӄ deZoG ddՄ deZpG dd deejqd׍Zrddd߄ZsdS )    )annotationsN)	lru_cache   )coredata)mlog)mesonlib)HoldableObjectEnvironmentExceptionMesonExceptionPopen_safe_loggedLibTypeTemporaryDirectoryWinProof	OptionKeyCompilerArgs)BuildTarget	DFeatures)MutableKeyedOptionDictTypeKeyedOptionDictType)MachineInfo)Environment)RSPFileSyntax)DynamicLinker)MachineChoice)
DependencyCompilerTypeCompiler)bound_T>	   ZmochhxxdivapihhippHhpp>   objores>   azdll.adyliblibjssodll)c)cppccZcxxzc++r#   r&   r$   r    inoZixxC)Zcu)Zf90Zf95Zf03Zf08fforZftnZfpp)dr!   )m)mm)Zrs)valar"   Zgs)cs)swift)java)Zpyx)asm)masm)r0   r1   cudafortranr7   objcobjcpprustr:   r;   r<   r=   cythonnasmr?   r   r1   r0   >   r>   SZsxsr?   Zll)rC   r1   rB   r0   rF   rA   )r7   r@   c                 #  s&    | ]\ } fd d|D V  qdS )c                   s   g | ]}| fqS  rI   ).0suffixlangrI   C/usr/lib/python3.10/site-packages/mesonbuild/compilers/compilers.py
<listcomp>_   s    z<genexpr>.<listcomp>NrI   )rJ   vrI   rL   rN   	<genexpr>^   s    
rQ   >   r@   r1   rB   rC   rA   r7   r0   >   r1   rB   r0   rC   z(.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$ZCFLAGSZCXXFLAGSZCUFLAGSZ	OBJCFLAGSZOBJCXXFLAGSZFFLAGSZDFLAGSZ	VALAFLAGSZ	RUSTFLAGSZCYTHONFLAGSZCSFLAGS)r0   r1   r@   rB   rC   rA   r7   r:   rD   rE   r;   zT.Mapping[str, str]CFLAGS_MAPPINGrM   strreturnintc                 C  s   | t vrdS t |  S )a"  
    Sorting function to sort the list of languages according to
    reversed(compilers.clink_langs) and append the unknown langs in the end.
    The purpose is to prefer C over C++ for files that can be compiled by
    both such as assembly, C, etc. Also applies to ObjC, ObjC++, etc.
       )clink_langsindexrL   rI   rI   rN   
sort_clinkx   s   rY   fname'mesonlib.FileOrString'boolc                 C  (   t | tjr	| j} | dd }|tv S N.)
isinstancer   FilerZ   splitheader_suffixesrZ   rK   rI   rI   rN   	is_header      rf   rK   c                 C  s   | t v S N)source_suffixes)rK   rI   rI   rN   is_source_suffix      rj   c                 C  s,   t | tjr	| j} | dd  }t|S r^   )ra   r   rb   rZ   rc   lowerrj   re   rI   rI   rN   	is_source   s   rm   c                 C  r]   r^   )ra   r   rb   rZ   rc   assembler_suffixesre   rI   rI   rN   is_assembly   rg   ro   c                 C  r]   r^   )ra   r   rb   rZ   rc   llvm_ir_suffixesre   rI   rI   rN   
is_llvm_ir   rg   rq   maxsizec                 C  s   |  dd }|tv S r^   )rc   obj_suffixesre   rI   rI   rN   cached_by_name   s   ru   c                 C  s   t | tjr	| j} t| S rh   )ra   r   rb   rZ   ru   )rZ   rI   rI   rN   	is_object   s   rv   c                 C  s6   t | tjr	| j} t| rdS | dd }|tv S )NTr_   r`   )ra   r   rb   rZ   soregexmatchrc   lib_suffixesre   rI   rI   rN   
is_library   s   
rz   c                 C  r]   r^   )ra   r   rb   rZ   rc   all_suffixesre   rI   rI   rN   is_known_suffix   s   r|   c                   @  s   e Zd ZdZdZdZdS )CompileCheckModeZ
preprocesscompilelinkN)__name__
__module____qualname__
PREPROCESSCOMPILELINKrI   rI   rI   rN   r}      s    r}   z-gz-Gz	-lineinfo)plaindebugdebugoptimizedreleaseminsizecustomT.Dict[str, T.List[str]]cuda_buildtype_argsjava_buildtype_argsrust_buildtype_argsz-finline-functionsd_gdc_buildtype_argsz-enable-inliningz-Hkeep-all-bodiesd_ldc_buildtype_argsz-inlined_dmd_buildtype_argsz
-optimize+mono_buildtype_argsswift_buildtype_args)
z
-lkernel32z-luser32z-lgdi32z
-lwinspoolz	-lshell32z-lole32z
-loleaut32z-luuidz
-lcomdlg32z
-ladvapi32)
zkernel32.libz
user32.libz	gdi32.libzwinspool.libzshell32.libz	ole32.libzoleaut32.libzuuid.libzcomdlg32.libzadvapi32.libz-O1z-O2z-O3z-Os)r   0g123rH   clike_optimization_argsz-O0cuda_optimization_args)FTzT.Dict[bool, T.List[str]]cuda_debug_argsclike_debug_args)nonemdmddmtmtdZb_pchzUse precompiled headersTb_ltozUse link time optimizationFb_lto_threadsz/Use multiple threads for Link Time Optimization)NNr   
b_lto_modez#Select between different LTO modes.defaultZthinb_thinlto_cachez6Use LLVM ThinLTO caching for faster incremental buildsb_thinlto_cache_dirz(Directory to store ThinLTO cache objects 
b_sanitizezCode sanitizer to use)r   addressthread	undefinedZmemoryZleakzaddress,undefinedr   b_lundefz#Use -Wl,--no-undefined when linking
b_asneededz Use -Wl,--as-needed when linkingb_pgozUse profile guided optimization)offgenerateuser   
b_coveragezEnable coverage tracking.
b_coloroutzUse colored output)autoalwaysneverr   b_ndebugzDisable asserts)truefalse
if-releaser   b_staticpicz.Build static libraries as position independentb_piez)Build executables as position independent	b_bitcodez0Generate and embed bitcode (only macOS/iOS/tvOS)b_vscrtz VS run-time library type to use.from_buildtypestatic_from_buildtype'KeyedOptionDictType'base_optionsboptionsT.Set[OptionKey]optionsoptionr   c                 C  sF   z|| vrW dS || j }t|tsJ d|W S  ty"   Y dS w )NFzmust return bool)valuera   r\   KeyError)r   r   r   retrI   rI   rN   option_enabledN  s   
r   optfallback'_T'c                 C  sT   z| | j }W n ty   | Y S w t|t|s(J dt|dt||S )z2Get the value of an option, or the fallback value.zShould have z	 but was )r   r   ra   type)r   r   r   rP   rI   rI   rN   get_option_valueZ  s   *r   r   c                 C  s6   | t d jdkp| t d jdko| t d jdv S )zShould debug assertions be disabled

    :param options: OptionDictionary
    :return: whether to disable assertions or not
    r   r   r   	buildtype>   r   r   )r   r   )r   rI   rI   rN   are_asserts_disabledf  s   r   compiler
'Compiler'T.List[str]c                 C  s  g }z| t d jr ||jt| t ddt| t ddd W n	 ty*   Y nw z||| t d j7 }W n	 tyB   Y nw z||| t d j7 }W n	 tyZ   Y nw z | t d	 j}|d
kro||  n|dkrz||	  W n	 ty   Y nw z| t d jr||
 7 }W n	 ty   Y nw z||t| 7 }W n	 ty   Y nw t|j| t dr|d z&| t d j}| t d j}z||||7 }W W |S  ty   Y W |S w  ty   Y |S w )Nr   r   r   r   r   threadsmoder   r   r   r   r   r   r   z-fembed-bitcoder   r   )r   r   extendget_lto_compile_argsr   r   get_colorout_argssanitizer_compile_argsget_profile_generate_argsget_profile_use_argsget_coverage_argsget_assert_argsr   r   r   appendget_crt_compile_argsAttributeError)r   r   argspgo_valcrt_valr   rI   rI   rN   get_base_compile_argsq  sv   
r   linkeris_shared_module	build_dirc                 C  sD  g }z>| t d jr?d }t| t ddr(t| t dd}|dkr(tj|dd}||jt| t dd	t| t d
d|d W n	 tyI   Y nw z||	| t d j7 }W n	 tya   Y nw z | t d j}|dkrv||
  n|dkr||  W n	 ty   Y nw z| t d jr|| 7 }W n	 ty   Y nw t|j| t d}t|j| t d}|r|s||  n	|r||  |s||  |st|j| t dr||  n||  z'| t d j}	| t d j}
z|||	|
7 }W W |S  ty   Y W |S w  ty!   Y |S w )Nr   r   Fr   r   zmeson-privatezthinlto-cacher   r   r   r   r   r   thinlto_cache_dirr   r   r   r   r   r   r   r   r   r   )r   r   r   ospathjoinr   get_lto_link_argsr   sanitizer_link_argsr   r   get_coverage_link_argsr   r   bitcode_argsget_asneeded_argsheaderpad_argsno_undefined_link_argsget_allow_undefined_link_argsget_crt_link_argsr   )r   r   r   r   r   r   r   Z	as_neededZbitcoder   r   rI   rI   rN   get_base_link_args  s   r   c                   @  s   e Zd ZdS )CrossNoRunExceptionN)r   r   r   rI   rI   rI   rN   r     s    r   c                   @  s   e Zd Z			ddddZdS )	RunResult  	UNDEFINEDFcompiledr\   
returncoderU   stdoutrS   stderrcachedc                 C  s"   || _ || _|| _|| _|| _d S rh   )r   r   r  r  r  )selfr   r   r  r  r  rI   rI   rN   __init__  s
   
zRunResult.__init__N)r   r   r   F)
r   r\   r   rU   r  rS   r  rS   r  r\   )r   r   r   r  rI   rI   rI   rN   r     s
    r   c                   @  s(   e Zd ZdZ						ddddZdS )CompileResultz.The result of Compiler.compiles (and friends).Nr   FstdoT.Optional[str]stdecommandT.Optional[T.List[str]]r   rU   
input_nameoutput_namer  r\   c                 C  s2   || _ || _|| _|| _|pg | _|| _|| _d S rh   )r  r  r  r  r
  r  r   )r  r  r	  r
  r   r  r  r  rI   rI   rN   r    s   

zCompileResult.__init__)NNNr   NNF)r  r  r	  r  r
  r  r   rU   r  r  r  r  r  r\   )r   r   r   __doc__r  rI   rI   rI   rN   r    s    r  c                   @  s@	  e Zd ZU g Zded< g Zded< dZded< dZded	< ded
< ded< dZ		ddddZ	ddd Z
edd!dd$d%Zdd&d'Zdd)d*Zdd+d,Zdd-d.Zdd/d0Zedd1d2Zdd3d4Z	ddd?d@ZddIdJZddMdNZdddOddSdTZddUddVdWZddXdYZdɐddZd[Zdd\d]Zejdd_d`ZddadbZ ddddeZ!ddgdhZ"ddidjZ#ddkdlZ$ddmdnZ%ddodpZ&ddqdrZ'ddtduZ(ddwdxZ)dd{d|Z*dd}d~Z+dddOdddZ,dddddddZ-dddOdddZ.dddOdddZ/dddOdddZ0dddOdddZ1dddOdddZ2dddOdddZ3edddZ4dddZ5edddZ6e7j8dfdddZ9	ddddZ:dddZ;dddZ<dddZ=dddZ>dddZ?ddddZ@eAjB	deCjDddddddZEeAjBdeCjDdddddǄZFdddʄZGdddd΄ZHdddфZIdddӄZJdddՄZKdddׄZLdddلZMdddۄZNddd݄ZOdddZPdddZQdddZRdddZSdddZTdddZUdddZVdddZWdddZXdddZYdddZZdd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ZadݐddZbddddddZcdddddddZddddZedddZfdːddZgdːdd Zhdːd!d"Zidd$d%Zjdd&d'Zkdd-d.Zldd1d2Zmdd5d6Zndd7d8Zoedd9d:Zpdːd;d<Zqdːd=d>Zrdd@dAZsddCdDZtddEdFZuddGdHZvdːdIdJZwdːdKdLZxdːdMdNZydːdOdPZzdːdQdRZ{	dddTdUZ|ddYdZZ}	dɐdd\d]Z~dd^d_Zdd`daZddbdcZddddeZd dhdiZddjdkZddldmZejddqdrZddtduZddxdyZdːdz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ZejdddZd	ddZd
ddZdddZdddZdːddZeCjfdddZeAjBddeCjddfdddZddeCjdddddZddddd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ZdS (  r   r   ignore_libsinternal_libsNzT.Union[None, str, T.List[str]]LINKER_PREFIXTrS   languageidr   Z	warn_argsCOMPILERFccacheexelistversionfor_machiner   info'MachineInfo'r   T.Optional['DynamicLinker']full_versionr  is_crossr\   c	           	      C  s~   || | _ || _t| dst| j | _t| dst| j| _| jd | _|| _	|| _
|| _t | _|| _|| _|| _g | _d S )Nfile_suffixescan_compile_suffixesr   )r  exelist_no_ccachehasattrlang_suffixesr  r  setr  default_suffixr  r  r  r   r   r  r  modes)	r  r  r  r  r  r  r   r  r  rI   rI   rN   r    s   



zCompiler.__init__rT   c                 C  s    d}| | jj| jd| jS )Nz<{0}: v{1} `{2}`> )format	__class__r   r  r   r  )r  repr_strrI   rI   rN   __repr__)  s   
zCompiler.__repr__rr   srcr[   c                 C  sL   t |tjr	|j}tj|d }|dkr| }t|o%|dd  | j	v S )NrV   z.C)
ra   r   rb   rZ   r   r   splitextrl   r\   r  )r  r+  rK   rI   rI   rN   can_compile.  s   zCompiler.can_compilec                 C     | j S rh   )r  r  rI   rI   rN   get_id7     zCompiler.get_idT.List[Compiler]c                 C  r.  rh   )r%  r/  rI   rI   rN   	get_modes:  r1  zCompiler.get_modesc                 C  s$   z| j jW S  ty   | j Y S w rh   )r   r  r   r/  rI   rI   rN   get_linker_id=  s
   

zCompiler.get_linker_idc                 C  s0   | j | jg}| jr|d| j g7 }dd| S )Nz"%s"z(%s)r&  )r  r  r  r   )r  detailsrI   rI   rN   get_version_stringF  s   zCompiler.get_version_stringc                 C  r.  rh   )r  r/  rI   rI   rN   get_languageL  r1  zCompiler.get_languagec                 C  
   | j  S rh   )r  
capitalize)clsrI   rI   rN   get_display_languageO     
zCompiler.get_display_languagec                 C  r.  rh   )r$  r/  rI   rI   rN   get_default_suffixS  r1  zCompiler.get_default_suffixdnameprefixenv'Environment'
extra_argsAT.Union[T.List[str], T.Callable[[CompileCheckMode], T.List[str]]]dependenciesT.List['Dependency']disable_cacheT.Tuple[str, bool]c                 C     t d|   )Nz%s does not support get_define r	   r0  )r  r>  r?  r@  rB  rD  rF  rI   rI   rN   
get_defineV     zCompiler.get_define
expressionlowT.Optional[int]highguessGT.Union[None, T.List[str], T.Callable[[CompileCheckMode], T.List[str]]] T.Optional[T.List['Dependency']]rU   c          	      C  rH  )Nz %s does not support compute_int rI  )	r  rL  rM  rO  rP  r?  r@  rB  rD  rI   rI   rN   compute_int\  rK  zCompiler.compute_intparameter_listr   c                 C  rH  )Nz;%s does not support compute_parameters_with_absolute_paths rI  )r  rT  r   rI   rI   rN   &compute_parameters_with_absolute_pathsb  s   z/Compiler.compute_parameters_with_absolute_pathsrB  rD  typenamemembernamesT.Tuple[bool, bool]c                C  rH  )Nz"%s does not support has_member(s) rI  )r  rW  rX  r?  r@  rB  rD  rI   rI   rN   has_membersf  rK  zCompiler.has_members)rD  c                C  rH  )Nz%s does not support has_type rI  r  rW  r?  r@  rB  rD  rI   rI   rN   has_typel     zCompiler.has_typec                 C  rH  )Nz3%s does not support symbols_have_underscore_prefix rI  r  r@  rI   rI   rN   symbols_have_underscore_prefixq     z'Compiler.symbols_have_underscore_prefixc                 C  s   |r| j  S | j S rh   )r  copyr   )r  r  rI   rI   rN   get_exelistt     zCompiler.get_exelistc                 C  s   | j r| j  S |  S rh   )r   rb  r/  rI   rI   rN   get_linker_exelistw  rc  zCompiler.get_linker_exelist
outputnamec                 C     d S rh   rI   r  re  rI   rI   rN   get_output_argsz     zCompiler.get_output_argsc                 C     | j |S rh   )r   rh  rg  rI   rI   rN   get_linker_output_args~     zCompiler.get_linker_output_argsdirnamec                 C  rj  rh   )r   Zget_search_args)r  rm  rI   rI   rN   get_linker_search_args  rl  zCompiler.get_linker_search_argsdefinec                 C     t d| j )Nz'%s does not support get_builtin_define.r	   r  r  ro  rI   rI   rN   get_builtin_define     zCompiler.get_builtin_definec                 C  rp  )Nz'%s does not support has_builtin_define.rq  rr  rI   rI   rN   has_builtin_define  rt  zCompiler.has_builtin_definec                 C     g S rh   rI   r/  rI   rI   rN   get_always_args     zCompiler.get_always_argsc                 C  r8  )z[
        Determines whether the linker can accept arguments using the @rsp syntax.
        )r   Zget_accepts_rspr/  rI   rI   rN   can_linker_accept_rsp  s   
zCompiler.can_linker_accept_rspc                 C  r8  rh   )r   rw  r/  rI   rI   rN   get_linker_always_args     
zCompiler.get_linker_always_argsc                 C  r8  rh   )r   Zget_lib_prefixr/  rI   rI   rN   get_linker_lib_prefix  r{  zCompiler.get_linker_lib_prefix
implibnamec                 C  rv  )z
        Used only on Windows for libraries that need an import library.
        This currently means C, C++, Fortran.
        rI   )r  r}  rI   rI   rN   gen_import_library_args  s   z Compiler.gen_import_library_args'MutableKeyedOptionDictType'c                 C  s   i S rh   rI   r/  rI   rI   rN   get_options  rx  zCompiler.get_optionsr   r   c                 C  rv  rh   rI   r  r   rI   rI   rN   get_option_compile_args  rx  z Compiler.get_option_compile_argsc                 C  rj  rh   )r   Zget_option_argsr  rI   rI   rN   get_option_link_args  rl  zCompiler.get_option_link_argshnamec                C  rH  )zCheck that header is usable.

        Returns a two item tuple of bools. The first bool is whether the
        check succeeded, the second is whether the result was cached (True)
        or run fresh (False).
        +Language %s does not support header checks.r	   r;  )r  r  r?  r@  rB  rD  rI   rI   rN   check_header     	zCompiler.check_header)rB  rD  rF  c                C  rH  )a  Check that header is exists.

        This check will return true if the file exists, even if it contains:

        ```c
        # error "You thought you could use this, LOLZ!"
        ```

        Use check_header if your header only works in some cases.

        Returns a two item tuple of bools. The first bool is whether the
        check succeeded, the second is whether the result was cached (True)
        or run fresh (False).
        r  r  )r  r  r?  r@  rB  rD  rF  rI   rI   rN   
has_header  s   zCompiler.has_headersymbolc                C  rH  )Nz2Language %s does not support header symbol checks.r  )r  r  r  r?  r@  rB  rD  rI   rI   rN   has_header_symbol  rK  zCompiler.has_header_symbolcodeGT.Union[T.List[str], T.Callable[[CompileCheckMode], T.List[str]], None]r   c                C  rH  )Nz(Language %s does not support run checks.r  )r  r  r@  rB  rD  rI   rI   rN   run  r]  zCompiler.runc          	      C  s   |j j}| |||td}|t|f}||v rG|| }d|_td td| td| td|j td|j	 td|j
 |S | j||||d	}|||< |S )
Nr   TzUsing cached run result:Code:
zArgs:
zCached run returncode:
zCached run stdout:
zCached run stderr:
rV  )r   run_check_cachebuild_wrapper_argsr}   tupler  r   r   r   r  r  r  )	r  r  r@  rB  rD  r  r   keyprI   rI   rN   
cached_run  s    
zCompiler.cached_runT.Tuple[int, bool]c                C  rH  )Nz+Language %s does not support sizeof checks.r  r[  rI   rI   rN   sizeof  r]  zCompiler.sizeofr  c                C  rH  )Nz.Language %s does not support alignment checks.r  r[  rI   rI   rN   	alignment  r]  zCompiler.alignmentfuncnamec                C  rH  )zSee if a function exists.

        Returns a two item tuple of bools. The first bool is whether the
        check succeeded, the second is whether the result was cached (True)
        or run fresh (False).
        z-Language %s does not support function checks.r  )r  r  r?  r@  rB  rD  rI   rI   rN   has_function  r  zCompiler.has_functionr   r   c                 C     |  S z7Always returns a copy that can be independently mutatedra  )r:  r   r  rI   rI   rN   _unix_args_to_native     zCompiler._unix_args_to_nativec                 C  s   |  || jS rh   )r  r  r  r   rI   rI   rN   unix_args_to_native  rt  zCompiler.unix_args_to_nativec                 C  r  r  r  )r:  r   rI   rI   rN   native_args_to_unix
  r  zCompiler.native_args_to_unixlibname
extra_dirslibtyper   lib_prefix_warningc                 C     t d|   d)N	Language z" does not support library finding.r  )r  r  r@  r  r  r  rI   rI   rN   find_library  s   zCompiler.find_librarystrictT.Optional[T.Tuple[str, ...]]c                 C     t d|  )Nz0Language {} does not support get_library_naming.r	   r'  r;  )r  r@  r  r  rI   rI   rN   get_library_naming  s
   zCompiler.get_library_namingc                 C  rv  rh   rI   r^  rI   rI   rN   get_program_dirs  rx  zCompiler.get_program_dirsc                 C  r  )Nz1Language {} does not support has_multi_arguments.r  r  r   r@  rI   rI   rN   has_multi_arguments  s
   zCompiler.has_multi_argumentsc                 C  s   | j ||S rh   )r   r  r  rI   rI   rN   has_multi_link_arguments!  rt  z!Compiler.has_multi_link_argumentsr   r}   c                 C  s8   |t jks	J d|t jkrd}nd}tj|d| S )NAIn pre-processor mode, the output is sent to stdout and discardedexer'   zoutput.)r}   r   r   r   r   r   )r  rm  r   rK   rI   rI   rN   _get_compile_output$  s
   
zCompiler._get_compile_outputc                 C  sV   g }||   7 }|tju r||  7 }|S |tju r"||  7 }|S |tju s)J |S rh   )rw  r}   r   get_compile_only_argsr   get_preprocess_only_argsr   )r  r   r   rI   rI   rN   get_compiler_args_for_mode.  s   

z#Compiler.get_compiler_args_for_modeT.Optional[T.Iterable[str]]r   c                 C  s
   t | |S )z;Return an appropriate CompilerArgs instance for this class.r   r  rI   rI   rN   compiler_args9  r<  zCompiler.compiler_args)r   want_outputtemp_dir(T.Union[None, CompilerArgs, T.List[str]]r  r  %T.Iterator[T.Optional[CompileResult]]c             	   c  s   |t jkr|rJ d|d u rg }t|d}d}t|trJtj|d| j }t	|ddd}	|	
| W d    n1 s@w   Y  d}|}
n&|j}t|jsnt	|jdd}| }
W d    n1 shw   Y  nd	}
|  }|| |t jkr| ||}|| |7 }|| t | |r||7 }| j| d
|  }td td| td|
 tj }d|d< |rd|d< t|d||d\}}}t||||j|d}|r||_|V  W d    d S 1 sw   Y  d S )Nr  )dirFz	testfile.wzutf-8)encodingTz<binary>)r  zRunning compile:zWorking directory: r  r4   LC_ALLr   ZCCACHE_DISABLEzCommand line)msgcwdr@  )r  )r}   r   r   ra   rS   r   r   r   r$  openwriterZ   rv   readr  r   r  rh  r   r  rb  Z	to_nativer   r   environra  r   r  r   r  )r  r  rB  r   r  r  Z
tmpdirnameZ	no_ccachesrcnameofilecontentsr5   commandsoutputZcommand_listZos_envr  r  r	  resultrI   rI   rN   r~   =  sZ   







"zCompiler.compilerB  r   r  cdatacoredata.CoreData(T.Union[None, T.List[str], CompilerArgs]c          	      c  s    |d ur	t |nt  }t | j| j|||f}||jv rM|j| }d|_td tdd|jd td| td|j	 td|j
 |V  d S | j|||d	|d
}||j|< |V  W d    d S 1 skw   Y  d S )NTzUsing cached compile:zCached command line: r&  
r  zCached compiler stdout:
zCached compiler stderr:
FrB  r   r  r  )r  r  r  compiler_check_cacher  r   r   r   r
  r  r  r~   )	r  r  r  rB  r   r  Ztextra_argsr  r  rI   rI   rN   cached_compile{  s    




"zCompiler.cached_compile	colortypec                 C  rv  rh   rI   )r  r  rI   rI   rN   r     ri  zCompiler.get_colorout_argsrel_objpchc                 C  rv  rh   rI   )r  r  r  rI   rI   rN   get_compile_debugfile_args  rx  z#Compiler.get_compile_debugfile_args
targetfilec                 C  rj  rh   )r   Zget_debugfile_namer  r  rI   rI   rN   get_link_debugfile_name  rl  z Compiler.get_link_debugfile_namec                 C  rj  rh   )r   Zget_debugfile_argsr  rI   rI   rN   get_link_debugfile_args  rl  z Compiler.get_link_debugfile_argsc                 C  r8  rh   )r   Zget_std_shared_lib_argsr/  rI   rI   rN   get_std_shared_lib_link_args  r{  z%Compiler.get_std_shared_lib_link_argsc                 C  rj  rh   )r   Zget_std_shared_module_argsr  rI   rI   rN   get_std_shared_module_link_args  rl  z(Compiler.get_std_shared_module_link_argsc                 C  rj  rh   )r   get_link_whole_forr  rI   rI   rN   r    rl  zCompiler.get_link_whole_forc                 C  r8  rh   )r   Zget_allow_undefined_argsr/  rI   rI   rN   r     r{  z&Compiler.get_allow_undefined_link_argsc                 C  r8  rh   )r   Zno_undefined_argsr/  rI   rI   rN   r     r{  zCompiler.no_undefined_link_argsinstruction_setc                 C     dS )zCompiler arguments needed to enable the given instruction set.

        Return type ay be an empty list meaning nothing needed or None
        meaning the given set is not supported.
        NrI   )r  r  rI   rI   rN   get_instruction_set_args     z!Compiler.get_instruction_set_argsfrom_dirrpath_pathsT.Tuple[str, ...]build_rpathinstall_rpath"T.Tuple[T.List[str], T.Set[bytes]]c                 C     | j ||||||S rh   )r   build_rpath_args)r  r@  r   r  r  r  r  rI   rI   rN   r    s   zCompiler.build_rpath_argsfilenamec                 C  rj  rh   )r   get_archive_name)r  r  rI   rI   rN   r    rl  zCompiler.get_archive_namec                 C  s   | j sg S | j  S rh   )r   get_command_to_archive_shlibr/  rI   rI   rN   r    s   
z%Compiler.get_command_to_archive_shlibc                 C  rv  rh   rI   r^  rI   rI   rN   thread_flags  rx  zCompiler.thread_flagsc                 C  rj  rh   )r   r  r^  rI   rI   rN   thread_link_flags  rl  zCompiler.thread_link_flagsc                 C  rH  )Nz*Language %s does not support OpenMP flags.r  r/  rI   rI   rN   openmp_flags  r`  zCompiler.openmp_flagsc                 C     |   S rh   )r  r/  rI   rI   rN   openmp_link_flags  rk   zCompiler.openmp_link_flagsc                 C  rv  rh   rI   r^  rI   rI   rN   language_stdlib_only_link_flags  rx  z(Compiler.language_stdlib_only_link_flagsvistypec                 C  rv  rh   rI   )r  r  rI   rI   rN   gnu_symbol_visibility_args  rx  z#Compiler.gnu_symbol_visibility_argsr   c                 C  rj  rh   )r   get_win_subsystem_argsr  r   rI   rI   rN   r    s   zCompiler.get_win_subsystem_argsnamec                 C  r  )Nr  z& does not support function attributes.r  )r  r  r@  rI   rI   rN   has_func_attribute  s   zCompiler.has_func_attributec                 C     d}t ||  )Nz6Language {} does not support position-independent coder  r  r8   rI   rI   rN   get_pic_args     zCompiler.get_pic_argsc                 C  r  )Nz<Language {} does not support position-independent executabler  r  rI   rI   rN   get_pie_args  r   zCompiler.get_pie_argsc                 C  r8  rh   )r   r  r/  rI   rI   rN   get_pie_link_args  r{  zCompiler.get_pie_link_argsc                 C  r  )as  Returns the argument family type.

        Compilers fall into families if they try to emulate the command line
        interface of another compiler. For example, clang is in the GCC family
        since it accepts most of the same arguments as GCC. ICL (ICC on
        windows) is in the MSVC family since it accepts most of the same
        arguments as MSVC.
        otherrI   r/  rI   rI   rN   get_argument_syntax  s   	zCompiler.get_argument_syntaxc                 C  rH  )Nz.%s does not support get_profile_generate_args rI  r/  rI   rI   rN   r        
z"Compiler.get_profile_generate_argsc                 C  rH  )Nz)%s does not support get_profile_use_args rI  r/  rI   rI   rN   r     r  zCompiler.get_profile_use_argsc                 C  s`   d}d}d}g }t |}|D ]}||v rq||r||vrq||v r(t| q|| q|S )N)z-headerpad_max_install_names)z-Wl,-L)r  z
-framework)iter
startswithnextr   )r  r   Zrm_exactZrm_prefixesZrm_nextr   ZiargsargrI   rI   rN   remove_linkerlike_args  s   zCompiler.remove_linkerlike_argsr   r   r   r   c                C  rv  rh   rI   )r  r   r   rI   rI   rN   r     rx  zCompiler.get_lto_compile_argsr   r   c                C  r8  rh   )r   Zget_lto_args)r  r   r   r   rI   rI   rN   r     r<  zCompiler.get_lto_link_argsc                 C  rv  rh   rI   r  rI   rI   rN   r     rx  zCompiler.sanitizer_compile_argsc                 C  rj  rh   )r   Zsanitizer_argsr  rI   rI   rN   r   "  rl  zCompiler.sanitizer_link_argsc                 C  r8  rh   )r   r   r/  rI   rI   rN   r   %  r{  zCompiler.get_asneeded_argsc                 C  r8  rh   )r   r   r/  rI   rI   rN   r   (  r{  zCompiler.headerpad_argsc                 C  r8  rh   )r   r   r/  rI   rI   rN   r   +  r{  zCompiler.bitcode_argsr   c                 C     t | j d)Nz& does not implement get_buildtype_argsrq  r  r   rI   rI   rN   get_buildtype_args.  r`  zCompiler.get_buildtype_argsc                 C  rj  rh   )r   r  r  rI   rI   rN   get_buildtype_linker_args1  rl  z"Compiler.get_buildtype_linker_args
shlib_namerK   	soversiondarwin_versionsT.Tuple[str, str]c                 C  r  rh   )r   get_soname_args)r  r@  r?  r  rK   r  r  rI   rI   rN   r  4  s   
zCompiler.get_soname_argstarget'BuildTarget'c                 C  s   |j S rh   )	link_args)r  r  rI   rI   rN   get_target_link_args;  r1  zCompiler.get_target_link_argsdep'Dependency'c                 C  r  rh   )get_compile_argsr  r  rI   rI   rN   get_dependency_compile_args>  rk   z$Compiler.get_dependency_compile_argsc                 C  r  rh   )get_link_argsr  rI   rI   rN   get_dependency_link_argsA  rk   z!Compiler.get_dependency_link_argsc                 C  rv  )zKGet a list of arguments to pass to the compiler to set the linker.
        rI   )r:  r   r  rI   rI   rN   use_linker_argsD  s   zCompiler.use_linker_argsc                 C  rv  rh   rI   r/  rI   rI   rN   r   J  rx  zCompiler.get_coverage_argsc                 C  r8  rh   )r   r   r/  rI   rI   rN   r   M  r{  zCompiler.get_coverage_link_argsdisablec                 C  rv  )zGet arguments to enable or disable assertion.

        :param disable: Whether to disable assertions
        :return: A list of string arguments for this compiler
        rI   )r  r!  rI   rI   rN   r   P  r  zCompiler.get_assert_argsr   c                 C  sh   |t v r|S |dv sJ d}d}|dkrd}d}|dkrdS |d	kr$|S |d
v r*|S |dks0J td)N>   r   r   r   r   r   r   r   r   r   r   >   r   r   r   r   zBRequested C runtime based on buildtype, but buildtype is "custom".)
MSCRT_VALSr	   )r  r   r   ZdbgrelrI   rI   rN   get_crt_valX  s    zCompiler.get_crt_valc                 C     t dNz4This compiler does not support Windows CRT selectionr	   r  r   r   rI   rI   rN   r   n  rk   zCompiler.get_crt_compile_argsc                 C  r%  r&  r'  r(  rI   rI   rN   r   q  rk   zCompiler.get_crt_link_argsc                 C  rv  rh   rI   r/  rI   rI   rN   r  t  rx  zCompiler.get_compile_only_argsc                 C  r%  )Nz*This compiler does not have a preprocessorr'  r/  rI   rI   rN   r  w  rk   z!Compiler.get_preprocess_only_argsc                 C  r  rh   )r  r/  rI   rI   rN   get_preprocess_to_file_argsz  rk   z$Compiler.get_preprocess_to_file_argsc                 C  rv  rh   rI   r/  rI   rI   rN   get_default_include_dirs}  ri  z!Compiler.get_default_include_dirsc                 C  s    |   dks| j sdgS g S )z=Enable transparent large-file-support for 32-bit UNIX systemsZmsvcz-D_FILE_OFFSET_BITS=64)r  r  	is_darwinr/  rI   rI   rN   get_largefile_args  s   zCompiler.get_largefile_args	elf_classc                 C  rv  rh   rI   )r  r@  r-  rI   rI   rN   get_library_dirs  ri  zCompiler.get_library_dirsrZ   rtypeT.Union[str, int]c                 C  r  )Nz" does not support get_return_valuerq  )r  rZ   r/  r?  r@  rB  rD  rI   rI   rN   get_return_value  s   zCompiler.get_return_valueallow_systemc                 C  r  )Nz  does not support find_frameworkrq  )r  r  r@  r  r2  rI   rI   rN   find_framework  s   zCompiler.find_frameworkc                 C  r  )Nz& does not support find_framework_pathsrq  r^  rI   rI   rN   find_framework_paths  r`  zCompiler.find_framework_pathsc                 C  r  )Nz" does not support attribute checksrq  r  r  rI   rI   rN   attribute_check_func  r`  zCompiler.attribute_check_funcc                 C  r  Nz& does not support pre compiled headersrq  r/  rI   rI   rN   get_pch_suffix  r`  zCompiler.get_pch_suffixc                 C  r  r7  rq  r5  rI   rI   rN   get_pch_name  r`  zCompiler.get_pch_namepch_dirheaderc                 C  r  r7  rq  )r  r:  r;  rI   rI   rN   get_pch_use_args  r`  zCompiler.get_pch_use_argsc                 C  r  )Nz% does not support function attributesrq  r5  rI   rI   rN   !get_has_func_attribute_extra_args  r`  z*Compiler.get_has_func_attribute_extra_argsc                 C  s   d | jS )Nr&  )r   r  r/  rI   rI   rN   name_string  rl  zCompiler.name_stringwork_direnvironmentNonec                 C  r  )zCheck that this compiler actually works.

        This should provide a simple compile/link test. Something as simple as:
        ```python
        main(): return 0
        ```
        is good enough here.
        NrI   )r  r?  r@  rI   rI   rN   sanity_check  s    zCompiler.sanity_checkT.Tuple[T.Optional[str], str]c                 C  s   d |fS rh   rI   )r  rZ   rI   rI   rN   split_shlib_to_parts  rk   zCompiler.split_shlib_to_parts	outtargetoutfilec                 C  rv  rh   rI   )r  rE  rF  rI   rI   rN   get_dependency_gen_args  rx  z Compiler.get_dependency_gen_argsc                 C  rv  rh   rI   r/  rI   rI   rN   get_std_exe_link_args  ri  zCompiler.get_std_exe_link_argsr   	is_systemc                 C  rv  rh   rI   )r  r   rI  rI   rI   rN   get_include_args  rx  zCompiler.get_include_argsobjfilec                 C  s   |d |    S )Nr_   )get_depfile_suffix)r  rK  rI   rI   rN   depfile_for_object  r`  zCompiler.depfile_for_objectc                 C  r  )Nz& does not implement get_depfile_suffixrq  r/  rI   rI   rN   rL    r`  zCompiler.get_depfile_suffixc                 C  rv  )z>Arguments to turn off default inclusion of standard libraries.rI   r/  rI   rI   rN   get_no_stdinc_args  ri  zCompiler.get_no_stdinc_argslevelc                 C  rv  rh   rI   )r  rO  rI   rI   rN   get_warn_args  rx  zCompiler.get_warn_argsc                 C  rv  rh   rI   r/  rI   rI   rN   get_werror_args  rx  zCompiler.get_werror_argsoptimization_levelc                 C  rf  rh   rI   )r  rR  rI   rI   rN   get_optimization_args  ri  zCompiler.get_optimization_argsc                 C  r  )Nz* does not implement get_module_incdir_argsrq  r/  rI   rI   rN   get_module_incdir_args  r`  zCompiler.get_module_incdir_argsc                 C  r  )Nz* does not implement get_module_outdir_argsrq  )r  r   rI   rI   rN   get_module_outdir_args  r`  zCompiler.get_module_outdir_argsmodule_namec                 C  r  )Nz+ does not implement module_name_to_filenamerq  )r  rV  rI   rI   rN   module_name_to_filename  r`  z Compiler.module_name_to_filenamec                 C  r  )aL  Arguments to pass the compiler and/or linker for checks.

        The default implementation turns off optimizations.

        Examples of things that go here:
          - extra arguments for error checking
          - Arguments required to make the compiler exit with a non-zero status
            when something is wrong.
        )get_no_optimization_args)r  r   rI   rI   rN   get_compiler_check_args  s   
z Compiler.get_compiler_check_argsc                 C  rv  )z8Arguments to the compiler to turn off all optimizations.rI   r/  rI   rI   rN   rX    ri  z!Compiler.get_no_optimization_argsUT.Union[None, CompilerArgs, T.List[str], T.Callable[[CompileCheckMode], T.List[str]]]c                 C  s   t |r||}|du rg }|du rg }| | |}|D ]}|| 7 }|tju r1|| 7 }q|tju rC||j	| j
| j7 }n|tju rS||j| j
| j7 }||7 }|S )ab  Arguments to pass the build_wrapper helper.

        This generally needs to be set on a per-language basis. It provides
        a hook for languages to handle dependencies and extra args. The base
        implementation handles the most common cases, namely adding the
        check_arguments, unwrapping dependencies, and appending extra args.
        N)callabler  rY  r  r}   r   r  r   r   get_external_argsr  r  get_external_link_args)r  r@  rB  rD  r   r   r7   rI   rI   rN   r    s$   


zCompiler.build_wrapper_argsc           
      c  s    |  ||||}|s|r.| j|||||jd}	|	V  W d   dS 1 s'w   Y  dS | j||j|||jd}	|	V  W d   dS 1 sIw   Y  dS )zHelper for getting a cached value when possible.

        This method isn't meant to be called externally, it's mean to be
        wrapped by other methods like compiles() and links().
        r  Nr  )r  r~   scratch_dirr  r   )
r  r  r@  rB  rD  r   r  rF  r   rrI   rI   rN   _build_wrapper'  s   ""zCompiler._build_wrapperrB  rD  r   rF  UT.Union[None, T.List[str], CompilerArgs, T.Callable[[CompileCheckMode], T.List[str]]]c                C  sJ   | j ||||||d}|jdk|jfW  d    S 1 sw   Y  d S )N)rF  r   )r`  r   r  )r  r  r@  rB  rD  r   rF  r  rI   rI   rN   compiles:  s   $zCompiler.compiles)r   rB  rD  rF  r   T.Optional['Compiler']c          	   	   C  st   |r.|j |||dd}tj|j}| j||||tjddW  d    S 1 s)w   Y  | j||||tj|dS )NT)rD  r  ra  )r`  r   rb   from_absolute_filer  rc  r}   r   )	r  r  r@  r   rB  rD  rF  r_  rK  rI   rI   rN   linksB  s   
 
zCompiler.linkskwargsr   build_to_srcc                 C  r  )z&Used by D for extra language features.z$ does not implement get_feature_argsrq  )r  rg  rh  rI   rI   rN   get_feature_argsP  r]  zCompiler.get_feature_argsprelink_nameobj_listc                 C  r  )Nz$ does not know how to do prelinking.rq  )r  rj  rk  rI   rI   rN   get_prelink_argsU  r`  zCompiler.get_prelink_args'RSPFileSyntax'c                 C  r8  )zThe format of the RSP file that this compiler supports.

        If `self.can_linker_accept_rsp()` returns True, then this needs to
        be implemented
        )r   rsp_file_syntaxr/  rI   rI   rN   rn  X  s   
zCompiler.rsp_file_syntaxis_debugc                 C  rv  )z%Arguments required for a debug build.rI   )r  ro  rI   rI   rN   get_debug_args`  ri  zCompiler.get_debug_argsc                 C  rv  )z)Arguments to completely disable warnings.rI   r/  rI   rI   rN   get_no_warn_argsd  ri  zCompiler.get_no_warn_argsc                 C  s   t d| j )NzThere is no static linker for )NotImplementedErrorr  r/  rI   rI   rN   needs_static_linkerh  r`  zCompiler.needs_static_linkerc                 C  s   t |   d)z%Get compiler's preprocessor.
        z does not support preprocessorrI  r/  rI   rI   rN   get_preprocessork  s   zCompiler.get_preprocessor)NNF)r  r   r  r   r  rS   r  r   r  r  r   r  r  r  r  r\   )rT   rS   )r+  r[   rT   r\   )rT   r2  )F)r>  rS   r?  rS   r@  rA  rB  rC  rD  rE  rF  r\   rT   rG  )rL  rS   rM  rN  rO  rN  rP  rN  r?  rS   r@  rA  rB  rQ  rD  rR  rT   rU   )rT  r   r   rS   rT   r   )rW  rS   rX  r   r?  rS   r@  rA  rB  rQ  rD  rR  rT   rY  )rW  rS   r?  rS   r@  rA  rB  rC  rD  rR  rT   rY  )r@  rA  rT   r\   )T)r  r\   rT   r   )rT   r   )re  rS   rT   r   )rm  rS   rT   r   )ro  rS   rT   r  )ro  rS   rT   r\   )rT   r\   )r}  rS   rT   r   )rT   r  )r   r   rT   r   )r  rS   r?  rS   r@  rA  rB  rQ  rD  rR  rT   rY  )r  rS   r?  rS   r@  rA  rB  rQ  rD  rR  rF  r\   rT   rY  )r  rS   r  rS   r?  rS   r@  rA  rB  rQ  rD  rR  rT   rY  )
r  r[   r@  rA  rB  r  rD  rR  rT   r   )
r  rS   r@  rA  rB  r  rD  rR  rT   r   )rW  rS   r?  rS   r@  rA  rB  rQ  rD  rR  rT   r  )rW  rS   r?  rS   r@  rA  rB  r  rD  rR  rT   r  )r  rS   r?  rS   r@  rA  rB  r  rD  rR  rT   rY  )r   r   r  r   rT   r   )r   r   rT   r   )r  rS   r@  rA  r  r   r  r   r  r\   rT   r  )r@  rA  r  r   r  r\   rT   r  )r@  rA  rT   r   )r   r   r@  rA  rT   rY  )rm  rS   r   r}   rT   rS   )r   r}   rT   r   rh   )r   r  rT   r   )r  r[   rB  r  r   r}   r  r\   r  r  rT   r  )r  r[   r  r  rB  r  r   r}   r  r  rT   r  )r  rS   rT   r   )r  rS   r  r\   rT   r   )r  rS   rT   r  )r  rS   rT   r   )r  rS   rT   r  )r@  rA  r   rS   r  rS   r  r  r  rS   r  rS   rT   r  )r  rS   rT   rS   )r  rS   rT   r   )r   rS   rT   r   )r  rS   r@  rA  rT   rY  )r   rU   r   rS   rT   r   )r   rU   r   rS   r   r  rT   r   )r   rS   rT   r   )r@  rA  r?  rS   r  rS   rK   rS   r  rS   r  r  rT   r   )r  r  rT   r   )r  r  rT   r   )r   rS   r  rS   rT   r   )r!  r\   rT   r   )r   rS   r   rS   rT   rS   )r   rS   r   rS   rT   r   )r@  rA  r-  rN  rT   r   )rZ   rS   r/  rS   r?  rS   r@  rA  rB  r  rD  rR  rT   r0  )
r  rS   r@  rA  r  r   r2  r\   rT   r  )r  rS   rT   rS   )r:  rS   r;  rS   rT   r   )r  rS   rT   r   )r?  rS   r@  rA  rT   rA  )rZ   rS   rT   rC  )rE  rS   rF  rS   rT   r   )r   rS   rI  r\   rT   r   )rK  rS   rT   r  )rO  rS   rT   r   )rR  rS   rT   r   )rT   r  )r   rS   rT   r   )rV  rS   rT   rS   )
r@  rA  rB  rZ  rD  rR  r   r}   rT   r   )r  r[   r@  rA  rB  rZ  rD  rR  r   r}   r  r\   rF  r\   rT   r  )r  r[   r@  rA  rB  rb  rD  rR  r   r}   rF  r\   rT   rY  )r  r[   r@  rA  r   rd  rB  rb  rD  rR  rF  r\   rT   rY  )rg  r   rh  rS   rT   r   )rj  rS   rk  r   rT   r   )rT   rm  )ro  r\   rT   r   )rT   r   )r   r   r   r  __annotations__r  r  INVOKES_LINKERr   r  r*  r   r-  r0  r3  r4  r6  r7  classmethodr;  r=  rJ  rS  rU  rZ  r\  r_  rb  rd  abcabstractmethodrh  rk  rn  rs  ru  rw  ry  rz  r|  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   PREFER_SHAREDr  r  r  r  r  r  r  r  
contextlibcontextmanagerr}   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   r   r   r$  r   r   r  r  r)  r*  r,  r.  r1  r3  r4  r6  r8  r9  r<  r=  r>  rB  rD  rG  rH  rJ  rM  rL  rN  rP  rQ  rS  rT  rU  rW  rY  rX  r   r  r`  rc  rf  ri  rl  rn  rp  rq  rs  rt  rI   rI   rI   rN   r     s  
 	
=
%	)	metaclasscompT.Type[Compiler]r  r   r@  rA  c                 C  s   d|  }t d| |d}|d}|d}||jv r|n|}|j|g }	|j|g }
tj|d |	ddd}tj|d	 |
ddd}|jrO||krO||	 ||||i}|S )
zBRetrieve options that apply to all compilers for a given language.zExtra arguments passed to the r   )rM   machiner  Zenv_argsz	 compilerT)
split_args
allow_dupsz linker)r   evolver   getr   UserArrayOptionrv  extend_value)rM   r~  r  r@  descriptionZargkeyZlargkeyZenvkeyZcomp_keyZcomp_optionsZlink_optionsZcargsZlargsoptsrI   rI   rN   get_global_optionsp  s&   



r  )rM   rS   rT   rU   )rZ   r[   rT   r\   )rK   rS   rT   r\   )r   r   r   r   r   r   rT   r\   )r   r   r   r   r   r   rT   r   )r   r   rT   r\   )r   r   r   r   rT   r   )
r   r   r   r   r   r\   r   rS   rT   r   )
rM   rS   r~  r  r  r   r@  rA  rT   r   )t
__future__r   rx  r{  Zos.pathr   reenum	itertoolstypingT	functoolsr   r   r   r   r   r   r	   r
   r   r   r   r   arglistr   TYPE_CHECKINGbuildr   r   r   r   Z	envconfigr   r@  r   Zlinkersr   linkers.linkersr   r   rD  r   TypeVarr   r   rd   rt   ry   r"  keysall_languagesZc_cpp_suffixesr#  cpp_suffixes
c_suffixesrn   rp   chainvaluesr{   ri   
clib_langsrW   dictitemsSUFFIX_TO_LANGLANGUAGES_USING_LDFLAGSZLANGUAGES_USING_CPPFLAGSr~   rw   rR   ru  rY   rf   rj   rm   ro   rq   ru   rv   rz   r|   Enumr}   r   r   r   r   r   r   r   r   Zgnu_winlibsZmsvc_winlibsr   r   r   r   r"  UserBooleanOptionUserIntegerOptionUserComboOptionUserStringOptionr   r   r   r   r   r   r   r   r  ABCMetar   r  rI   rI   rI   rN   <module>   s  $
$


















		





0B      r