
    -Ph&                       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
Z
ddlmZ ddlmZ ddlmZ ej        ZddlmZmZmZmZmZmZmZmZmZ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$ 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%m0Z0 ddl1m2Z2 ddlm3Z3 ddl4m5Z5 ddlm6Z6 e	j7        e8e0f         Z9g dZ:dZ;dedZ<dfd"Z=dgdhd*Z>didjd-Z?dkdld/Z@dmd2ZAdndod6ZBdpd8ZCdqdrd<ZDdqdsd>ZEdtdAZFdudBZGdudCZHdudDZIdudEZJdvdHZKdwdJZLdvdKZMdvdLZNdMdNdOdPdQdQdPdRdRdRdRdRdSdTdUdVZOdWePdX<   dxdZZQdxd[ZRdyd\ZSdzd]ZTdkd{d`ZUd|dbZV G dc dd          ZWdS )}    )annotationsN   coredata)mesonlib)machinefile)
MesonExceptionMachineChoice
Popen_safe
PerMachinePerMachineDefaultablePerThreeMachineDefaultable
split_args	quote_argsearch_versionMesonBugException)	OptionKey)mlog)ExternalProgram)BinaryTableMachineInfo
Propertiesknown_cpu_familiesCMakeVariables)	compilers)is_assembly	is_header
is_library
is_llvm_ir	is_object	is_source)	lru_cache)	envconfig)Compiler)VisualStudioLikeCompiler)ElementaryOptionValues)Resolver)cargo))PKG_CONFIG_PATHpkg_config_path)CMAKE_PREFIX_PATHcmake_prefix_path)LDFLAGSldflags)CPPFLAGScppflagszmeson.buildvalobjectreturnstrc                D    t          | t                    s
J d            | S )Nfor mypy)
isinstancer4   )r1   s    V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mesonbuild/environment.py_as_strr9   ?   s%    c3+++++J    for_machiner
   is_crossboolvar_nameT.Optional[str]c                <   t          |r|dz   gn|g|g          |          }|D ]%}t          j                            |          }| n:&d                    d |D                       }t          j        d| d           dS t          j        d|d|           |S )	z2
    Returns the exact env var and the value.
    
_FOR_BUILDNz, c                    g | ]}|S  rC   ).0vars     r8   
<listcomp>z _get_env_var.<locals>.<listcomp>V   s    @@@c#z@@@r:   zNone of z; are defined in the environment, not changing global flags.zUsing z from environment with value: )r   osenvirongetjoinr   debug)r;   r<   r>   
candidatesrE   value	formatteds          r8   _get_env_varrO   D   s     
 '/	>(\
!	"	"XJ	
  J   
s##E  II@@Z@@@AA	
didddeeetJFFFUFFGGGLr:   gcovr3.3F	gcovr_exemin_versionlog/T.Union[T.Tuple[None, None], T.Tuple[str, str]]c           
     p   	 t          | dg          dd         \  }}n# t          t          f$ r Y dS w xY wt          |          }|j        dk    ret          j        |d|z             rM|rGt          j        d	                    |t          t          j        |                                          | |fS dS )N	--versionr      NN>=zFound gcovr-{} at {})r   FileNotFoundErrorPermissionErrorr   
returncoder   version_comparer   rT   formatr   shutilwhich)rR   rS   rT   pfounds        r8   detect_gcovrrd   ]   s    y+677!<55/   zz 5!!E|qX5eTK=OPP 	_H+225)FLQZD[D[:\:\]]^^^%:    44lcovlcov_exec           
     D   	 t          | dg          dd         \  }}n# t          t          f$ r Y dS w xY wt          |          }|j        dk    rO|rM|rGt          j        d                    |t          t          j
        |                                          | |fS dS )NrW   r   rX   rY   zFound lcov-{} at {})r   r[   r\   r   r]   r   rT   r_   r   r`   ra   )rg   rT   rb   rc   s       r8   detect_lcovri   k   s    x566qs;55/   zz 5!!E|qU 	]H*11%6<PXCYCY9Z9Z[[\\\:re   suffixc                    | %| dk    rd}nd|  }t          j        |          |S n,t          d          }|D ]}t          j        |          r|c S d S )N zllvm-covz	llvm-cov-)r`   ra   get_llvm_tool_names)rj   tooltoolss      r8   detect_llvm_covrp   y   s    R<<DD'v''D<)K * $J// 	 	D|D!! 4r:   r   coredata.CoreDatac                0   | j         t          j                 }d|v o|d         j        dk    }d|v o|d         j        dk    }|r(|d         j                            d          d         }|S |r(|d         j                            d          d         }|S d S )Ncppclangc.r   )r   r
   BUILDidversionsplit)r   r   cpp_compiler_is_clangc_compiler_is_clangrj   s        r8   compute_llvm_suffixr}      s    "=#67I!Y.Q9U3C3F'3Q*Ky~/@G/K 5!)//44Q7  3'--c2215 4r:   genhtmlgenhtml_exe"T.Tuple[str, T.Optional[str], str]c                \    t          |           \  } }t          j        |          d }| ||fS N)ri   r`   ra   )rg   r   lcov_versions      r8   detect_lcov_genhtmlr      s6    (22Hl|K  (\;..r:   mT.Tuple[T.Optional[str], T.Optional[str], T.Optional[str], T.Optional[str], T.Optional[str], T.Optional[str]]c                    t                      \  }}t          t          |                     }|t          d          }t                      \  }}}||||||fS )Nrl   )rd   rp   r}   r   )r   rR   gcovr_versionllvm_cov_exerg   r   r   s          r8   find_coverage_toolsr      s^    +~~I}"#6x#@#@AAL&r***=*?*?'HlKmX|[,VVr:   1.8.2ry   T.Optional[T.List[str]]c                :    t          | |          }|r|d         nd S )Nr   ) detect_ninja_command_and_version)ry   rT   rs      r8   detect_ninjar      s$    (#66A1Q44$r:   %T.Optional[T.Tuple[T.List[str], str]]c                   t           j                            dd           }|r|gng dD ]U}t          |d          }|                                s)	 t          |j        dgz             dd         \  }}n# t          t          f$ r Y aw xY w|	                                }|j
        dk    rt          j        |d| z             r|rt           j                            |          }|                    d	|z             r|dd
t!          |          z
           }|dk    rd}|dk    rd}t#          j        d                    ||d                    d |j        D                                            |j        |fc S Wd S )NNINJA)ninjaninja-buildsamuT)silentrW   r   rX   rZ   -r   r   r   samuraizFound {}-{} at {} c                ,    g | ]}t          |          S rC   )r   )rD   xs     r8   rF   z4detect_ninja_command_and_version.<locals>.<listcomp>   s    "F"F"FA9Q<<"F"F"Fr:   )rG   rH   rI   r   rc   r   commandr[   r\   stripr]   r   r^   pathbasenameendswithlenr   rT   r_   rJ   )ry   rT   	env_ninjanprogrb   rc   names           r8   r   r      s   
w--I%Ki[[+K+K+K ) )q...zz|| 		!$,+">??!DHAuu!?3 	 	 	H	  <1!9%!P!P 	Jw''**==u-- 3"s5zz/ 12D=(("D6>>$D,33D%"F"F"F"F"FGGI I J J JL%((((4s   #A88BBrn   T.List[str]c                L    g d}g }|D ]}|                     | |z              |S )N)5rl   z-20.1z20.1-2020z-19.1z19.1z-1919z-18.1z18.1z-1818z-1717z-1616z-1515z-1414z-1313z-1212z-1111z-1010z-990z-880z-770z-6.060z-5.050z-4.040z-3.939z-3.838z-3.737z-3.636z-3.535r   z-devel)append)rn   suffixesnamesrj   s       r8   rm   rm      sG      H< E $ $TF]####Lr:   c                 Z   g } dt           j        v r t          t           j        d                   } n/t          d          }|D ]}t	          j        |          }||g}  n| rI| d         }t           j                            |          r"t          j        |t           j	                  r|gS g S )a   Look for scan-build binary on build platform

    First, if a SCANBUILD env variable has been provided, give it precedence
    on all platforms.

    For most platforms, scan-build is found is the PATH contains a binary
    named "scan-build". However, some distribution's package manager (FreeBSD)
    don't. For those, loop through a list of candidates to see if one is
    available.

    Return: a single-element list of the found scan-build binary ready to be
        passed to Popen()
    	SCANBUILDz
scan-buildNr   )
rG   rH   r   rm   r`   ra   r   isfileaccessX_OK)exelistro   rn   ra   s       r8   detect_scanbuildr      s     Gbj  RZ455 $L11 	 	DL&&E  ' !  qz7>>$ 	BIdBG$<$< 	6MIr:   c                 d    t          d          } | D ]}t          j        |          }||gc S g S )a   Look for clang-format binary on build platform

    Do the same thing as detect_scanbuild to find clang-format except it
    currently does not check the environment variable.

    Return: a single-element list of the found clang-format binary ready to be
        passed to Popen()
    zclang-formatrm   r`   ra   ro   rn   r   s      r8   detect_clangformatr     sJ      //E  |D!!6MMM Ir:   c                 d    t          d          } | D ]}t          j        |          }||gc S g S )z Look for clang-tidy binary on build platform

    Return: a single-element list of the found clang-tidy binary ready to be
        passed to Popen()
    z
clang-tidyr   r   s      r8   detect_clangtidyr   )  sJ      --E  |D!!6MMM Ir:   c                 d    t          d          } | D ]}t          j        |          }||gc S g S )z Look for clang-apply-replacements binary on build platform

    Return: a single-element list of the found clang-apply-replacements binary
        ready to be passed to Popen()
    zclang-apply-replacementsr   r   s      r8   detect_clangapplyr   6  sK       :;;E  |D!!6MMM Ir:   r   CompilersDictc                ,   t          j                    }|dk    r|S  | j                    D ]h}t          j        d|          }|j        dk    r|j        dv r dS |j        dk    r|j        dv r dS |j        dk    r|                    d          r dS i|S )	a  
    Detecting the 'native' architecture of Windows is not a trivial task. We
    cannot trust that the architecture that Python is built for is the 'native'
    one because you can run 32-bit apps on 64-bit Windows using WOW64 and
    people sometimes install 32-bit Python on 64-bit Windows.

    We also can't rely on the architecture of the OS itself, since it's
    perfectly normal to compile and run 32-bit applications on Windows as if
    they were native applications. It's a terrible experience to require the
    user to supply a cross-info file to compile 32-bit applications on 64-bit
    Windows. Thankfully, the only way to compile things with Visual Studio on
    Windows is by entering the 'msvc toolchain' environment, which can be
    easily detected.

    In the end, the sanest method is as follows:
    1. Check environment variables that are set by Windows and WOW64 to find out
       if this is x86 (possibly in WOW64), if so use that as our 'native'
       architecture.
    2. If the compiler toolchain target architecture is x86, use that as our
      'native' architecture.
    3. Otherwise, use the actual Windows architecture

    x86r%   msvc>   r   80x86zclang-cl>   r   i686gcc__i386__)r   windows_detect_native_archvaluesTcastrx   targethas_builtin_define)r   os_archcompilers      r8   detect_windows_archr   C  s    0 133G%
 %I$&&  64h??;&  ho9I&I&I55;*$$(/_*L*L55;%H$?$?
$K$K55Nr:   definec                     | j                     D ]0}	 |                    |          r dS # t          j        $ r Y -w xY wdS )NTF)r   r   r   r	   )r   r   ru   s      r8   any_compiler_has_definer   l  sm    Y  	##F++ tt& 	 	 	D	 5s   ,>>c                   t          j                    rt          |           }nt          j                    sLt          j                    s9t          j                    s&t          j                    st          j                    r&t          j	                    
                                }n%t          j                    
                                }|                    d          r|                    d          rd}n|dk    rd}n|dk    rd}n|                    d          rd}n|                    d          s|                    d          rd}ng|                    d	          rd
}nO|                    d          s|dv rd}n3|dv rd}n,|dv rd}n%|                    d          r
d|vrd}n	d}n|dv rd}|dk    rt          | d          rd}nU|dk    rt          | d          rd}n<|dk    rd}n3|dk    rt          | d          rd
}n|dk    r| rt          | d          sd}|t          vrt!          j        d|d           |S )z
    Python is inconsistent in its platform module.
    It returns different values for the same cpu.
    For x86 it might return 'x86', 'i686' or some such.
    Do some canonicalization.
    i86r   bepcarm64aarch64armearm)	powerpc64ppc64r   )powerpcppc>   power macintoshmacppcr   >   x64amd64i86pcx86_64>   sun4usun4vsparc64mips64mips64>   ip30ip35r   __arm__parisc64parisc	__64BIT____mips64zUnknown CPU family z|, please report this at https://github.com/mesonbuild/meson/issues/new with the output of `uname -a` and `cat /proc/cpuinfo`)r   
is_windowsr   
is_freebsd	is_netbsd
is_openbsdis_qnxis_aixplatform	processorlowermachine
startswithr   r   r   r   warningr   trials     r8   detect_cpu_familyr  v  s     +#I..				 +("4"6"6 +(:M:O:O +S[SbSdSd +hphwhyhy +"$$**,, ""((** !5!5 	&	'					)	$	$ 			%	 	  E$4$4V$<$< 			0	1	1 			,	-	- :W1W1W	+	+	+	$	$	$			&	!	! uEEEE	"	"	"
 "9j99 	E	)		"9i88 	E 
*		 	%"9k:: 	E 
(		 	4Y
KK 	E&&& D5 D D D 	E 	E 	E Lr:   c                X   t          j                    rt          |           }nt          j                    s9t          j                    s&t          j                    st          j                    r&t          j                    	                                }n%t          j
                    	                                }|dv rd}|dk    rt          | d          rd}n|                    d          s|                    d          rt          | d          rd}nd}n|                    d	          rd}nx|d
k    r&t          j                    	                                }nL|                    d          rd|vrd}n0| rt          | d          sd}nd}n|dk    rt          | d          rd}|S )N>   r   r   r   r   r   r   r   r   r   r   r   e2kr   r   r  r   r   r  r   )r   r  r   r  r  r  r
  r  r  r  r  r   r  r  s     r8   
detect_cpur    s    +#I..				 +("4"6"6 +(:M:O:O +S[SbSdSd +"$$**,, ""((**)))"9j99 	E			)	$	$ (8(8(A(A "9i88 	EE EE			&	!	! 	%"$$**,,			&	!	! uEE !!8J!O!O ! 	%"9k:: 	E Lr:   freebsdopenbsdnetbsdntlinuxxnu	dragonflyhaikugnu)r  r  r  windowsandroidr  cygwindarwiniostvosvisionoswatchosr  r  r  zT.Mapping[str, str]KERNEL_MAPPINGSsystemc                   | dk    rt          j        t          j                    j        d          rdS t          ddg          \  }}}|j        dk    rt          d          |                                	                                }|dvrt          j        d	| d
           d S |S t                              | d           S )Nsunosz<=5.10solarisz/usr/bin/unamez-or   z!Failed to run "/usr/bin/uname -o">   illumosr,  zqGot an unexpected value for kernel on a SunOS derived platform, expected either "illumos" or "solaris", but got "z^".Please open a Meson issue with the OS you're running and the value detected for your kernel.)r   r^   r  unamereleaser   r]   r	   r  r   r   r  r(  rI   )r)  rb   out_s       r8   detect_kernelr2    s     #HN$4$4$<hGG 	9  0$788	3<1 !DEEEiikk!!,,,L x  NQ x x x y y y4
vt,,,r:   c                    | dk    rdS | S )Nr#  macosrC   )r)  s    r8   detect_subsystemr5    s    wMr:   c                 p    t           j        dk    rdS t          j                                                    S )Nr"  )sysr  r)  r  rC   r:   r8   detect_systemr8    s.    
|xx?""$$$r:   c                 B    t           j                            dd           S )NMSYSTEM_CARCH)rG   rH   rI   rC   r:   r8   detect_msys2_archr;    s    :>>/4000r:   T.Optional[CompilersDict]r   c           
         t                      }t          || t          |           nd| t          |           ndt          j        t          |          t          |                    S )a  Detect the machine we're running on

    If compilers are not provided, we cannot know as much. None out those
    fields to avoid accidentally depending on partial knowledge. The
    underlying ''detect_*'' method can be called to explicitly use the
    partial information.
    N)r8  r   r  r  r7  	byteorderr2  r5  )r   r)  s     r8   detect_machine_infor?    sh     __F(1(=)$$$4!*!6
9Df  " " "r:   machine_infoc                    | j         t                      k    rdS t          i           }| j        
J d            | j        |k    p!|dk    o
| j        dk    p|dk    o
| j        dk    S )aW  Whether we can run binaries for this machine on the current machine.

    Can almost always run 32-bit binaries on 64-bit natively if the host
    and build systems are the same. We don't pass any compilers to
    detect_cpu_family() here because we always want to know the OS
    architecture, not what the compiler environment tells us.
    FNz!called on incomplete machine_infor   r   r   r   )r)  r8  r  
cpu_family)r@  true_build_cpu_familys     r8   machine_info_can_runrD  .  s     moo--u-b11"..0S...		 $9	9 	V
8
+	S,2IU2R	V
8
+	T,2IV2SVr:   c                     e Zd ZdZdZdZdRdZdSdZdTdZdUdZ	dUdZ
dUdZdVdZej        fdWd ZdXd!ZdXd"ZdYd$ZedZd[d(            Zd\d+Zd\d,Zd\d-Zd\d.Zd\d/Z ed01          d]d3            Zd^d7ZdXd8ZdXd9ZdXd:ZdXd;Z dXd<Z!dXd=Z"dXd>Z#dXd?Z$dXd@Z%dXdAZ&dXdBZ'dXdCZ(dXdDZ)dXdEZ*dXdFZ+d_dGZ,d_dHZ-ej        fd`dIZ.dadKZ/dbdLZ0dcdQZ1d0S )dEnvironmentzmeson-privatez
meson-logsz
meson-info
source_dirr4   	build_dirr?   cmd_optionscoredata.SharedCMDOptionsr3   Nonec           	         | _         || _        t          j                            |t
          j                   _        t          j                            |t
          j                   _        t          j                            |t
          j	                   _	        t          j
         j        d           t          j
         j        d           t          j
         j	        d           	 t          j                                         d           _        d _        n# t          $ r                      |           Y nqt          j        $ r\}t%          j        dt)          |                     t          j         j        |                                |           Y d }~nd }~wt,          $ r}t          j                            t          j         j                            rzt%          j        dd           t%          j        dt%          j        t)          |                               t          j         j        |                                |           nt-          t)          |           d	          Y d }~n+d }~ww xY wd
 _        d
 _                             |           t7                      }t9                      }t9                      }t9                      }t;                      |_        t?                      |_        tA                      |_        tC          j"                     _#        i  _$        tK          j&         j        j'         j        j(         j                    _)         j        j'        tK          j*         j        j'         j                   }	t?          |	+                    di                     |_        tA          |	+                    di                     |_        tY          |	+                    di                     |_         -                    |	|j         j        j(        rt\          j/        nt\          j0                    j        j(        rotK          j*         j        j(         j                   }	tA          |	+                    di                     |_1        t?          |	+                    di                     |_1        tY          |	+                    di                     |_1        d|	v rte          j3        |	d                   |_1        d|	v rte          j3        |	d                   |_4        tk           j#        6                                          D ]@\  }
} j        j7        8                    |
          r| j#        |
9                                <   A -                    |	|j1        t\          j0                   |:                                 _;        |:                                 _<        |:                                 _=        |:                                 _>         ?                                  @                                  A                                 t          d          }t          d          }t          d          }| j#        v r(| j#        v s	| j#        v rt%          j        dd            fd j#        6                                D              _#         C                    t\          j0        d          }|&t          jE         t\          j0        d           _F        nd  _F        dg _G        dg _H        d  _I        d  _J        d S )NT)exist_okF)suggest_reconfigurez(Regenerating configuration from scratch:z(Regenerating configuration from scratch.)fatalzReason:z- Try regenerating using "meson setup --wipe".rl   binaries
propertiescmakehost_machinetarget_machine	buildtyperK   optimizationzRecommend using either -Dbuildtype or -Doptimization + -Ddebug. Using both is redundant since they override each other. See: https://mesonbuild.com/Builtin-options.html#build-type-optionsc                    i | ]:\  }}|j         t          j        u sj        j                            |          7||;S rC   )r  r
   HOSTr   optstoreis_per_machine_option)rD   kvselfs      r8   
<dictcomp>z(Environment.__init__.<locals>.<dictcomp>  sT     o o oA9(:::dm>T>j>jkl>m>m: 1:::r:   exe_wrapperz
pkg-config)KrG  rH  rG   r   rJ   rF  private_dirscratch_dirlog_dirinfo_dirmakedirsr   loadget_build_dirfirst_invocationr[   create_new_coredataMesonVersionMismatchExceptionr   rT   r4   read_cmd_line_filer	   r   get_cmd_line_filer  redr   r   r?  buildr   r   collectionsOrderedDictoptionsenv_optsr   MachineFileStoreconfig_filescross_filesmachinestoreparse_machine_filesrI   r   _load_machine_file_optionsr
   rw   rX  hostr   from_literalr   listitemsrY  rZ  as_builddefault_missingmachinesrP  rQ  	cmakevars_set_default_options_from_env_set_default_binaries_from_env _set_default_properties_from_envr   lookup_binary_entryr   from_bin_listr_  default_cmakedefault_pkgconfigwrap_resolverr(   )r]  rG  rH  rI  er~  rP  rQ  r  configkeyrM   btdbopr_  s   `               r8   __init__zEnvironment.__init__D  s   $  &DN!w||I{7NOOD7<<	;3FGGDLGLLK4HIIDMK(48888Kt4444K5555c3;=ASASAUAUkp3q3q3q(-%%$ 6 6 6((555559 6 6 6CSVVLLL+DNKHHH((55555555! 	c 	c 	c 7>>("<T^"L"LMM cL!KSXYYYYHYQ(8(8999/LLL,,[9999(CFF)a)a)abbb :9999	c  DN!D$$[111 =W<X<X 8M7N7N 9N8O8O
 <Q;R;R	
 -.. %%<<
 MXLcLeLe
 NP'89SUYUbUnptp  A  A =%1 4T]5OQUQ`aaF(J)C)CDDHN)&**\2*F*FGGJ,VZZ-D-DEEIO++
('+}'@X##mFXZ Z Z =$ 	Y 4T]5NPTP_``F(L")E)EFFJO'

:r(B(BCCHM+FJJw,C,CDDIN'' + 89O P P6))"-":6BR;S"T"T #4<#5#5#7#788 9 9
U=)??DD 938DL0++FJO]EWXXX !0022 0022$4466"2244 	**,,,++-----/// {##w~&&2#5#5t|9K9KL _  %& & & &o o o o););)=)= o o o ..}/A=QQ".<T=CUWdeeD#D%Y".5948


s,   24D( (J
JAF//J<CJJmachine_file_stringsectionsection_subprojectr  r
   r   c                &   t          j        |          }|j        t          j        k    sJ |j        r |dk    r|nd}t          d| d| d          |r|                    |          }|t          j        k    r|                    |          S |S )Nproject optionsbuilt-in optionsz"Do not set subproject options in [z] section, use [subproject:z
] instead.)
subprojectr  )	r   from_stringr  r
   rX  r  r	   evolverw   )r]  r  r  r  r  r  
suggestions          r8   mfilestr2keyzEnvironment.mfilestr2key  s    #$788{m00000> 	B$+/@$@$@FXJ   "Ag  "A  "Ajt  "A  "A  "A  B  B  B 	<**(:*;;Cm)))::g:...
r:   r  6T.Mapping[str, T.Mapping[str, ElementaryOptionValues]]rQ  r   c                L   |                     d          }|rPt          j        d           |                                D ]'\  }}|                     |dd|          }|| j        |<   (t                      }t          j        D ]2}	|	                    |	dz              |	                    |	dz              3|j
                                                                        D ]J\  }}||v rAt          j        | d           |                     |dd|          }|| j        |<   |j
        |= K|                                D ]\  }
}d|
v r|
                    d          \  }}
nd	}|
d
k    rj|                                D ]T\  }}|                     ||
||          }|t          j        u r|j        |urt          j        dd           || j        |<   U|
dk    rJ|t          j        u r<|                                D ]'\  }}|                     ||
||          }|| j        |<   (dS )zDRead the contents of a Machine file and put it in the options store.pathszNThe [paths] section is deprecated, use the [built-in options] section instead.N_args
_link_argszc in the [properties] section of the machine file is deprecated, use the [built-in options] section.rQ  :rl   r  zqSetting build machine options in cross files, please use a native file instead, this will be removed in meson 2.0T)oncer  )rI   r   deprecationr{  r  rp  setr   all_languagesaddrQ  copyrz   r
   rX  r  )r]  r  rQ  r  r  strkr\  r[  deprecated_propertieslangr  r   r  r  s                 r8   rw  z&Environment._load_machine_file_options  s    

7## 	$mnnn ;;== $ $a%%dGT7CC"#Q
 -0EE+ 	; 	;D!%%dWn555!%%d\&9::::!,113399;; 	0 	0GD!,,, D  "N  "N  "N  O  O  O%%dL$HH"#Q)$/%||~~ 	* 	*OGVg~~.5mmC.@.@+"GG%'",,,%||~~ * *GD!++D';MwWWC-"444G9S9S(  *]  dh  i  i  i  i()DL%%* ---']=O2O2O  &||~~ * *GD!++D';MwWWC()DL%%%	* 	*r:   c                   d t           j         j                                        D             t          z   }t	          j        t                    }t          j        |t                    D ]J\  \  }}}t          ||                                 |          }||dk    rv| j        |                                         r |                    t          j                  }nt#          j        d|          }t          t%          j        |                    }nT|dk    r?t          t%          j        |                    t          j                                      }nt)          |          }d |D             }| j        r7|dk    rEt           j         j        D ]1}	t/          |	 d|          }
||
                             |           2^|d	k    rEt           j         j        D ]1}	t/          |	 d
|          }
||
                             |           2t/          j        |                              |          }
|t           j         j                                        v r9|
j                            dd          d         }	|
                    |	 d
          }
||
                             |           Lt          j        t          t                    D ]P\  \  }}}t/          j        |                              |          }
|
|v r|
| j        vr||
         | j        |
<   ||
= Q| j                             |           d S )Nc                "    g | ]\  }}|| d fS )r  rC   )rD   r[  r\  s      r8   rF   z=Environment._set_default_options_from_env.<locals>.<listcomp>  s'    UUU$!QaAUUUr:   r,   z:|;r*   c                    g | ]}||S rC   rC   )rD   r  s     r8   rF   z=Environment._set_default_options_from_env.<locals>.<listcomp>.  s    111q1!111r:   r.   r  )r   r  r0   r  r  r1  r   r   )!r   CFLAGS_MAPPINGr{  NON_LANG_ENV_OPTIONSrn  defaultdictrz  	itertoolsproductr
   rO   is_cross_buildr~  r  rz   rG   pathseprer   
OrderedSetr   rg  LANGUAGES_USING_LDFLAGSr   extendLANGUAGES_USING_CPPFLAGSr  r  r   r   rp  rq  update)r]  optsrq  evarkeynamer;   p_env_p_envp_listr  r  r1  s               r8   r  z)Environment._set_default_options_from_env  s.   UU)*=*L*R*R*T*TUUU ! 	
 ;F:QRV:W:W,5,=dM,R,R %	5 %	5(OT7[ d.A.A.C.CTJJE  111}[1<<>> 9!&RZ!8!8 "$&%!8!8!("5f"="=>>FF 111!("5ekk"*6M6M"N"NOOFF'..F11V111 ( 5)++$-$7$O 9 9D"+D1D1D1Dk"Z"Z"ZC$SM0088889 !J..$-$7$P 9 9D"+tNNNK"P"P"PC$SM0088889 (3G<<CCKCXX9#6#E#L#L#N#NNN#&8>>#q#9#9!#<D"%**^^^"<"<C ,,V444 *3):;OQ^)_)_ 	" 	"%LQ+'00777LLC h3dl#:#:$,SMS!SMX&&&&&r:   c                .   t          j        t          j                                        t          j                                                  }t          j        |t                    D ]\  \  }}}t          || 	                                |          }|t          j                            |          r(| j        |         j                            ||g           t| j        |         j                            |t          j        |                     dS )zSet default binaries from the environment.

        For example, pkg-config can be set via PKG_CONFIG, or in the machine
        file. We want to set the default to the env variable.
        N)r  chainr#   DEPRECATED_ENV_PROG_MAPr{  ENV_VAR_PROG_MAPr  r
   rO   r  rG   r   existsrP  
setdefaultr   r   )r]  r  r   r  r;   r  s         r8   r  z*Environment._set_default_binaries_from_envY  s     y@FFHH(9??AAC C *3):4)O)O 	e 	e%LT4+ d.A.A.C.CTJJE 7>>%(( eM+.7BB4%QQQQM+.7BB4I\]bIcIcddd	e 	er:   c                   ddgdfddgdfdddgd	fd
dgdfg}t          j        |t                    D ]\  \  }}}}|D ]}t          ||                                 |          }|n|rD| j        |         j                            ||                    t          j	                             n&| j        |         j                            ||            ndS )z6Properties which can also be set from the environment.boost_includedirBOOST_INCLUDEDIRFboost_librarydirBOOST_LIBRARYDIR
boost_root
BOOST_ROOT	BOOSTROOTT	java_home	JAVA_HOMEN)
r  r  r
   rO   r  rQ  r  rz   rG   r  )r]  r  r   evarsrz   r;   r  r  s           r8   r  z,Environment._set_default_properties_from_envj  s     "4!5u="4!5u=L+6=;-/	9
 2;1B41W1W 	 	- T5%+  $[$2E2E2G2GNN$ X4?JJ4QVQ\Q\]_]gQhQhiiii4?JJ4QVWWWE %	 	r:   rp  c                    t          j                    }|g }n|                                }t          j        || j        |          | _        d| _        d S )NT)r   get_meson_commandr  r   CoreDatara  rg  )r]  rp  meson_commands      r8   rh  zEnvironment.create_new_coredata~  sW    
 !244 MM)..00M )'43C]SS $r:   when_building_forr=   c                6    | j                             |          S r   )r   r  )r]  r  s     r8   r  zEnvironment.is_cross_build  s    }++,=>>>r:   c                Z    t          j        | j         |                                           S r   )r   saverf  r]  s    r8   dump_coredatazEnvironment.dump_coredata  s"    }T]D,>,>,@,@AAAr:   c                    | j         S r   )rb  r  s    r8   get_log_dirzEnvironment.get_log_dir  s
    |r:   rq   c                    | j         S r   r   r  s    r8   get_coredatazEnvironment.get_coredata  s
    }r:   F
unbufferedr   c                    t          j                    }|t          d          |                                }| r=dt          j                            |d                   v r|                    dd           |S )NzNo command?pythonr   r   z-u)r   r  r   r  rG   r   r   insert)r  cmds     r8   get_build_commandzEnvironment.get_build_command  so    (**;#M222hhjj 	 (bg&6&6s1v&>&>>>JJq$
r:   fname'mesonlib.FileOrString'c                     t          |          S r   )r   r]  r  s     r8   r   zEnvironment.is_header      r:   c                     t          |          S r   )r!   r  s     r8   r!   zEnvironment.is_source  r  r:   c                     t          |          S r   )r   r  s     r8   r   zEnvironment.is_assembly  s    5!!!r:   c                     t          |          S r   )r   r  s     r8   r   zEnvironment.is_llvm_ir  s    %   r:   c                     t          |          S r   )r    r  s     r8   r    zEnvironment.is_object  r  r:   N)maxsizemesonlib.FileOrStringc                     t          |          S r   )r   r  s     r8   r   zEnvironment.is_library  s    %   r:   r;   r   r   c                B    | j         |                             |          S r   )rP  lookup_entry)r]  r;   r   s      r8   r  zEnvironment.lookup_binary_entry  s    }[)66t<<<r:   c                    | j         S r   )ra  r  s    r8   get_scratch_dirzEnvironment.get_scratch_dir  s    r:   c                    | j         S r   )rG  r  s    r8   get_source_dirzEnvironment.get_source_dir  s
    r:   c                    | j         S r   )rH  r  s    r8   rf  zEnvironment.get_build_dir  s
    ~r:   c                *    |                                  S )z=Install dir for the import library (library used for linking)
get_libdirr  s    r8   get_import_lib_dirzEnvironment.get_import_lib_dir         r:   c                *    |                                  S )z9Install dir for shared modules that are loaded at runtimer  r  s    r8   get_shared_module_dirz!Environment.get_shared_module_dir  r  r:   c                    | j         j        }|                                s|                                r|                                 S |                                 S )z"Install dir for the shared library)r~  rx  r  	is_cygwin
get_bindirr  )r]  ms     r8   get_shared_lib_dirzEnvironment.get_shared_lib_dir  sK    M<<>> 	%Q[[]] 	%??$$$   r:   c                0    |                                   dS )zInstall dir for JAR filesz/java)get_datadirr  s    r8   get_jar_dirzEnvironment.get_jar_dir  s    ""$$++++r:   c                *    |                                  S )z"Install dir for the static libraryr  r  s    r8   get_static_lib_dirzEnvironment.get_static_lib_dir  r  r:   c                t    t          | j        j                            t	          d                              S )Nprefixr9   r   rY  get_value_forr   r  s    r8   
get_prefixzEnvironment.get_prefix  +    t}-;;Ih<O<OPPQQQr:   c                t    t          | j        j                            t	          d                              S )Nlibdirr  r  s    r8   r  zEnvironment.get_libdir  r  r:   c                t    t          | j        j                            t	          d                              S )N
libexecdirr  r  s    r8   get_libexecdirzEnvironment.get_libexecdir  +    t}-;;Il<S<STTUUUr:   c                t    t          | j        j                            t	          d                              S )Nbindirr  r  s    r8   r  zEnvironment.get_bindir  r  r:   c                t    t          | j        j                            t	          d                              S )N
includedirr  r  s    r8   get_includedirzEnvironment.get_includedir  r  r:   c                t    t          | j        j                            t	          d                              S )Nmandirr  r  s    r8   
get_mandirzEnvironment.get_mandir  r  r:   c                t    t          | j        j                            t	          d                              S )Ndatadirr  r  s    r8   r  zEnvironment.get_datadir  s+    t}-;;Ii<P<PQQRRRr:   c                   | j         j        |                                         D ] }|j        dk    rd} n|j        dk    rd} n!g S t	          |                                dgz             \  }}}|j        dk    rt          j        d          |	                    d          |         
                    d	          	                    d
          }d |D             S )Nrt   r   r   rX   z-print-search-dirsr   z&Could not calculate system search dirs
zlibraries: =r  c                L    g | ]!}t           j                            |          "S rC   )rG   r   normpath)rD   rb   s     r8   rF   z<Environment.get_compiler_system_lib_dirs.<locals>.<listcomp>  s(    333  ##333r:   )r   r   r   rx   r   get_exelistr]   r   r	   rz   lstrip)r]  r;   compindexrb   r0  r1  rz   s           r8   get_compiler_system_lib_dirsz(Environment.get_compiler_system_lib_dirs  s    M+K8??AA 
	 
	Dw'!!E!! " It//115I4JJKK	3<1)*RSSS		$&--n==CCCHH33U3333r:   c                    | j         j        |                                         D ]}|j        dk    r n|j        dk    r ng S |                                S )Nrt   r   )r   r   r   rx   get_default_include_dirs)r]  r;   r%  s      r8    get_compiler_system_include_dirsz,Environment.get_compiler_system_include_dirs   si    M+K8??AA 	 	Dw'!!E!! "
 I,,...r:   c                    | j         |                             dd           }|!t          |t                    s
J d            |S |                                 sdS t          | j        |                    S )Nneeds_exe_wrapperr6   F)rQ  rI   r7   r=   r  rD  r~  )r]  r;   rM   s      r8   need_exe_wrapperzEnvironment.need_exe_wrapper  sy    ,001DdKKeT**66J666L""$$ 	5'k(BCCCCr:   T.Optional[ExternalProgram]c                <    |                                  sd S | j        S r   )r-  r_  r  s    r8   get_exe_wrapperzEnvironment.get_exe_wrapper  s$    $$&& 	4r:   c                F    | j         d uo| j                                         S r   )r_  rc   r  s    r8   has_exe_wrapperzEnvironment.has_exe_wrapper  s$    t+H0@0F0F0H0HHr:   library_paths
T.Set[str]extra_pathsmesonlib.EnvironmentVariablesc                   t          j                    }| j        j                                         o| j        j                                        }|r|                    |           |r|r&|                    dt          |          d           n| j        j                                        s| j        j        	                                r|                    |           ne| j        j        
                                r$|                    dt          |                     n#|                    dt          |                     |r#|                    dt          |                     |S )NWINEPATH;)	separatorDYLD_LIBRARY_PATHLD_LIBRARY_PATHPATH)r   EnvironmentVariablesr~  rm  r  rx  r  prependrz  r   	is_darwin)r]  r3  r5  env	need_wines        r8   get_env_for_pathszEnvironment.get_env_for_paths  s\   +--+66888\T]=O=Z=Z=\=\	 	.
   --- 	D DJ](;(;sKKKK#..00 DDM4F4P4P4R4R D""=1111#--// D/m1D1DEEEE-tM/B/BCCC 	3KK[ 1 1222
r:   )rG  r4   rH  r?   rI  rJ  r3   rK  )
r  r4   r  r?   r  r?   r  r
   r3   r   )r  r  rQ  r   r  r
   r3   rK  )r3   rK  )rp  rJ  r3   rK  )r  r
   r3   r=   r3   r4   )r3   rq   )F)r  r=   r3   r   )r  r  r3   r=   )r  r  r3   r=   )r;   r
   r   r4   r3   r   )r;   r
   r3   r   )r;   r
   r3   r=   )r3   r.  )r3   r=   )r3  r4  r5  r4  r3   r6  )2__name__
__module____qualname__r`  rb  rc  r  r  rw  r  r  r  rh  r
   rX  r  r  r  r  staticmethodr  r   r!   r   r   r    r"   r   r  r  r  rf  r  r  r  r  r  r  r  r  r  r  r  r  r'  r*  r-  r0  r2  rC  rC   r:   r8   rF  rF  ?  s       !KGHS9 S9 S9 S9j
 
 
 
.* .* .* .*`B' B' B' B'He e e e"   (% % % % AN@R ? ? ? ? ?B B B B           \              " " " "! ! ! !        Yt! ! ! != = = =             ! ! ! !! ! ! !! ! ! !, , , ,! ! ! !R R R RR R R RV V V VR R R RV V V VR R R RS S S S4 4 4 4&
/ 
/ 
/ 
/ =J<N D D D D D       
I I I I     r:   rF  )r1   r2   r3   r4   )r;   r
   r<   r=   r>   r4   r3   r?   )rP   rQ   F)rR   r4   rS   r4   rT   r=   r3   rU   )rf   F)rg   r4   rT   r=   r3   rU   r   )rj   r?   r3   r?   )r   rq   r3   r?   )rf   r~   )rg   r4   r   r4   r3   r   )r   rq   r3   r   )r   F)ry   r4   rT   r=   r3   r   )ry   r4   rT   r=   r3   r   )rn   r4   r3   r   )r3   r   )r   r   r3   r4   )r   r   r   r4   r3   r=   )r)  r4   r3   r?   rD  )r3   r?   )r   r<  r3   r   )r@  r   r3   r=   )X
__future__r   r  rG   r  r  r7  r`   typingr   rn  rl   r   r   r   CmdLineFileParserr	   r
   r   r   r   r   r   r   r   r   rp  r   r   programsr   r#   r   r   r   r   r   r   r   r   r   r   r    r!   	functoolsr"   
mesonbuildTYPE_CHECKINGr$   compilers.mixins.visualstudior%   r&   	wrap.wrapr'   r(   Dictr4   r   r  build_filenamer9   rO   rd   ri   rp   r}   r   r   r   r   rm   r   r   r   r   r   r   r  r  r(  __annotations__r2  r5  r8  r;  r?  rD  rF  rC   r:   r8   <module>rU     s{  
 # " " " " " "     $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $                          1                        
             % % % % % %                                                     ? *######GGGGGG//////######F3=)M       
   2            "   $/ / / / /
W 
W 
W 
W        8' ' ' 'R   @          ' ' ' 'R   F F F FP) ) ) )V 4=3<2:373:182627/40549385@18/4(* (* * * * *"- - - -(   
% % % %
1 1 1 1" " " " "&V V V V"r r r r r r r r r rr:   