o
    Wodę                 
   @  s@  d dl mZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lm	Z	 dd
lm
Z
 ddlmZ ddlmZmZ ddlm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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%m&Z&m'Z'm(Z(m)Z)m*Z* ddlm+Z+m,Z,m-Z-m.Z. ddlm/Z/m0Z0 ddlm1Z1m2Z2m3Z3m4Z4 ddlm5Z5m6Z6 ddl7m8Z8m9Z9m:Z:m;Z;m<Z< ddl=m>Z> ddl?m@Z@ ddlmAZB ddlmCZD ddlEmFZF ddlGmHZH dd lAmIZImJZJmKZKmLZLmMZMmNZN dd!lOmPZPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZs dd"lmtZu d d#lvmwZw d d$lxmyZy d d%lzZzd d%l{Z{d d%l|Z|d d%l}Z}d d%l~Z~d d%lZd d%lZd d%lZd d%lZd d%lZejrd d%lZd d&lmZ dd'lmZ dd(l?mZ dd)lmZmZmZ dd*lmZ ejejejejejejejejejef	 Zejejejejejejejejejf Zejejejejf ZdBd/d0ZdCdDd7d8ZG d9d: d:ZejejB ZeejB ejB d;hB ZG d<d= d=eyZh d>Zd?ZG d@dA dAe!eZd%S )E    )annotations   )mparser)environment)coredata)dependencies)mlog)build)optinterpreter)	compilers)	envconfig)wrapWrapMode)mesonlib)
MesonBugExceptionMesonExceptionHoldableObjectFileModeMachineChoice	OptionKeylistifyextract_as_listhas_path_sep
PerMachine)ExternalProgramNonExistingExternalProgram)
Dependency)DepFile)ContainerTypeInfoInterpreterBase	KwargInfotyped_kwargstyped_pos_args)	noPosargsnoKwargspermittedKwargsnoArgsFlatteningnoSecondLevelHolderResolvingunholder_return)InterpreterExceptionInvalidArgumentsInvalidCodeSubdirDoneRequest)DisablerdisablerIfNotFound)
FeatureNewFeatureDeprecatedFeatureNewKwargsFeatureDeprecatedKwargs)ObjectHolderContextManagerObject)ExtensionModuleModuleObjectMutableModuleObjectNewExtensionModuleNotFoundExtensionModule)CMakeInterpreter)ExecutableSerialisation   )interpreterobjects)compiler)	MesonMain)DependencyFallbacksHolder)SubprojectHolderTest
RunProcessextract_required_kwargextract_search_dirsNullSubprojectInterpreter)$
COMMAND_KWCT_BUILD_ALWAYSCT_BUILD_ALWAYS_STALECT_BUILD_BY_DEFAULTCT_INPUT_KWCT_INSTALL_DIR_KWMULTI_OUTPUT_KW	OUTPUT_KWDEFAULT_OPTIONSDEPENDENCIES_KW
DEPENDS_KWDEPEND_FILES_KW
DEPFILE_KWDISABLER_KWD_MODULE_VERSIONS_KWENV_KWENV_METHOD_KWENV_SEPARATOR_KWINCLUDE_DIRECTORIES
INSTALL_KWINSTALL_DIR_KWINSTALL_MODE_KWLINK_WITH_KWLINK_WHOLE_KWCT_INSTALL_TAG_KWINSTALL_TAG_KWLANGUAGE_KW	NATIVE_KWPRESERVE_PATH_KWREQUIRED_KW
SOURCES_KWVARIABLES_KWTEST_KWSNoneTypein_set_validatorenv_convertor_with_method)
primitives)Path)EnumN)Literalkwargs)Backend)InterpreterObjectTYPE_varTYPE_kwargs)OverrideProgramvalue)T.Union[T.List, str, mesonlib.File, None]returnT.Optional[str]c                 C  s2   t | trt| dkrdS t | d tjsdS d S )Nr<   z,when passed as array must have a length of 1r   z(when passed as array must contain a File)
isinstancelistlenr   File)rv    r~   home/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/lib/python3.10/site-packages/mesonbuild/interpreter/interpreter.py_project_version_validator   s   
r   FargsT.List[T.Any]quoteboolstrc                 C  s   t | trdddd | D  S t | tr$dddd |  D  S t | tr/| r-dS dS t | tr8t| S t | trG|rEd	|  d	S | S td
)Nz[%s], c                 S  s   g | ]}t |d qS TstringifyUserArguments.0xr~   r~   r   
<listcomp>       z*stringifyUserArguments.<locals>.<listcomp>z{%s}c                 S  s(   g | ]\}}d  t|dt|dqS )z{} : {}T)formatr   r   kvr~   r~   r   r      s   ( truefalse'zVFunction accepts only strings, integers, bools, lists, dictionaries and lists thereof.)	rz   r{   joindictitemsr   intr   r*   )r   r   r~   r~   r   r      s   




r   c                   @  s0   e Zd ZdddZdddZdd Zdd ZdS )Summaryproject_namer   project_versionc                 C  s"   || _ || _tt| _d| _d S Nr   )r   r   collectionsdefaultdictr   sectionsmax_key_len)selfr   r   r~   r~   r   __init__   s   
zSummary.__init__sectionvaluesT.Dict[str, T.Any]bool_ynr   list_sepry   
subprojectrx   Nonec                 C  sN  |  D ]\}}|| j| v rtd|d|g }t|D ]r}	t|	tr8|r8||	r1tdnt	d qt|	t
ttfrH|t
|	 qt|	ttfr^tdd| ||	  qt|	trstdd| |t	d qt|	tjrtd	d
| ||	  qd}
t|
||||f| j| |< t| jt|| _qd S )NzSummary section z already have key YESNOz)dependency or external program in summary0.57.0zdisabler in summary0.64.0zfeature option in summary0.58.0ztSummary value in section {!r}, key {!r}, must be string, integer, boolean, dependency, disabler, or external program)r   r   r)   r   rz   r   appendr   greenredr   r   r   r   r/   
single_useZsummary_valuer-   r   
UserOptionZprintable_valuer   maxr   r|   )r   r   r   r   r   r   r   r   Zformatted_valuesimr~   r~   r   add_section   s.    
zSummary.add_sectionc           	      C  s   t | jt | j | j D ]H\}}t d |r$t dt | | D ]/\}}|\}}| jt	| }|r;dnd}t jd|d|  d |d | jd }| 
||| q(qt d d S )N  z   :)end   )r   logr   normal_cyanr   r   r   boldr   r|   
dump_value)	r   r   r   r   r   r   paddingr   indentr~   r~   r   dump   s   

zSummary.dumpc           
      C  s   dd|  }|d u rt j|d|i d S t j}g }|}| | }|D ](}t|t| }	|rD||	 |krDt j|||d |}g }|| ||	7 }q%t j|d|i d S )N
r   sep)r   r   )r   r   shutilget_terminal_sizecolumnsrstripr|   r   )
r   Zarrr   r   Z	lines_sepZmax_lenlineZline_lenr   Zv_lenr~   r~   r   r      s"   


zSummary.dump_valueN)r   r   r   r   )r   r   r   r   r   r   r   ry   r   r   rx   r   )__name__
__module____qualname__r   r   r   r   r~   r~   r~   r   r      s
    

r   target_typec                   @  s   e Zd ZdZdZdS )InterpreterRuleRelaxationz Defines specific relaxations of the Meson rules.

    This is intended to be used for automatically converted
    projects (CMake subprojects, build system mixing) that
    generate a Meson AST via introspection, etc.
    r<   N)r   r   r   __doc__ALLOW_BUILD_DIR_FILE_REFERENCESr~   r~   r~   r   r      s    r   >   cmake_package_versionversionrequiredZprivate_headers
componentsallow_fallbackmethoddefault_optionscmake_module_pathmodulesinclude_typenot_found_messagestaticlanguagemainfallbacknative
cmake_argsZoptional_moduleszYou should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300c                      s  e Zd Z										d|d} fddZd~ddZddd Zdd!d"Zdd#d$Zdd)d*Zdd-d.Z	dd2d3Z
dd4d5Zdd7d8Zdd;d<Zdd>d?Zdd@dAZedBeedBejdCdDejdCdDeddKdLZedMedNeddSdTZeedUedVeeedWg dXejdYdZd[ejdZdDed\eeedWg dXe ee!e"jd]dDe#e$jd^ed_id`edaee%fedbeee&j'dWg dcdddedf Z(edge)egdheddjdkZ*dldm Z+edne&j,e-e.j/e0j1efe&j,e-e.j/e0j1efdNednedoe)e%fdpdDedqe)dWdpdre2jdsdDddwdxZ3	dddzd{Z4d|d} Z5d~d Z6ed	eed	ee7jddDedaeeeg dWddddZ8		ddddZ9dddZ:				ddddZ;dddZ<dddZ=edeedddZ>ede?gdhedddZ@dddZAedeedNede7edee%fedaee0j1e%efdeBdd dedeeee%fddWdedeeeg dWdcdededddddZCedede)e%fd^dDeededNdddZDeEedddZFdd ZGeEeHddÃedee?feIgdhedededdede)ddedee%fd^dDdddʄZJddd̄ZKddd΄ZLeEeHddЃedd҄ ZMeEeddԄ ZNeEeHddփedd؄ ZOeeddڄ ZPeededdd߄ZQdddZRdddZSdddZTdddZUdddZVdddZWdddZXdddZYdddZZe[j\dWdWdddfdd	d
Z]dddZ^dddZ_edee0j1fddedejddDe`eedeeeg dWddedaeeeg dWddedddZadd Zbecddd gecdd_d!gecdd^d"gecddd#gecddsg d$ecddd%gecdd&dgecdddgeedeeededddd(d)ZfeHd%dЃeed*d+ Zgecd,d-d.gecd,d_d/gehd,d_d0gd1d2ede&jied,eee0j1e&jje&jke&jle&jme&j'e&jnfdNdd5d6Zoede&jped7eee0j1e&jje&jke&jle&jme&j'e&jnfdNdd9d:Zqede&jred;eee0j1e&jje&jke&jle&jme&j'e&jnfdNdd=d>Zsedeted?eee0j1e&jje&jke&jle&jme&j'e&jnfdNddAdBZueHdCdDede&jvedCeee0j1e&jje&jke&jle&jme&j'e&jnfdNddFdGZwedetedHeee0j1e&jje&jke&jle&jme&j'e&jnfdNddIdJZxede&jyedKeee0j1e&jje&jke&jle&j'e&jnfdNddNdOZzecdPd&dQdRgede{edPeee0j1e&jje&jke&jle&jme&j'e&jnfdNddTdUZ|eedVe}jdWdWe~edXeeee&jne&jje&jke-e0j1fdWg dXedee%fedYedZddd^d_ZeHd`d]eeddcddZeddhdiZedjegdhedjeeeee}eee~eeee2jddDeejdpdDedke)ddCdredqe)ddedle)ddmdrddodpZedqeedqeee2jddDddtduZeHdvdedvee&jddeddydzZed{e&j,e-fed{ed|eeedd}dWdWd~edeeedd}dWdWd~eeedqe)dddrdddZedee&j,e&je-e0j1fedgeR  dddZedee&j,e&je-e0j1fedgeede)dWdR  dddZdddZdddZdddZedee0j1fdNedeedee%fejdpdDedddZedee0j1fdNededee%fddDejdpdDedddZeHddedeedee%fdZdDdddZeHddedeedededWdWededWdWedddZeHddZedeIe?gdheeEdddZedeededeeeIdd dg dWddddZddÐdĄZdÐdǐdȄZedee0j1fdNededeeee0j1fdWg dXedeeeg dWd]dejddDejddDeejddDdĐdϐdЄZ			dŐdƐd֐dׄZedeedededWdWede)ddedeeeg dWd-dd d܍edeeeg dWd-dd d܍ejddDejddDdǐddZeedejddDejddDejddDedqe)dddredXeee&j,e-e.j/e0j1efdd}e%fdWdedee?eee)fe&je%fede)ddpd̐ddededdpdrededd]eh ddedeee0j1efdWg dXede)e%fdsdDedee)fddd deededdpeddhddȐddZdɐdʐddZededNeded e)dddːddZdd̐ddZedeeded	eeee-fdWg dXed
e)ddededdedeeedWg dddede)dddre2d͐ddZededNede`edΐddZededNede`edΐddZededNede`edΐddZededNede`edΐddZeHddփedejdNede`edϐd d!ZdАd"d#Zdѐd&d'ZdҐd)d*ZdӐd,d-ZeEed.eee?fgdhed.eejdZdDdԐd0d1Zed2eddedՐd3d4Zd fd5d6Zdd7d8Zdd9d:ZÐd;d< ZejƐd֐dאd@dAZejƐddؐdBdAZejƐdِdEdAZejƐd֐dڐdHdAZǐd֐dڐdIdAZedېdJdKZȐdܐdNdOZeHd?d]dPdQ ZʐdRdS ZːddTdUZ̐dVdW Z͐dXdY ZΐdZd[ Zϐdݐd^d_ZАdސd`daZedbeeIeeEeҐdߐdddeZedfeefeIgdheeEeՐddidjZedkeeddldmZeHdndedneeddodpZeddqdrZeHdsdedseIeddudvZeeHdwdedweeegdhddzd{Zۇ  ZS (  InterpreterNr   subprojectsF_buildbuild.BuildbackendT.Optional[Backend]r   r   subdirsubproject_dirdefault_project_options"T.Optional[T.Dict[OptionKey, str]]mockr   ast!T.Optional[mparser.CodeBlockNode]is_translatedrelaxations,T.Optional[T.Set[InterpreterRuleRelaxation]]user_defined_options T.Optional['argparse.Namespace']rx   r   c                   sj  t  |j || d| _|| _| jj| _| j | _|| _i | _	i | _
|tjjd | _|| _|
p6t | _|sG|d u rG|   |   n|d urR|| _|   | jdt| j| i g | _t | _d| _d| _i | _g | _i | _|r||  | _!ni | _!i | _"| #  | $  || _%t&i i | _'t() | _*tj+| j,tj-}|	s| j*.| |s| /  | 0  d S )Nr   mesonF)1superr   r   get_source_diractive_projectnamer	   Zget_coredatar   r   summaryr   splitospathr   Zsubproject_directory_namer   setr   Zload_root_meson_fileZsanity_check_astr   builtinupdater?   
generatorsprocessed_buildfilesproject_args_frozenglobal_args_frozenr   subproject_stackconfigure_file_outputscopyr   project_default_optionsbuild_func_dictbuild_holder_mapr   r   r   r   
OrderedSetbuild_def_filesr   r   build_filenameaddZparse_project_redetect_machines)r   r   r   r   r   r   r   r   r   r   r   r   r  	__class__r~   r   r     sP   


zInterpreter.__init__-T.Tuple[T.Tuple[object], T.Dict[str, object]]c                 C     t d)NzThis class is unpicklable)r   r   r~   r~   r   __getnewargs_ex__M     zInterpreter.__getnewargs_ex__c                 C  s   | j jj }t| jjj |_ | | j j_| j jjj jd us"J | j jjj	jd us-J | j jjj
jd us8J t| j jjj | | jd< t| j jjj	| | jd< t| j jjj
| | jd< d S )NZbuild_machineZhost_machineZtarget_machine)r	   r   machinesZmiss_defaultingZdetect_machine_infor   r   Zdefault_missingZcpuhosttargetOBJMachineHolderr   )r   r  r~   r~   r   r  P  s   zInterpreter._redetect_machinesc                 C  s  | j i d| jd| jd| jd| jd| jd| jd| jd| j	d	| j
d
| jd| jd| jd| jd| jd| jd| jd| ji d| jd| jd| jd| jd| jd| jd| jd| jd| jd| jd| jd| jd| jd| j d | j!d!| j"d"| j#i d#| j$d$| j%d%| j&d&| j'd'| j(d(| j)d)| j*d*| j+d+| j,d,| j-d-| j.d.| j/d/| j0d0| j1d1| j2d2| j3d3| j4| j5| j6| j7| j8| j9| j:| j;| j<| j=| j>d4
 d5t?j@v r| j d6| jAi d7t?j@v r| j d8| jBi d S d S )9Nadd_global_argumentsadd_global_link_argumentsadd_languagesadd_project_argumentsadd_project_dependenciesadd_project_link_argumentsadd_test_setupalias_targetassert	benchmarkboth_librariesbuild_targetconfiguration_dataconfigure_filecustom_targetdebugdeclare_dependency
dependencydisablerr   error
executablefilesZfind_libraryfind_program	generator
get_optionget_variablegettextimportinclude_directoriesinstall_datainstall_emptydirinstall_headersinstall_maninstall_subdirinstall_symlinkis_disableris_variablejar
join_pathslibrarymessageoptionprojectrangerun_command
run_targetset_variablestructured_sourcesr   )
shared_libraryshared_modulestatic_librarysubdir_doner   r   testunset_variablevcs_tagwarningZMESON_UNIT_TEST	exceptionZMESON_RUNNING_IN_PROJECT_TESTSexpect_error)Cfuncsr  func_add_global_argumentsfunc_add_global_link_argumentsfunc_add_languagesfunc_add_project_argumentsfunc_add_project_dependenciesfunc_add_project_link_argumentsfunc_add_test_setupfunc_alias_targetfunc_assertfunc_benchmarkfunc_both_libfunc_build_targetfunc_configuration_datafunc_configure_filefunc_custom_target
func_debugfunc_declare_dependencyfunc_dependencyfunc_disablerfunc_environment
func_errorfunc_executable
func_filesfunc_find_libraryfunc_find_programfunc_generatorfunc_get_optionfunc_get_variablefunc_gettextfunc_importfunc_include_directoriesfunc_install_datafunc_install_emptydirfunc_install_headersfunc_install_manfunc_install_subdirfunc_install_symlinkfunc_is_disablerfunc_is_variablefunc_jarfunc_join_pathsfunc_libraryfunc_messagefunc_optionfunc_project
func_rangefunc_run_commandfunc_run_targetfunc_set_variablefunc_structured_sourcesfunc_subdirfunc_shared_libfunc_shared_modulefunc_static_libfunc_subdir_donefunc_subprojectfunc_summary	func_testfunc_unset_variablefunc_vcs_tagfunc_warningr   environfunc_exceptionfunc_expect_errorr  r~   r~   r   r
  b  s   	
 !"#$%&'()*+,-./0123

>zInterpreter.build_func_dictc                 C  s  | j i ttjttjttjt	tj
ttjtjtjtjtjtjtjtjtjtjtjtjtjtjtjtjtjtj tj!tj"tj#tj$tj%tj&tj'i tj(tj)tj*tj+tj,tj-tj.tj/tj0tj1tj2tj3tj4tj5tj6tj7tj8tj9tj:tj;tj<tj=tj>tj?tj@tjAtjBtjCtDjEtFjGtHjItjJtKjLtjMtNjOtjPtjQtjRi 	 | jStHjTtjUtVtjWtDjXtFjYtZtj[t\tj]i dS )z
            Build a mapping of `HoldableObject` types to their corresponding
            `ObjectHolder`s. This mapping is used in `InterpreterBase` to automatically
            holderify all returned values from methods and functions.
        N)^
holder_mapr  r{   P_OBJZArrayHolderr   Z
DictHolderr   ZIntegerHolderr   ZBooleanHolderr   ZStringHolderZMesonVersionStringZMesonVersionStringHolderDependencyVariableStringZDependencyVariableStringHolderOptionStringZOptionStringHolderr   r}   r  Z
FileHolderr	   SharedLibraryZSharedLibraryHolderStaticLibraryZStaticLibraryHolderBothLibrariesZBothLibrariesHolderSharedModuleZSharedModuleHolder
ExecutableZExecutableHolderJarZ	JarHolderCustomTargetZCustomTargetHolderCustomTargetIndexZCustomTargetIndexHolder	GeneratorZGeneratorHolderGeneratedListZGeneratedListHolderExtractedObjectsZGeneratedObjectsHolder	RunTargetZRunTargetHolderAliasTargetZAliasTargetHolderHeadersZHeadersHolderManZ	ManHolderEmptyDirZEmptyDirHolderDataZ
DataHolderSymlinkDataZSymlinkDataHolder
InstallDirZInstallDirHolderIncludeDirsZIncludeDirsHolderEnvironmentVariablesZEnvironmentVariablesHolderStructuredSourcesZStructuredSourcesHolderr   Z	RunResultcompilerOBJZTryRunResultHolderr   ZExternalLibraryZExternalLibraryHolderr   UserFeatureOptionZFeatureOptionHolderr   ZMachineInfor  ConfigurationDataZConfigurationDataHolderbound_holder_mapr   ZDependencyHolderr   ZExternalProgramHolderCompilerZCompilerHolderr6   ZModuleObjectHolderr7   ZMutableModuleObjectHolderr  r~   r~   r   r    s   	 !"#$%&*	
zInterpreter.build_holder_map	held_typeT.Type[mesonlib.HoldableObject]holder_typeT.Type[ObjectHolder]c                 C  s   | j ||i dS )z
            Adds one additional mapping to the `holder_map`.

            The intended use for this function is in the `initialize` method of
            modules to register custom object holders.
        N)r  r  )r   r  r  r~   r~   r   append_holder_map  s   
zInterpreter.append_holder_mapinvalues2T.List[T.Union[TYPE_var, ExecutableSerialisation]]c                 C  s@  t |}|D ]}t|trtdt|tjtjtjfr$| |j	| qt|t
r/| | qt|tr@| j|_| jj| qt|tjrN| jj| qt|tjr\| jj| qt|tjrk| |jd  qt|tjry| jj| qt|tr| jj| qt|ttttttjt tj!frqtd|dd S )Nz%Modules must not return ObjectHoldersr   z(Module returned a value of unknown type .)"r   rz   r3   r)   r	   BuildTargetr  r  
add_targetnamer{   process_new_valuesr;   r   install_scriptsr   r  datar  symlinksr   InternalDependencysourcesr  install_dirsrB   testsr   r   r   r-   r  r   r  )r   r  r   r~   r~   r   r    s6   



zInterpreter.process_new_valuespvlocationmparser.BaseNodec                 C  s:   t tj|stjdtj d| |d|t j| j< d S )NzMeson version is z but project requires node)r   Zversion_comparer   r   r)   	from_nodeZproject_meson_versionsr   )r   r  r  r~   r~   r   handle_meson_version  s   z Interpreter.handle_meson_versionc                 C  sz   | j jsd S | j jd }t|tjsd S |jj D ] \}}t|tjs(J d|j	dkr:t|tj
r:| |j	| qd S )Nr   for mypymeson_version)r   linesrz   r   ZFunctionNoder   rp   r   ZIdNoderv   Z
StringNoder  )r   rG  kwvalr~   r~   r   handle_meson_version_from_ast  s   
z)Interpreter.handle_meson_version_from_astmesonlib.OrderedSet[str]c                 C     | j S N)r  r  r~   r~   r   get_build_def_files#     zInterpreter.get_build_def_filesfmesonlib.FileOrStringc                 C  s  t |tjr|jrd S tj| }nhtj|rz|	dszt
| j }t
| j }zt
| }W n. tyc   t
|}| }t|dr`|jtj@ dkr`|jtjkr`|j |j }n Y nw ||jv rkd S ||jv ru||}t|}nd S || jvr| j| d S d S )Nz/devst_file_attributesr   )rz   r   r}   is_builtr   r   normpathZrelative_nameisfile
startswithrl   r   r   get_build_dirresolveOSErrorstathasattrr  FILE_ATTRIBUTE_REPARSE_POINTst_reparse_tagZIO_REPARSE_TAG_APPEXECLINKparentr  parentsrelative_tor   r  r  )r   r  srcdirbuilddirZf_sr~   r~   r   add_build_def_file&  s<   






zInterpreter.add_build_def_fileT.Dict[str, InterpreterObject]c                 C  r  r  	variablesr  r~   r~   r   get_variablesI  r  zInterpreter.get_variablesc           
   
   C  s   t jg}| j r|t j |D ]^}| jjj| }| jj	| 
 D ]L}z
t||}W n	 ty7   Y q"w t|dkrItjdd| j| jd d|t ju i}|d }t| |g}|| |j|dd}	|	| jj| |< q"qd S )	Nr<   zstdlib without variable name0.56.0r  r   Z_stdlibT)Zforce_fallback)r   HOSTr   is_cross_buildr   BUILDr	   r   
propertiesr   keysr   ZstringlistifyZ
get_stdlibKeyErrorr|   r/   r   r   current_noder@   set_fallbacklookupstdlibs)
r   Zmachine_choicesfor_machinepropslZdirp   r  dfdepr~   r~   r   check_stdlibsL  s*   

zInterpreter.check_stdlibsr8  0.59.0)sincer  r   T.Tuple[str]rp   'kwtypes.FuncImportModule'ET.Union[ExtensionModule, NewExtensionModule, NotFoundExtensionModule]c              	   C  sV  |d }t || j\}}}|rt|S d}|dr?|dr2tjd| d|ddd	 d
|d |tdd	 d  }	d}n|}	|	| jv rK| j|	 S z
t	
d|	 }
W n tyl   |rftd| dt|	}Y nw |
| }t|ttfs{J | jj|	 |jjrtjd|jj |jj| j|d |jjrtjd|jj |jj| j|d |r|jjs|jjd u rtd|jj d|jjd ur|rtjd|jj d|jj| jd|d nFtjd|jj d|jj| jd|jj d
|d n,|jjr$|s|rtd|jj d|jj t|	}ntjd|jj d|dd || j|	< |S )Nr   F)z	unstable-	unstable_r  zImporting unstable modules as "z" instead of "_-r<   "r  unstableTzmesonbuild.modules.zModule "z" does not existzmodule zModule z4 has never been unstable, remove "unstable-" prefix.z has been stabilizedz,drop "unstable-" prefix from the module namez as stable modulezeConsider either adding "unstable-" to the module name, or updating the meson required version to ">= z<" has not been stabilized, and must be imported as unstable-zS has no backwards or forwards compatibility and might not exist in future releases.)r  fatal)rD   r   r9   r  r   deprecationreplacer|   r   	importlibimport_moduleImportErrorr*   Z
initializerz   r5   r8   r	   r   INFOZaddedr/   r   r  
deprecatedr0   r  Z
stabilizedrT  )r   r  r   rp   modnamedisabledr   r  Zexpect_unstableZreal_modnamemoduleZ
ext_moduler~   r~   r   ru  a  sj   	




""




zInterpreter.func_importr2  )varargsmparser.FunctionNodeT.Tuple[T.List[str]]'TYPE_kwargs'T.List[mesonlib.File]c                 C  s   |  |d S r   )source_strings_to_filesr   r  r   rp   r~   r~   r   rn       zInterpreter.func_filesr-  compile_argsT)r   defaultd_import_dirs0.62.0)r  r  	link_argsz0.46.00.54.0r  )r  Zsince_valuesr   objects1.1.0)r   r%  r  c                 C  sX  |d }|  |}|d }|d }|d }| |d }	|d }
|d }|d }|d	 }|d u r3| j}|d
 }|  |d}t| jj}| D ]C\}}zt|}W n	 tyZ   Y qGw |  sh|| j	 |j
v rhqG| r| r|| j |gtttj|j
 v rt|||< qG|D ]}t|tjstdqt|||
||||	|||||}|S )Nr   Z	link_with
link_wholer*  r  r$  r(  r  r   d_module_versionsr&  zInvalid dependency)extract_incdirsr!  r   rl   r   
source_dirr   
ValueErroris_subprojectr   r  is_absoluteis_dirroot_subdirr{   r   r   abspathr  r  rz   r   r   r)   r  )r   r  r   rp   depsZincsZlibsZ
libs_wholer*  r  r$  r(  r  r   r-  r&  r  r   r   pdr  r~   r~   r   rh    sH   
6

z#Interpreter.func_declare_dependencyr%  )optargsT.Tuple[bool, T.Optional[str]]c                 C  sj   |\}}|d u rt jdd| j|d |s3|d u r-ddlm} | }|jjd | |j}t	d| d S )Nz(assert function without message argument0.53.0r  r   )
AstPrinterr   zAssert failed: )
r/   r   r   r   r<  r   	argumentsacceptresultr)   )r   r  r   rp   rv   rE  r<  printerr~   r~   r   r`    s   zInterpreter.func_assertc                 C  s`   |d ur|t |krtd| dt | dt||D ]\}}|d ur-t||s-tdqd S )Nz	Expected z arguments, got r  zIncorrect argument type.)r|   r*   ziprz   )r   r   ZargcountZ	arg_typesactualwantedr~   r~   r   validate_arguments  s   
zInterpreter.validate_argumentsrI  check0.47.0capture)r%  r  0.50.0T.Tuple[T.Union[build.Executable, ExternalProgram, compilers.Compiler, mesonlib.File, str], T.List[T.Union[build.Executable, ExternalProgram, compilers.Compiler, mesonlib.File, str]]]'kwtypes.RunCommand'rC   c                 C     |  |||S r  )run_command_implr"  r~   r~   r   r    s   zInterpreter.func_run_commandin_builddirc                 C  s  |\}}|d }|d }| j  }	| j  }
|d }|d u r'tjtdd d}d}g }t|tjrR| jj	
 D ]\}}||krC|} nq7tdt||| t|trf| setd	| d
nRt|tjr| }|d }t|dd}| std|d
|}|dd  }n)t|tjr||	|
}tj|	| j}t|d|d}| std|d
|}|D ]c}t|tr|| qt|tjr|||	|
 qt|tr||  qt|tjrtj dd| j!|d t|j"d dd}| std|d
||  qt||j#| | $|  |D ]}tj%|s>tj|r8|
n|	| j|}| $| q't&||||	|
| j| j ' dg |||d
S )NrG  envrE  T)onceFzoProgram {!r} was overridden with the compiled executable {!r} and therefore cannot be used during configurationz;cmd was a built executable but not found in overrides tablezcommand z not found or not executabler   silentzProgram r<   )rQ  
search_dirzProgram or command z7Compiler object as a variadic argument to `run_command`0.61.0r  Z
introspect)rM  rE  rG  )(r   r   r  r   rT  implicit_check_false_warningrz   r	   r  find_overridesr   r   r)   r   descriptionr   foundget_namer   r  get_exelistr   r}   absolute_pathr   r   r   r   r   r   get_pathr/   r   r   exelistr  r  isabsrC   get_build_command)r   r  r   rp   rM  cmdZcargsrG  rN  r  r  rE  Zoverridden_msgZexpanded_argsr  exeZprognamer\  progrR  ar~   r~   r   rL  
  sz   





zInterpreter.run_command_implc                 C  r  )NzZGettext() function has been moved to module i18n. Import it and use i18n.gettext() insteadr)   r   nodesr   rp   r~   r~   r   rt  W  r  zInterpreter.func_gettextc                 C  r  )NzYTried to call option() in build description file. All options must be in the option file.rc  rd  r~   r~   r   r  Z  r  zInterpreter.func_option0.38.0)r%  r   re  kwtypes.SubprojectrA   c                 C  s.   |d |d |d d g d}|  |d d|S )Nr   r   r   )r   r   r   optionscmake_optionsr   r   )do_subproject)r   re  r   rp   r  r~   r~   r   r  ]  s   	zInterpreter.func_subproject	subp_namedisabled_featurery   rU  T.Optional[Exception]c                 C  s,   t t tj| j|||d}|| j|< |S )N)rl  rU  )rA   rF   r   r   r   r   r   )r   rk  rl  rU  subr~   r~   r   disabled_subprojectn  s
   
zInterpreter.disabled_subprojectr   Literal['meson', 'cmake']kwtypes.DoSubprojectc                 C  sv  t || j\}}}|r"tdt|ddt|d | j||dS t|d |}|dkr2td|d	 d
kr<tdd|v rDtdt	j
|rNtdt|rZtjd| jd || jv rr| j|g }d|}	td|	 d
|| jv r| j| }
|r|
 std|
j d|d r| jj| }|d }|dkst||d	 std| d| d| d|
S | jj}z|||}W n2 tjy } z%|st| tdt|dtdd | j||dW  Y d }~S |d }~ww t	j
| j |}t	jt	j
| jj  |dd  d| _!d| j|g }d!t|g}|d"kr/|d#t|g7 }tjg |d$R d%d&i z(|d"krK| "||||W S |d'krZ| #|||||W S t$d(| d)|  tym     t%y } zA|st&| tj'|t(d*d+ W d    n	1 sw   Y  td,t|dtdd | j||dW  Y d }~S |d }~ww )-N
Subprojectr   skipped: featurer  )rl  r   r   z"Subproject name must not be empty.r   r  z-Subproject name must not start with a period...z5Subproject name must not contain a ".." path segment.z-Subproject name must not be an absolute path.zJSubproject name has a path separator. This may cause unexpected behaviour.r  z => z"Recursive include of subprojects: zSubproject "z" required but not found.r   	undefinedSubproject  version is  but 
 required.zis buildable:r   z(disabling))rU  Texist_okz
Executing subprojectr   r   r   nestedFcmakezThe method z is invalid for the subproject z
Exception:)prefixz
Subproject))rD   r   r   r   r   ro  r   create_options_dictr)   r   r   r]  r   rT  r  r  r   r+   r   rW  r   r	   r   version_compare_manyr   wrap_resolverr  r   ZWrapExceptionr   r   makedirsr  r  _do_subproject_meson_do_subproject_cmaker   	Exceptionr|  rU  Zyellow)r   rk  r   rp   r  r   featurer   Z	fullstackZincpathr   r  rC  rr   e
subdir_absstackr   r~   r~   r   rj  u  s    




 


zInterpreter.do_subprojectr   T.Dict[OptionKey, str]r  T.Optional[T.List[str]]c	                 C  s  t |V | j }	t|	| j||| j||||| jd
}
| j|
_| j	|
_	| j
|
_
| j|
_| j|
_| j|g |
_| j}t j}dt _|
  t j}|t _t dt |d W d    n1 s^w   Y  t   |d r|
j}|d }|dks~t||d std| d| d	| d
|| _| j|
j t|
||d| j|< |r| j| | j|
j | j|
j |
j| jj|< | j| S )N)r   r   r   r   r   rr  z	finished.r   ru  rv  rw  rx  ry  )warnings)r   r|  r	   r  r   r   r   r   r   r   r  r  r   r  r   Zlog_warnings_counterrunr   r   r   r   r  r)   r  rA   r  merge)r   rk  r   r   rp   r   r  r   r   	new_buildZsubiZcurrent_activeZcurrent_warnings_counterZsubi_warningsr  rC  r~   r~   r   r    sH   

z Interpreter._do_subproject_mesonr  c                 C  s  t | | j }| jjtd j}ddlm	} |d p | }	|d |	j
 }
t|t|t|t||j| j}||
 |  ||	j}t   t da t d ddlm}m} |d	d
}||  || |  tj| jj |d}t|ddd}||j W d    n1 sw   Y  t d| t  | t   W d    n1 sw   Y  | j!|||||dd |j"D d	t#j$hd}||_%W d    n1 sw   Y  t   |S )Nr~  r   )CMakeSubprojectOptionsrh  ri  z	cmake-astzProcessing generated meson AST)AstIndentationGeneratorr<  T)Zupdate_ast_line_nosmeson.buildwutf-8encodingzBuild file:c                 S     g | ]}t |qS r~   r   )r   r  r~   r~   r   r         z4Interpreter._do_subproject_cmake.<locals>.<listcomp>)r   r   )&r   r|  r	   r  r   rh  r   rv   Zmodules.cmaker  ri  r:   rl   r   r   Z
initialiseZanalyseZpretend_to_be_mesonZtarget_optionsr   r   r  r<  r>  Zpost_processr   r   r   r  openwriter?  Zcmd_ci_includer  Zbs_filesr   r   Zcm_interpreter)r   rk  r   r  r   rp   r  r~  r  rh  ri  Zcm_intr   r  r<  r@  Zmeson_filenamer  r?  r~   r~   r   r    sL   
"





	+z Interpreter._do_subproject_cmakeoptnamecoredata.UserOptionc           	      C  sL  t |j| jd}| s=| jjtjfD ]'}|	|}|d u s#|j
r*|	| }|d ur<t|tjs8J d|  S qzW| jj| }|j
r|jr| | jjv r| jj|  }t|t|u rg|}|W S |jjdd  d d  }|jjdd  d d  }tjd||| j|| jd |W S  ty   Y nw td|d)	Nr   r     izOption {0!r} of type {1!r} in subproject {2!r} cannot yield to parent option of type {3!r}, ignoring parent value. Use -D{2}:{0}=value to set the value for this option manually.r  zTried to access unknown option r  )r   Zfrom_stringevolver   Z
is_projectr   rh  r   Zbase_optionsgetZyieldingZas_rootrz   r   typer  r   lowerr   rT  r   r  r  r)   )	r   r  keyoptsr   optZpoptZopt_typeZ	popt_typer~   r~   r   get_option_internal#  s8   
zInterpreter.get_option_internalr5  (T.Union[coredata.UserOption, 'TYPE_var']c                 C  sp   |d }d|v rt d| |}t|tjr||_|S t|tjr6t|jtr3t	
|jd| dS |jS |S )Nr   r   zuHaving a colon in option name is forbidden, projects are not allowed to directly access options of other subprojects.{})r)   r  rz   r   r  r  r   rv   r   r  r  )r   re  r   rp   r  r  r~   r~   r   rr  F  s   
zInterpreter.func_get_optionr)  'T.Tuple[T.Optional[T.Dict[str, T.Any]]]build.ConfigurationDatac                 C  sf   |d }|d ur.t jdd| j|d | D ]\}}t|tttfs-td|d|dqt	
|S )Nr   zconfiguration_data dictionary0.49.0r  4"configuration_data": initial value dictionary key "$"" must be "str | int | bool", not "r  )r/   r   r   r   rz   r   r   r   r*   r	   r  )r   r  r   rp   Zinitial_valuesr   r   r~   r~   r   rd  Y  s   
z#Interpreter.func_configuration_datac                 C  s   | j d urd S | jtd}ddl m} ||| j| | _ | j d u r+td| d|| j jkr`| j j	drCt
dt
| j j | jjsStd| d	| j j | jjtd| j jd
d | jjrj| j| dd | jj D }| j| d S )Nr   r   )backendszUnknown backend "".vsz$Auto detected Visual Studio backend:zBackend changed from z to T)first_invocationc                 S  s   i | ]\}}|  r||qS r~   )Z
is_backendr   r~   r~   r   
<dictcomp>|  s    z+Interpreter.set_backend.<locals>.<dictcomp>)r   r   r5  r   r  Zget_backend_from_namer	   r)   r  r  r   r   r   r   r  r   Z
set_optionZinit_backend_optionsrh  r   set_options)r   r   r  rh  r~   r~   r   set_backendf  s"   

zInterpreter.set_backendrG  r  ru  c                 C  s   t | tr	| d S | S r   rz   r{   r   r~   r~   r   <lambda>  r   zInterpreter.<lambda>)r%  	validator	convertorlicenselicense_files)r%  r   r  )r%  T.Tuple[str, T.List[str]]'kwtypes.Project'c                 C  s  |\}}d|v rt d|d|d r| |d | tj| j| jd}tj| j| jd}tj|rWtj|rMtj||rIt	
d ntdtd	d
| jd n|}tj|rvt| j}|| | j|j | | t|d | j| _| jjs| jdkr| j| jjvr| j }	|	| j | j| j | jj| j ni }	| j |	| j| j | ! s|| j"_#|| _$|d }
t%|
t&j'r$tjdd| j|d | |
 |
(| jj)| jj*}zt+|j,dd-d}W n t.y   t/dw t0|dkr|d dkr|dd }t0|dkrt/d|d | _1n|
| _1| j"j1d u r3| j1| j"_1|d d u rGdg}|d rFt dn|d }g }| 2|d D ]}|(| jj)| jj*}|3||f qTt"4| j1||| j| j"j5|< | j| j"j6v rt7d|d }t%|t8st/d tj9|rt/d!|:d"rt/d#d$|v rt/d%| ! s|| _;| j;| j"_;| j<t=d&}| ! r|t>j?krtj| j|}t@A| jB || j|}| ! r| jjCD| n|| j_C|| j"j6| j< t	Ed't	F| t	Ed(t	F| j1 | ! s0| j<t=d)}| j<t=d*}|p*|:d+}t&G| | H|d,tIjJ | H|d-tIjK | L  | ! sO| M  d S d S ).Nr   zProject name z must not contain ':'r  zmeson.optionszmeson_options.txtz`Not warning about meson.options with version minimum < 1.1 because meson_options.txt also existszJmeson.options and meson_options.txt both exist, but are not the same file.zmeson.options filez1.1zUse meson_options.txt insteadr   r   r   zversion from filer   r  r  r  r   zVersion file not found.r   r<   r   z3Version file must contain exactly one line of text.r  unknownr  zDProject `license` name must be specified when `license_files` is setzSecond call to project().r   zSubproject_dir must be a stringz,Subproject_dir must not be an absolute path.r  z,Subproject_dir must not begin with a period.rt  z/Subproject_dir must not contain a ".." segment.	wrap_modezProject name:zProject version:r   vsenvr  TF)Nr*   r  r   r   r   source_rootr   existssamefiler   r,  r   r/   r   r   r
   ZOptionInterpreterprocessr   Zupdate_project_optionsrh  r  r  r	  r   r  Zinitialized_subprojectsr  r  r   Zinit_builtinsr  Zset_default_optionsr1  r	   r   r   rz   r   r}   rZ  r/  	build_dirrl   	read_textr   FileNotFoundErrorr)   r|   r   r!  r   ZDepManifestZdep_manifestZprojectsr+   r   r]  r  r   r5  r   r   Z	nopromoter   ZResolverr   r  Zmerge_wrapsr   r   Zsetup_vsenvr  r   r  r  r  r  )r   r  r   rp   Z	proj_nameZ
proj_langsZoption_fileZold_option_fileZoir   r   ZifnameZver_dataZproj_licenseZproj_license_filesr   Z	spdirnamer  r   r  r   r  Zforce_vsenvr~   r~   r   r    s   


 













zInterpreter.func_projectr  r   'kwtypes.FuncAddLanguages'c              	   C  s   |d }t || j\}}}|d }|r.t|tjdD ]}	tdt|	dt|d qdS |d ur<| ||| 	|S t
| j}
t
|
drOtjd	|d
 | |dtj}|| ||tjM }|S )Nr   r   r  Compiler for languagers  r  Fr)  zXadd_languages is missing native:, assuming languages are wanted for both host and build.r  )rD   r   sortedr   
sort_clinkr   r   r   r  machine_from_native_kwargr/   get_target_versioncheck_versionrT  r   r  r  )r   r  r   rp   langsr  r   r  r   langtvsuccessr~   r~   r   rZ    s"    zInterpreter.func_add_languagesc                 C  s<   t |dkrtjdd| j|d dd |D }| | d S )Nr<   z#message with more than one argumentr)  r  c                 S  r  r~   r   r   r   r~   r~   r   r   6  r  z,Interpreter.func_message.<locals>.<listcomp>)r|   r/   r   r   message_implr   r  r   rp   Zargs_strr~   r~   r   r  1  s   zInterpreter.func_messagec                 C  s   t jt dg|R   d S )NzMessage:)r   r   r   r   r   r~   r~   r   r  9  s   zInterpreter.message_implr   r;  r   r   r   <T.Tuple[T.Union[str, T.Dict[str, T.Any]], T.Optional[T.Any]]'kwtypes.Summary'c                 C  sh   |d d u rt |d tstd|d }nt |d ts!td|d |d i}| |d || d S )Nr<   r   z*Summary first argument must be dictionary.z&Summary first argument must be string.r   )rz   r   r)   r   summary_impl)r   r  r   rp   r   r~   r~   r   r  <  s   
zInterpreter.func_summaryc                 C  sJ   | j | jvrt| j| j| j| j < | j| j  |||d |d | j  d S )Nr   r   )r   r   r   r   r   r   )r   r   r   rp   r~   r~   r   r  Q  s
   zInterpreter.summary_implc           
      C  s^  t  }t| j D ]1\}}| }|jr |d|jdg}n|jr+|t|jg}n|j	dkr8||j	 dg}|||< q|rI| 
d|ddd | jrt  }| jjrZ| jj|d	< | jjrd| jj|d
< t| jj }|dd |D  |r| 
d|dd d td | jdd }t| j D ]\}}	| j|  r|	  q|r|  d S d S )NzFeature z	 disabledr   z	 warningsZSubprojectsTr   )r   r   zCross fileszNative filesc                 S  s   i | ]	\}}t ||qS r~   r  r   r~   r~   r   r  p      z.Interpreter._print_summary.<locals>.<dictcomp>zUser defined optionsFr   )r   OrderedDictr  r   r   rW  rl  rU  r   r  r  r   Z
cross_fileZnative_fileZcmd_line_optionsr  r   r   r   popr   )
r   Zall_subprojectsr  Zsubprv   r   Zsorted_optionsZmain_summaryrk  r   r~   r~   r   _print_summaryW  sF   


zInterpreter._print_summaryrT  z0.44.0c                 C  sB   t |dkrtjdd| j|d dd |D }tj|d|i d S )Nr<   z#warning with more than one argumentr)  r  c                 S  r  r~   r   r  r~   r~   r   r     r  z,Interpreter.func_warning.<locals>.<listcomp>r  )r|   r/   r   r   r   rT  r  r~   r~   r   r  |  s   zInterpreter.func_warningc                 C  s@   t |dkrtjdd| j|d dd |D }tdd| )	Nr<   z!error with more than one argumentr   r  c                 S  r  r~   r   r  r~   r~   r   r     r  z*Interpreter.func_error.<locals>.<listcomp>zProblem encountered: r   )r|   r/   r   r   r)   r   r  r~   r~   r   rl    s   zInterpreter.func_errorr,  0.63.0c                 C  s$   dd |D }t jdg|R   d S )Nc                 S  r  r~   r   r  r~   r~   r   r     r  z*Interpreter.func_debug.<locals>.<listcomp>zDebug:)r   r,  r  r~   r~   r   rg    s   zInterpreter.func_debugc                 C  r  )Nzunit test traceback :))RuntimeErrorr"  r~   r~   r   r    s   zInterpreter.func_exceptionrV  rt   r4   c                 C  s    G dd dt }||d | jS )Nc                      s&   e Zd Zd
 fddZdd	 Z  ZS )z8Interpreter.func_expect_error.<locals>.ExpectErrorObjectmsgr   r   rx   r   c                   s   t  | || _d S r  )r   r   r  )r   r  r   r  r~   r   r     s   
zAInterpreter.func_expect_error.<locals>.ExpectErrorObject.__init__c                 S  sL   |d u rt dt|tjr$t|}|| jkr"t d| jd|dS d S )Nz+Expecting an error but code block succeededzExpecting error z	 but got T)r)   rz   r   r   r   r  )r   exc_typeZexc_valZexc_tbr  r~   r~   r   __exit__  s   
zAInterpreter.func_expect_error.<locals>.ExpectErrorObject.__exit__)r  r   r   r   rx   r   )r   r   r   r   r  __classcell__r~   r~   r  r   ExpectErrorObject  s    r  r   )r4   r   )r   r  r   rp   r  r~   r~   r   r    s   zInterpreter.func_expect_errorT.List[str]r   r  r   c                 C  s.   |  |||}| j s| j  |   |S r  )add_languages_forr   r  Z$copy_build_options_from_regular_onesr  )r   r   r   r  r  r~   r~   r   r    s
   

zInterpreter.add_languagesc                 C  sL   | j jjdd}t|tstd|tjkr|sdS | j 	 s$|s$dS |S )NZskip_sanity_checkFz+Option skip_sanity_check must be a boolean.)
r   r  r  r  rz   r   r)   r   r  r  )r   r  Zshouldr~   r~   r   should_skip_sanity_check  s   
z$Interpreter.should_skip_sanity_checkc                 C  sH  dd |D }t | j|  }|| d|v r-d|vr-tjdd| j| jd |d d|v r<tjd	d
| j| jd d}t	|tj
dD ]}|| j| v rOqE| }| jj| |}|sz+t| j||}|d u rstd| d| |r~td n
|| j | j W n tjy   |stdt|d|d d}Y qE w | jri }	| D ]}
t| jj|
 }|
j| jd}
||	|
< q| j|	||| j |tj ks| j! rtj}ntj"}||# d|dtd$|% |&  |j'd ur||# d|dtd$|j'% |j'j(|j'j) | j*+| || j| |< qE|S )Nc                 S  s   g | ]}|  qS r~   )r  r   rb  r~   r~   r   r     r  z1Interpreter.add_languages_for.<locals>.<listcomp>ZvalaczAdding Vala language without Cr  r  nasmzAdding NASM languager   Tr  zTried to use unknown language "r  z8Cross compiler sanity tests disabled via the cross file.r  zfor thezmachine not found.Fr  zcompiler for thezmachine:r   zlinker for the),r   r   r  r  r/   r   r   r  r   r  r  Zget_lower_case_namer   r  Zdetect_compiler_forr   r*   r  r   Zlog_onceZsanity_checkget_scratch_dirr   r   r   r   Zget_optionsr  rh  r  Zadd_compiler_optionsr   r  r  r,  Zget_display_languager   rY  Zget_version_stringZlinkeridr   r	   Zensure_static_linker)r   r   r   r  r  r  r  Zmachine_namecomprh  r   r   Z
logger_funr~   r~   r   r    sj   



 zInterpreter.add_languages_for	prognamesT.List[mesonlib.FileOrString]T.Optional[ExternalProgram]c                 C  sP   |D ]#}t |tjrqt |tstdt| j||}t |ts%|  S qd S )Nz Executable name must be a string)	rz   r   r}   r   r)   r   Zfrom_bin_listr   r   )r   r  r  r7  ra  r~   r~   r   program_from_file_for  s   

z!Interpreter.program_from_file_forsearch_dirs
extra_infoT.List[mlog.TV_Loggable]c           	      C  s   t j| j | j}|D ]W}t|tjr5|j	r$t j| j
 |j}nt j| j |j}|j}g }nt|tr?|}|}ntd|t|||dd}| rd|dd|  d |  S qd S )Nz1find_program only accepts strings and files, not T)rR  extra_search_dirsrQ  (r   ))r   r   r   r   r   r   rz   r   r}   r  r  fnamer   r*   r   rW  r   get_command)	r   r   r  r  r/  ZexenamerR  r  Zextprogr~   r~   r   program_from_system
  s2   
zInterpreter.program_from_systemcommand_namesT.List['mlog.TV_Loggable']GT.Optional[T.Union[ExternalProgram, OverrideProgram, build.Executable]]c                 C  sJ   |D ] }t |ts
q|| jjv r"| jj| }|td |  S qd S )Nz(overridden))rz   r   r	   rU  r   r   Zblue)r   r  r  r  r`  r~   r~   r   program_from_overrides'  s   
z"Interpreter.program_from_overridesc                 C  s&   |D ]}t |tr| jj| qd S r  )rz   r   r	   searched_programsr  )r   r  r  r~   r~   r   store_name_lookups3  s
   
zInterpreter.store_name_lookupsr  r`  =T.Union[build.Executable, ExternalProgram, 'OverrideProgram']c                 C  sH   || j jv rtd| d|| j jv rtd| d|| j j|< d S )Nz)Tried to override finding of executable "z" which has already been found.zTried to override executable "z$" which has already been overridden.)r	   r  r)   rU  )r   r  r`  r~   r~   r   add_find_program_override8  s
   z%Interpreter.add_find_program_overrider   c                   s   t d fdd|D S )Nr   c                   s.   g | ]}t |tr|n	| jj jjqS r~   )rz   r   rZ  r   r/  r  r  r  r~   r   r   A  s    &z0Interpreter.notfound_program.<locals>.<listcomp>)r   r   r  r~   r  r   notfound_program?  s
   
zInterpreter.notfound_programrQ  rC  T.Union[str, T.List[str]]version_func`T.Optional[T.Callable[[T.Union['ExternalProgram', 'build.Executable', 'OverrideProgram']], str]]AT.Union['ExternalProgram', 'build.Executable', 'OverrideProgram']c                 C  s  t |}g }| |||||}	|	d u r| |}	t|	trC|	 sC|s4tdt	|	
 dtd |rAd}
t|
|	
 |	S |r|rL||	}n#t|	tjrj|	jr]| j|	j j}n| }t|tsfJ |j}n|	| }t ||\}}}|stjdt	|	jdtddt|dt	ddd	 |D g|R   |rd
}
t|
|	j||| |S |dt| | | |stjdt	|	jdtdg|R   t|	tjrd|	_|	S )NProgramzfound:r   z(Program {!r} not found or not executablerW  z	but need:r   c                 S  s   g | ]}d | d qS )r   r~   )r   r  r~   r~   r   r   l  s    z1Interpreter.find_program_impl.<locals>.<listcomp>z6Invalid version of program, need {!r} {!r} found {!r}.r   r   T)r   r   program_lookupr  rz   r   rW  r   r   r   rX  r   r)   r   r	   r  r   r   Zheld_objectr   r   get_versionr  r  r   r   insertr  r   Zwas_returned_by_find_program)r   r   r  r   rQ  rC  r  r	  r  progobjr   r   ZinterpZis_foundZ	not_foundr  r~   r~   r   find_program_implF  sR   

 



&zInterpreter.find_program_implGT.Optional[T.Union[ExternalProgram, build.Executable, OverrideProgram]]c           
      C  s   |  ||}|r
|S d }| jtd}|tjkr$| jjr$| jj|}|r3|tj	kr3| 
||||S | ||}|d u rD| |||}|d u r_|d dr_tdtjdd}	|	 r]|	nd }|d u ro|ro|ro| 
||||}|S )Nr  r   Zpython3TrP  )r  r   r5  r   r   Z
nofallbackr   r  Zfind_program_providerZforcefallbackfind_program_fallbackr  r  endswithr   r   Zpython_commandrW  )
r   r   r  r   r  r  r  r   r  ra  r~   r~   r   r  {  s$   zInterpreter.program_lookupr   c              
   C  sL   t dt |dt d| |g g g d d}| |d| | ||S )NzFallback to subprojectzwhich provides programr   )r   r   r   ri  rh  r   )r   r   r   r   rj  r  )r   r   r   r   r  Z	sp_kwargsr~   r~   r   r    s   z!Interpreter.find_program_fallbackr3  r<   )r  Zmin_varargsr  dirs0.52.0&T.Tuple[T.List[mesonlib.FileOrString]]'kwtypes.FindProgram'?T.Union['build.Executable', ExternalProgram, 'OverrideProgram']c              	   C  sv   t || j\}}}|r&tdtd|d dt|d | |d S t|}| j|d |d |d|d |d	S )
Nr  r   r   rs  r  r   Fr   )r   rQ  rC  r  )	rD   r   r   r   r   r   r  rE   r  )r   r  r   rp   r  r   r  r  r~   r~   r   rp    s   (zInterpreter.func_find_programc                 C  r  )Na  find_library() is removed, use meson.get_compiler('name').find_library() instead.
Look here for documentation: http://mesonbuild.com/Reference-manual.html#compiler-object
Look here for example: http://mesonbuild.com/howtox.html#add-math-library-lm-portably
)r+   r"  r~   r~   r   ro    r  zInterpreter.func_find_libraryr.  r   r   r   r   r   )r   r   r   r/  0.40.0r   c                 C  s  dd |d D }t |dkrtdd| j |d}|d ur*t|ts*td|d	}|d
}t| |||}|	| |dd}	t|	t
sOtdz||}
W n tyf   |	re| |	g  w t|
tsnJ |
 sz|	rz| |	g d|v r|d }t|t
std|
 }||krtd|d  d| d|  |
|}
|
jd ur|
j\}}td|
jd|| j|| |
jD ]	}|| j| q|
S )Nc                 S  s   g | ]}|r|qS r~   r~   )r   nr~   r~   r   r     r  z/Interpreter.func_dependency.<locals>.<listcomp>r   r<   z"dependency with more than one name0.60.0r   z)"allow_fallback" argument must be booleanr   r   r   r   z'The not_found_message must be a string.r   z)The `include_type` kwarg must be a stringzCurrent include type of z is z. Converting to requested zdep z custom lookup)r|   r/   user   r  rz   r   r*   r@   r  r   r  r  r  r   rW  get_include_typer   r,  Zgenerate_system_dependencyZfeature_sincer   r  Zfeaturechecks)r   r  r   rp   namesr   r   r   r  r   r8  rC  rB  r   Z	extra_msgr  r~   r~   r   ri    sJ   





 



zInterpreter.func_dependencyc                 C  s   t  S r  )r-   r"  r~   r~   r   rj       zInterpreter.func_disablerr1  0.42.0ZimplibZwin_subsystemZgui_appzUse 'win_subsystem' instead.)Zextra_message'T.Tuple[str, T.List[BuildTargetSource]]build.Executablec                 C     |  |||tjS r  )r(  r	   r  r"  r~   r~   r   rm    s   zInterpreter.func_executablerO  build.StaticLibraryc                 C  r$  r  )r(  r	   r  r"  r~   r~   r   r       zInterpreter.func_static_librM  build.SharedLibraryc                 C  s   |  |||tj}d|_|S NT)r(  r	   r  Zshared_library_only)r   r  r   rp   Zholderr~   r~   r   r    s   zInterpreter.func_shared_libr'  build.BothLibrariesc                 C  rK  r  )build_both_librariesr"  r~   r~   r   rb       zInterpreter.func_both_librN  z0.37.0build.SharedModulec                 C  r$  r  )r(  r	   r  r"  r~   r~   r   r    s   zInterpreter.func_shared_modulerD  c                 C  rK  r  )build_libraryr"  r~   r~   r   r  #  r+  zInterpreter.func_libraryrB  GT.Tuple[str, T.List[T.Union[str, mesonlib.File, build.GeneratedTypes]]]	build.Jarc                 C  r$  r  )r(  r	   r  r"  r~   r~   r   r  *  r&  zInterpreter.func_jarr(  r,  Zoverride_optionswT.Union[build.Executable, build.StaticLibrary, build.SharedLibrary, build.SharedModule, build.BothLibraries, build.Jar]c                 C  s   d|vrt d|d}|dkr| |||tjS |dkr'| |||tjS |dkr>tjdd| j|d | |||tj	S |d	krK| |||tj
S |d
krV| |||S |dkra| |||S |dkrn| |||tjS t d)Nr   z$Missing target_type keyword argumentr1  rM  rN  z*build_target(target_type: 'shared_module')z0.51.0r  rO  r'  rD  rB  zUnknown target_type.)r)   r  r(  r	   r  r  r/   r   r   r  r  r*  r-  r  )r   r  r   rp   r   r~   r~   r   rc  1  s,   
zInterpreter.func_build_targetrS  r   commandreplace_stringz	@VCS_TAG@T.List['TYPE_var']'kwtypes.VcsTag'build.CustomTargetc                 C  s  |d d u rt jdd| j|d |d p| j}|d }d}|d }tjtj| j	 | j
}|rkt|d ttjfr`t|d tjrNt jd	d
| j|d | j|d dd}	|	 r_|	|d< n-t jdd| j|d n"t|}
|
rtd|
d |
d  |
d  }|
d }ndg}| t|d dk|d d | j dddd||||g | }tj|d d | j
| j| j|| |d |d ddd	}| |j| |S )Nr   zOptional fallback in vcs_tag0.41.0r  r3  z(.*)r2  r   z'vcs_tag with file as the first argumentr'  Fr1  zGvcs_tag with custom_tgt, external_program, or exe as the first argumentr  zFound {} repository at {}r  Zwc_dirZget_revZ	rev_regexr   inputr<   outputrS  z
--internalZ	vcstaggerz@INPUT0@z	@OUTPUT0@T)build_by_defaultbuild_always_stale)r/   r   r   r   r   r   r  r   r   r   r   rz   r   r   r}   r  rW  Z
detect_vcsr   r   r   r   _validate_custom_target_outputsr|   r^  r	   r  r!  r  r  )r   r  r   rp   r   r3  Zregex_selectorZvcs_cmdr/  ZmaincmdZvcsr_  tgr~   r~   r   r  O  sb   



zInterpreter.func_vcs_tagrP  rs   
T.NoReturnc                 C  s   t  r  )r,   r"  r~   r~   r   r    r   zInterpreter.func_subdir_donehas_multi_inoutputsT.Iterable[str]c                 C  s0   |D ]}| rd|v sd|v rt | dqdS )zChecks for additional invalid values in a custom_target output.

        This cannot be done with typed_kwargs because it requires the number of
        inputs.
        @PLAINNAME@
@BASENAME@zt: output cannot contain "@PLAINNAME@" or "@BASENAME@" when there is more than one input (we can't know which to use)N)r*   )r?  r@  r  outr~   r~   r   r<    s
   z+Interpreter._validate_custom_target_outputsr+  feedconsole0.48.0'kwtypes.CustomTarget'c                 C  s  |d rd|d v sd|d v rt jdd| j|d | |d }|d }|d	 }|d
 d ur9|d	 d ur9td|d u rD|d rDd}n|d
 d urV|d u rR|d
 }|d }|d u r\d}|d u rbd}|d }|d u rvt jdd| j|d d}| j|d dd}|d }	|	rt|	d tr| |	d g|	d< t	|dkr|d rt
dt	|d dkr|d rt
d|d r|d rt
d|	D ]$}
|d rt|
trd|
v rt
d|d rt|
trd |
v rt
d!q|d r|d" st
d#t	|d" dkrt jd$d%| j|d t	|d& ddt	|d hvr)t
d't	|d&  d(t	|d  d)|d D ]}| | q-| t	|dk|d d* tj|| j| j| j|	||d f|||d |d |d+ |d |d, |d- |d |d |d" ||d& | jd.}| |j| |S )/NdepfilerC  rB  z&substitutions in custom_target depfilerF  r  install_moder:  r;  Zbuild_alwayszLCustomTarget: "build_always" and "build_always_stale" are mutually exclusiveinstallTFr   z%custom_target() with no name argumentr  r   r8  )strictr2  r<   rE  zKcustom_target: "feed" keyword argument can only be used with a single inputr9  rG  zOcustom_target: "capture" keyword argument can only be used with a single outputrF  zOcustom_target: "capture" and "console" keyword arguments are mutually exclusive@OUTPUT@zHcustom_target: "capture" keyword argument cannot be used with "@OUTPUT@"z@INPUT@zDcustom_target: "feed" keyword argument cannot be used with "@INPUT@"install_dirzQcustom_target: "install_dir" keyword argument must be set when "install" is true.z&multiple install_dir for custom_targetr  install_tagzcustom_target: install_tag argument must have 0 or 1 outputs, or the same number of elements as the output keyword argument. (there are z install_tags, and z	 outputs)r+  depend_filesdependsrN  )r;  r:  rG  rF  rP  rI  Zextra_dependsrN  rE  rK  rN  rJ  rO  r   )r/   r   r   _warn_kwarg_install_mode_stickyr)   r!  rz   r   r  r|   r*   validate_forbidden_targetsr<  r	   r  r   r   r   r  r  )r   r  r   rp   rJ  r:  r;  r  inputsr2  r  tr=  r~   r~   r   rf    s     


zInterpreter.func_custom_targetrJ  'kwtypes.RunTarget'build.RunTargetc              
   C  s   |d   }t|D ]}t|tr| std|jq
t|d tr/| |d g|d< |d }t	
|||d | j| j| j|d }| || |S )Nr2  z%Tried to use non-existing executable r   rQ  rN  )r  r   rz   r   rW  r)   r  r   r  r	   r  r   r   r   r  )r   r  r   rp   all_argsr   r  r=  r~   r~   r   r    s   	zInterpreter.func_run_targetr$  "T.Tuple[str, T.List[build.Target]]build.AliasTargetc                 C  s0   |\}}t ||| j| j| j}| || |S r  )r	   r  r   r   r   r  )r   r  r   rp   r  r6  r=  r~   r~   r   r_  -  s   zInterpreter.func_alias_targetr4  r=  )Zallow_empty)r   r   r9  z0.43.03T.Tuple[T.Union[build.Executable, ExternalProgram]]'kwtypes.FuncGenerator'build.Generatorc                 C  s   |d D ]}d|vrd|vrt dt|rt dqt|d dkr2|d D ]
}d|v r1t dq'tj|d	 fi |}| j| |S )
Nr9  rC  rB  zAEvery element of "output" must contain @BASENAME@ or @PLAINNAME@.z0"output" must not contain a directory separator.r<   rM  z:Tried to use @OUTPUT@ in a rule with more than one output.r   )r*   r   r|   r	   r  r  r   )r   r  r   rp   Zruleogenr~   r~   r   rq  7  s   zInterpreter.func_generatorr&  RT.Tuple[str, T.Union[build.Executable, build.Jar, ExternalProgram, mesonlib.File]]'kwtypes.FuncBenchmark'c                 C     |  |||d d S NFadd_testr"  r~   r~   r   ra  Q     zInterpreter.func_benchmarkrQ  is_parallel'kwtypes.FuncTest'c                 C  rb  r(  rd  r"  r~   r~   r   r  X  rf  zInterpreter.func_testUT.Union[build.EnvironmentVariables, T.Dict[str, 'TYPE_var'], T.List['TYPE_var'], str]build.EnvironmentVariablesc                 C  s@   | d}|d u rt S t|}|rtd| t|S )NrN  z"env": )r  r	   r  rV   r  r*   r  )r   rp   Zenvlistr  r~   r~   r   unpack_env_kwarg_  s   


zInterpreter.unpack_env_kwarg'kwtypes.BaseTest'rB   c           
      C  s4  |d }d|v rt jd| d|d |dd}|d }t|tr+| s*tdnt|tjr7| 	|g}| 
|}|d	 dkrLtjd
d| j|d |  rS| jn| jj}g }|d D ]}	|	red|	 }	||dddd|	  q]t|||||d |dd|d ||d |d	 |d |d |d |d S )Nr   r   z!":" is not allowed in test name "z ", it has been replaced with "_"r  r  r<   z3Tried to use not-found external program as test exetimeoutztest() timeout <= 0r   suiter   rQ  rg  Fr   Zshould_failZworkdirZprotocolpriorityverbose)r   r  r  rz   r   rW  r*   r   r}   r  rk  r/   r   r   r1  r	   r   r   rB   r  )
r   r  r   rp   r  r`  rN  Zprjrn  r  r~   r~   r   	make_testh  sJ   

 
zInterpreter.make_testT.Listr   is_base_testc                 C  sb   |  |||}|r| jj| tdt|jd d S | jj| tdt|jd d S )NzAdding testTzAdding benchmark)	rq  r	   r  r   r   r,  r   r  
benchmarks)r   r  r   rp   rs  rU  r~   r~   r   re    s   zInterpreter.add_testr<  (T.Tuple[T.List['mesonlib.FileOrString']]'kwtypes.FuncInstallHeaders'build.Headersc                 C  s   |  |d }| |d }|d }|d ur,|d d ur tdtj|r+td nd}t	t
}g }|d rM|D ]}	tj|	j}
||
 |	 q;n|d | |D ]!}t|| tj|||d || j}|| | jj| qV|S )	NrJ  r   r   rN  zXinstall_headers: cannot specify both "install_dir" and "subdir". Use only "install_dir".z[Subdir keyword must not be an absolute path. This will be a hard error in the next release.r   preserve_path)rR  r!  r)   r   r   r]  r   r  r   r   r{   dirnamer  r   extendr	   r  r   r   headers)r   r  r   rp   rJ  Zsource_filesr>  r  Zret_headersfilery  childdirhr~   r~   r   ry    s2   


z Interpreter.func_install_headersr=  localer   'kwtypes.FuncInstallMan'	build.Manc           	   
   C  s   |  |d }| |d }|D ].}zt|ddd }W n ttfy+   d}Y nw d|  kr9dks>td tdqt||d || j	|d	 }| jj
| |S )
NrJ  r   r  r<   r   	   z?Man file must have a file extension of a number between 1 and 9rN  r  )rR  r!  r   rsplit
IndexErrorr0  r*   r	   r  r   Zmanr   )	r   r  r   rp   rJ  r  r  numr   r~   r~   r   rz    s$   

zInterpreter.func_install_manr;  r  rO  c                 C  s0   t |d |d | j|d }| j j| |S )Nr   rJ  rO  )r	   r  r   Zemptydirr   )r   r  r   rp   r8  r~   r~   r   rx    s   z!Interpreter.func_install_emptydirr?  rS  Zsymlink_namepointing_torN  build.SymlinkDatac                 C  s>   |d }|d }t |||d | j|d }| j j| |S )Nr   r  rN  rO  )r	   r  r   r  r   )r   r  r   rp   r  r  r  r~   r~   r   r|    s   
z Interpreter.func_install_symlinkrL  0T.Tuple[object, T.Optional[T.Dict[str, object]]]build.StructuredSourcesc           	      C  s  t tjtjtjtjtjf}tt	}t
|d D ](}t||s*tdt| dt|t r:tj| jj| j|}|d | q|d rd|d v rPtd|d  D ]2\}}t
|D ](}t||sptdt| dt|t rtj| jj| j|}|| | q_qVt|S )Nr   zstructured_sources: type "z" is not validr   r<   zKstructured_sources: keys to dictionary argument may not be an empty string.)r   r   r}   r	   r  r  r  r   r   r{   r   rz   r*   r  from_source_filer   r/  r   r   r   r  )	r   r  r   rp   Zvalid_typesr  argr   r   r~   r~   r   r    s(   





z#Interpreter.func_structured_sourcesif_foundc                 C  s   t dd | D sdS d S )Nc                 s  s    | ]}t |d V  qdS )rW  N)r  r   r~   r~   r   	<genexpr> 	  s    'Interpreter.<lambda>.<locals>.<genexpr>z"Objects must have a found() method)all)rb  r~   r~   r   r   	  r  )r  r  r%  r   'kwtypes.Subdir'c              
   C  s.  t | d|d v rtd| jdkr|d | jkrtd| jdkr/|d dr/td|d dkr9td|d	 D ]	}| sF d S q=| j}tj	||d }tj
|r]td
tj	| j |}tj|}tj	|d}	|	| jv rtd| d| j|	 || _tjtj	| jj|dd tj	| jtj}
| j|
 tj	| j |
}tj|s|| _td|
dt|dd}| }W d    n1 sw   Y  t|tsJ z
t|| }W n t jy } z||_|d }~ww z| | W n
 t y   Y nw || _d S )Nrt  r   zSubdir contains ..r   zIMust not go into subprojects dir with subdir(), use subproject() instead.meson-zJThe "meson-" prefix is reserved and cannot be used for top-level subdir().zJThe argument given to subdir() is the empty string ''. This is prohibited.r  z(Subdir argument must be a relative path.r  zTried to enter directory "z"", which has already been visited.Trz  zNonexistent build file 'r   r  r  )!r   check_direntry_issuesr*   r   r   r  rW  r   r   r   r]  r   r   realpathr  r  r  r  r  r  r  r)   r  readrz   r   r   Parserparser   r|  Zevaluate_codeblockr,   )r   r  r   rp   r   Zprev_subdirr   ZabsdirZsymlinkless_dirZ
build_fileZbuildfilenameZabsnamer  codeZ	codeblockmer~   r~   r   r  	  s`   



zInterpreter.func_subdirT.Optional[FileMode]c                 C  s   | dd d u r
d S t|d tr|d S g }t| dg ttf}|D ]}|du r-d }|| q%t|dkr=t	dt|dkrT|d d urTt|d tsTt	dt| S )NrJ  F   z8Keyword argument install_mode takes at most 3 arguments.r   zRKeyword argument install_mode requires the permissions arg to be a string or false)
r  rz   r   r   Ztypeslistifyr   r   r   r|   r*   )r   rp   rJ  moder   r~   r~   r   _get_kwarg_install_modeT	  s"   z#Interpreter._get_kwarg_install_moder  r   c                 C  sT   |j dkr(|j tj@ r(tjd| jd t|j tj dd  }t||j|j	S |S )Nr   zfinstall_mode with the sticky bit on a file does not do anything and will be ignored since Meson 0.64.0r  r<   )
permsr  S_ISVTXr   r  r  filemoder   ownergroup)r   r  r  r~   r~   r   rR  n	  s   z+Interpreter._warn_kwarg_install_mode_stickyr:  r  renamer   'kwtypes.FuncInstallData'
build.Datac                 C  s   |  |d |d  }|d pd }|r*t|t|kr*tdt| dt| d| |d }| j||d |||d	 |d
 dS )Nr   r  r  z_"rename" and "sources" argument lists must be the same length if "rename" is given. Rename has z elements and sources has r  rJ  rN  rO  rx  )rx  )r!  r|   r*   rR  install_data_impl)r   r  r   rp   r  r  rJ  r~   r~   r   rw  w	  s    zInterpreter.func_install_datarJ  taginstall_dir_nameinstall_data_typerx  c	                 C  s   |pd}	|p	|	p	d}
t |
tjr|
j}
tt}g }|r0|D ]}tj	|j
}|| | qn|d | | D ] \}}t|tj|	|tj|
||| j|||}|| q;| jj| |S )z+Just the implementation with no validation.r   z	{datadir})rz   r  r  r  r   r   r{   r   r   ry  r  r   rz  r   r	   r  r   r   r  )r   r  rN  rJ  r  r  r  r  rx  idir	idir_namer  Zret_datar|  ry  r}  r2  r8  r~   r~   r   r  	  s&   
zInterpreter.install_data_implr>  strip_directoryexclude_filesc                 C     t dd | D rdS d S )Nc                 s      | ]	}t j|V  qd S r  r   r   r]  r   r8  r~   r~   r   r  	      r  cannot be absoluteanyr  r~   r~   r   r  	  r  )r%  r   r  r  exclude_directoriesc                 C  r  )Nc                 s  r  r  r  r  r~   r~   r   r  	  r  r  r  r  r  r~   r~   r   r  	  r  'kwtypes.FuncInstallSubdir'build.InstallDirc           	      C  s   t |d t |d f}tj| jj| j|d }tj|r&tt	|s:t
jdd| j|d tdd| jd| | |d	 }|d
 }t|tjrN|j}tj| j|d |d
 ||||d | j|d d	}| jj| |S )Nr  r  r   z#install_subdir with empty directoryrF  r  r  zAIt worked by accident and is buggy. Use install_emptydir instead.rJ  rN  r  rO  )rO  )r   r   r   r   r   r/  r   isdirr  scandirr/   r   r   r0   rR  rz   r  r  r  r	   r  r  r   )	r   r  r   rp   excluder  rJ  r  r  r~   r~   r   r{  	  s0   
zInterpreter.func_install_subdirr*  z0.47.0,r7  )r   configurationr  zUse fs.copyfile instead)r%  r  r  Zdeprecated_messager  r  r   r   >   zcmake@r   r}  )r%  r  r  r8  rK  c                 C  s   | du rdS d S )NTzmust be `false` if booleanr~   r  r~   r~   r   r  	  s    )r%  r  output_formatr  r  T.List[TYPE_var]kwtypes.ConfigureFilec           ,        s
  t  fdddD }t|}|dkrtd|dkr"tdj| |dkr-td	j|  d
 r9 d s9td|  d } d } d } d }	|  d }
g }|
D ]}t|tj	rr|
|| jj| jj | | qWtd d }|rt|d }t|g|}|d }|	rt|	g|d }	tj| j|}|| jv rtj| jd}| d| j }d|| j| }tdt|dd|d| n| j| j|< tjtj| j|\}}tj| jj||} d d ur d }t|tr)tjdd| j|d |  D ]\}}t|t!t"t#fs"td|d |d!q
t$%|}t&d"t|d# t|
d$kr>td%|
rtj'tj| jj| jdd&  d' }t(|d ||||| j\}}|rd(d)d t |D }tjd*| d+|
d  d,|d |rtj)|d }t*| j}t+|d-rtjd.|d/|d nt,||| d|_-n d d ur}t|
d$krtjd0d1| j|d t||g}|	rtj| j. |	}	|	|d2< t d |} t&d"t|d3 | ^}!}| /||!|fddt$0 d4d}" d
 rC|d5 }# d' }t1|#d6|d7}|2|"j3 W d    n	1 s-w   Y  |r=t45|d |# t6||# |	r|t&d8t|	 t1|	d9d7}t7|8 }$|$9|}%|%D ]}&| |& qcW d    n	1 sww   Y  n' d: rt|d$krtd;tj'tj| jj| jdd& t4:|d |  d< }'|'d=u rd>}'t;jd?d@| jdA|d  dB d urň dB n|'d>k}(|(r|'stdC|'})t|)t<j=r|)j>})tj	?||}* dD }+| j$j@
t$jA|*g|'|)|| j|+dEdF tj	?| j|S )GNc                 3  s     | ]} | d vr|V  qdS )rc  Nr~   r   ro   r~   r   r  	  s    
z2Interpreter.func_configure_file.<locals>.<genexpr>)r  r2  r  r   zbMust specify an action with one of these keyword arguments: 'configuration', 'command', or 'copy'.r   zXMust not specify both {!r} and {!r} keyword arguments since they are mutually exclusive.r  z]Must specify one of {!r}, {!r}, and {!r} keyword arguments since they are mutually exclusive.rG  r2  z=configure_file: "capture" keyword requires "command" keyword.rJ  r   r  rI  r8  z*Inputs can only be strings or file objectsr9  r  r   z{}:{}zOutput fileTzfor configure_file() atz%overwrites configure_file() output atr  z'configure_file.configuration dictionaryr  r  r  r  r  ZConfiguringzusing configurationr<   z6At most one input file can given in configuration moderz  r  r   c                 s  s    | ]}t |V  qd S r  )repr)r   r   r~   r~   r   r  J
  s    zThe variable(s) z in the input file 'z2' are not present in the given configuration data.rF  zVGot an empty configuration_data() object and found no substitutions in the input file z_. If you want to copy a file to the build dir, use the 'copy:' keyword argument added in 0.47.0z#multiple inputs in configure_file()r  z	@DEPFILE@zwith command)rG  rE  rN  ~r  r  zReading depfile:r  r  z1Exactly one input file must be given in copy moderN  Fr   z!configure_file install_dir: falserH  z Use the `install:` kwarg insteadrK  zJ"install_dir" must be specified when "install" in a configure_file is truerO  	configure)rO  Z	data_type)Br  r|   r)   r   r*   rR  r!  rz   r   r}   r   rZ  r   r/  r  r  Zget_filenames_templates_dictZsubstitute_valuesr   r   r   r   r  Zcurrent_linenor   rT  r   r   r   r/   r   r   r   r   r   r   r	   r  r   r  Zdo_conf_filebasenamer  r  Zdump_conf_headerusedr  rL  r  r  
writelinesstdoutr   copymodeZreplace_if_differentr   	readlinesZget_all_dependenciescopy2r0   r  r  r  Zfrom_built_filer  r  ),r   r  r   rp   actionsZnum_actionsrJ  fmtr  rI  rT  Z
inputs_absr  r9  r   r@  Zofile_rpathZmesonbuildfileZcurrent_callZ
first_callZ
ofile_pathZofile_fnameZ	ofile_absZconfr   r   file_encodingZmissing_variablesZconfdata_uselessZvar_listZifbaser  Z_cmdr_  resZdst_tmpr  r6  r  r  rK  r  cfilerO  r~   ro   r   re  	  s  '





zInterpreter.func_configure_filer9  r  c                 C  s   t ||}|dkr%|D ]}t|tr$tjdd| jd|d| jd  nqg }|D ] }t|tjr7|	| q)t|trF|	| 
|g q)td|S )Nr9  z(include_directories kwarg of type stringrH  zUse include_directories(z	) insteadr  zRInclude directory objects can only be created from strings or include directories.)r   rz   r   r/   r   r   r  r	   r  r   build_incdir_objectr)   )r   rp   r  Zprospectivesr   r?  r7  r~   r~   r   r.  
  s"   


zInterpreter.extract_incdirs	is_system 'kwtypes.FuncIncludeDirectories'build.IncludeDirsc                 C  s   |  |d |d S )Nr   r  )r  r"  r~   r~   r   rv  
  s   z$Interpreter.func_include_directoriesincdir_stringsc              
   C  s  t |ts	td| j }| j }tj|| j	}tj|| j	}|D ]V}|
|r3ttdz	| | j	| W n tyX   tjd| jd ttd|d Y nw tj||}tj||}	tj|s{tj|	s{td| dq%t| j	||}
|
S )	NzIs_system must be boolean.a                      Tried to form an absolute path to a dir in the source tree.
                    You should not do that but use relative paths instead, for
                    directories that are part of your project.

                    To get include path to any directory relative to the current dir do

                    incdir = include_directories(dirname)

                    After this incdir will contain both the current source dir as well as the
                    corresponding build dir. It can then be used in any subdirectory and
                    Meson will take care of all the busywork to make paths work.

                    Dirname can even be '.' to mark the current directory. Though you should
                    remember that the current source and build directories are always
                    put in the include directories by default so you only need to do
                    include_directories('.') if you intend to use the result in a
                    different subdirectory.

                    Note that this error message can also be triggered by
                    external dependencies being installed within your source
                    tree - it's not recommended to do this.
                    z&include_directories sandbox violation!r  zF                        The project is trying to access the directory aG   which belongs to a different
                        subproject. This is a problem as it hardcodes the relative paths of these two projects.
                        This makes it impossible to compile the project in any other directory layout and also
                        prevents the subproject from changing its own directory layout.

                        Instead of poking directly at the internals the subproject should be executed and
                        it should set a variable that the caller can then use. Something like:

                        # In subproject
                        some_dep = declare_dependency(include_directories: include_directories('include'))

                        # In subproject wrap file
                        [provide]
                        some = some_dep

                        # In parent project
                        some_dep = dependency('some')
                        executable(..., dependencies: [some_dep])

                        This warning will become a hard error in a future Meson release.
                        zInclude dir z does not exist.)rz   r   r*   r   r   r  r   r   r   r   r  textwrapdedentvalidate_within_subprojectr)   r   rT  r  printr  r	   r  )r   r  r  src_rootZ
build_rootZabsbase_srcZabsbase_buildrb  Z
absdir_srcZabsdir_buildr   r~   r~   r   r  
  s0   



zInterpreter.build_incdir_objectr#  exe_wrappergdbtimeout_multiplierexclude_suites
is_default'kwtypes.AddTestSetup'c                 C  s  |d }t d|d u rtdd|vr#| jr| jn| jj d| }g }|d D ]}t|tr6|| q)|	 s>td||
 7 }q)|d }|dkrVtdd	| j |d
 rm| jjd urit| jjd|| j_t||d ||d |d | jj|< d S )Nr   z0([_a-zA-Z][_0-9a-zA-Z]*:)?[_a-zA-Z][_0-9a-zA-Z]*z4Setup name may only contain alphanumeric characters.r   r  z"Tried to use non-found executable.r  z(add_test_setup() timeout_multiplier <= 0r   r  zC is already set as default. is_default can be set to true only oncer  rN  r  )re	fullmatchr)   r   r	   r   rz   r   r   rW  r  r/   r  Ztest_setup_default_nameZ	TestSetupZtest_setups)r   r  r   rp   Z
setup_namer  r   r  r~   r~   r   r^  
  s,   
zInterpreter.func_add_test_setupr  'kwtypes.FuncAddProjectArgs'c                 C  $   |  || jj|d  |d | d S Nr   r   )_add_global_argumentsr	   Zglobal_argsr"  r~   r~   r   rX       $z%Interpreter.func_add_global_argumentsr  c                 C  r  r  )r  r	   Zglobal_link_argsr"  r~   r~   r   rY    r  z*Interpreter.func_add_global_link_argumentsr   c                 C  r  r  )_add_project_argumentsr	   projects_argsr"  r~   r~   r   r[  "  r  z&Interpreter.func_add_project_argumentsr"  c                 C  r  r  )r  r	   projects_link_argsr"  r~   r~   r   r]  '  r  z+Interpreter.func_add_project_link_argumentsr!  (T.Tuple[T.List[dependencies.Dependency]]c              
   C  s   |d }|d D ]}|| j | vrtd| dqt|d D ]V}t| }| dk}| D ])}	|d D ]"}| jj | | }
|		| j
 | j
 D ]}||
|| qOq9q3| || jj| || | || jj| | | q!d S )Nr   r   zFadd_project_dependencies() called before add_language() for language "r  r   system)r   r+   r   Zget_leaf_external_dependenciesr{   Zget_compile_argsr  Zget_include_dirsr   Zto_string_listr   r   r  rz  Zget_include_argsr  r	   r  r  Zget_link_args)r   r  r   rp   r  r  r8  r$  Zsystem_incdirr   r  r  r~   r~   r   r\  ,  s$   z)Interpreter.func_add_project_dependenciesc                 C  s   d}d}|D ]n}||v rt jd| d| jd q||v r*t jd| d| jd q|dkr;t jd| d| jd q|d	krLt jd
| d| jd q|dr^t jd| d| jd q|dsh|drtt jd| d| jd qd S )N)z/W1z/W2z/W3z/W4z/Wallz-Wallz-Wextra)z-O0z-O2z-O3z-Osz-Ozz/O1z/O2z/OszCConsider using the built-in warning_level option instead of using "r  r  zAConsider using the built-in optimization level instead of using "z-Werrorz<Consider using the built-in werror option instead of using "z-gz;Consider using the built-in debug option instead of using "z
-fsanitizezDConsider using the built-in option for sanitizers instead of using "z-std=z/std:zSConsider using the built-in option for language standard version instead of using ")r   rT  r  r  )r   r   Zwarnargsr9  r  r~   r~   r   _warn_about_builtin_argsA  s:   
z$Interpreter._warn_about_builtin_argsargsdictT.Dict[str, T.List[str]]c                 C  s@   |   rd|j d}t|| jp| j}| ||||| d S )Nz
Function 'a  ' cannot be used in subprojects because there is no way to make that reliable.
Please only call this if is_subproject() returns false. Alternatively, define a variable that
contains your language-specific arguments and add it to the appropriate *_args kwarg in each target.)r1  	func_namer+   r  r  _add_arguments)r   r  r  r   rp   r  frozenr~   r~   r   r  \  s
   z!Interpreter._add_global_arguments%T.Dict[str, T.Dict[str, T.List[str]]]c                 C  s2   | j |vr
i || j < | ||| j  | j|| d S r  )r   r  r  )r   r  r  r   rp   r~   r~   r   r  i  s
   

z"Interpreter._add_project_argumentsargs_frozenc                 C  sJ   |rd|j  d}t|| | |d D ]}||g | ||< qd S )NzTried to use 'zr' after a build target has been declared.
This is not permitted. Please declare all arguments before your targets.r   )r  r+   r  r  )r   r  r  r  r   rp   r  r  r~   r~   r   r  p  s   
zInterpreter._add_argumentsr   HT.Tuple[T.Union[None, str, T.List['TYPE_var'], T.Dict[str, 'TYPE_var']]]c                 C  s   |d }|d urDt jdd| j|d t|}|r td| t|tr:tdd |	 D r:t jdd	| j|d t
||d
 |d S t S )Nr   z environment positional argumentsr  r  z"environment": c                 s  s    | ]
}t |tr|V  qd S r  r  r  r~   r~   r   r    s    z/Interpreter.func_environment.<locals>.<genexpr>z"List of string in dictionary valuer'  r   	separator)r/   r   r   rV   r  r*   rz   r   r  r   rj   r	   r  )r   r  r   rp   initr  r~   r~   r   rk  |  s   
 zInterpreter.func_environmentrC  c                 C  s   |d }t jjdg|dd  R  dd}t jj| dd}t|d tjr1d|vr1t|S t|d tjrIt j|d j|}t||S |S )Nr   r   r<   \/rt  )	r   r   r   r  rz   r  r  r  r  )r   r  r   rp   partsotherretr  r~   r~   r   r    s   $
zInterpreter.func_join_pathsc                   s`   t    tdttt| jj t	
| j t
| j |  s.|   |   d S d S )NzBuild targets in project:)r   r  r   r   r   r   r|   r	   targetsr/   reportr   r0   r1  print_extra_warningsr  r  r  r~   r   r    s   
zInterpreter.runc                 C  s2   | j jj D ]}| dkr|    d S qd S )NZclang)r   r   r  r   get_idcheck_clang_asan_lundef)r   r  r~   r~   r   r    s   z Interpreter.print_extra_warningsc                 C  s   t d| jjvr
d S t d| jjvrd S | jjt d jrB| jjt d jdkrD| jjt d j}tjtd| d| jd d S d S d S )NZb_lundefZ
b_sanitizenonez"                    Trying to use z sanitizer on Clang with b_lundef.
                    This will probably not work.
                    Try setting b_lundef to false instead.r  )	r   r   rh  rv   r   rT  r  r  r  )r   rv   r~   r~   r   r    s   

z#Interpreter.check_clang_asan_lundefc                   s  t jjt jj t|tjr%d fdd}t |}||r%d S t tj	t ||}tj
|r:d}nd}tjjv rI |jv rId S |jvrPd S t j}|j }||krad S ||jvrrtd	| d
|j d||ks{||jv rtd	| d
|j dd S )Nfpathrl   rx   r   c              	     sz   t  }jjD ]}|jD ]}|t|  qqfddjjD }| |v r,dS |D ]}t| 	|r: dS q.dS )Nc                   s   g | ]
}t t |jqS r~   )r   rl   Zsource_subdirr   r  )r  r~   r   r     s    z]Interpreter.validate_within_subproject.<locals>.validate_installable_file.<locals>.<listcomp>TF)
r   r	   r  r  r  rl   rZ  r  r   r  )r   Zinstallablefilesr8  r  Zinstallabledirsr  r   r  r~   r   validate_installable_file  s   
zIInterpreter.validate_within_subproject.<locals>.validate_installable_file	directoryr|  z!Sandbox violation: Tried to grab r   z outside current (sub)project.z from a nested subproject.)r   rl   rx   r   )rl   r   r/  r  rz   r  r  r   r   r5  r  r   r   r   r  r4  r   r)   r  )r   r   r  r  ZnormZ	inputtypeZproject_rootr   r~   r  r   r    s0   


z&Interpreter.validate_within_subprojectT.List['mesonlib.FileOrString']rL  T.List['mesonlib.File']c                 C     d S r  r~   r   r  rL  r~   r~   r   r!       z#Interpreter.source_strings_to_filesc                 C  r  r  r~   r  r~   r~   r   r!    r	  <T.List[T.Union[mesonlib.FileOrString, build.GeneratedTypes]]4T.List[T.Union[mesonlib.File, build.GeneratedTypes]]c                 C  r  r  r~   )r   r  r~   r~   r   r!    r	  T.List['SourceInputs']T.List['SourceOutputs']c                 C  r  r  r~   r  r~   r~   r   r!    r	  c              	   C  s   t | t|ts|g}g }|D ]c}t|trJ|s4|| j r4|| t	j
d|d| jd q| | j| |t j| jj| j| qt|t jrV|| qt|tjtjtjtjtjtjfrm|| qtd|d|S )a/  Lower inputs to a list of Targets and Files, replacing any strings.

        :param sources: A raw (Meson DSL) list of inputs (targets, files, and
            strings)
        :raises InterpreterException: if any of the inputs are of an invalid type
        :return: A list of Targets and Files
        zSource item zq cannot be converted to File object, because it is a generated file. This will become a hard error in the future.r  zSource item is z& instead of string or File-type object)r   r  rz   r{   r   r  r   r  r   r   rT  r  r  r   r}   r  r/  r	   r  r  r  r  r  r  r)   )r   r  rL  resultsr  r~   r~   r   r!    s,   



c                 C  sJ   |  dr	td|  drd| vrtd| tjv r#td|  dd S )Nzmeson-internal__zcTarget names starting with 'meson-internal__' are reserved for Meson's internal use. Please rename.r  r  zvTarget names starting with 'meson-' and without a file extension are reserved for Meson's internal use. Please rename.zTarget name 'z6' is reserved for Meson's internal use. Please rename.)r  r*   r   ZFORBIDDEN_TARGET_NAMES)r  r~   r~   r   rS    s   

z&Interpreter.validate_forbidden_targetstobjbuild.Targetc                 C  s.  | j jdkr
td|dkrtd| dkrtdt|rHtj| jtj	|d }tj
tj| j|rHttd| d| d	| | | }|| jjv r_td
| dt|tjr{| }| |d|j || | | || jj|< || jjvrtt   | jj|< d S d S )Nr  zOInstall-only backend cannot generate target rules, try using `--backend=ninja`.r   zTarget name must not be empty.z0Target name must not consist only of whitespace.r   z                    Target "z," has a path segment pointing to directory "z". This is an error.
                    To define a target that builds in that directory you must define it
                    in the meson.build file in that directory.
            zTried to create target "z,", but a target of that name already exists.T)!r   r  r)   stripr   r   r   r   r   r   r  r  r*   r  r  rS  r  r	   r  r+   rz   r  Zprocess_compilersr  r  Zprocess_compilers_lateadd_stdlib_infor   Ztarget_guidsr   uuidZuuid4upper)r   r  r  ZpathsegZidnameZmissing_languagesr~   r~   r   r  &  s6   


zInterpreter.add_targetc                 C  s   |  |||tj}|  |||tj}| jjdkrd}n|j}|r?|jt	||j
|jg  g |_
g |_dd |j D |_t||S )NZxcodeFc                 S  s    i | ]\}}|t jv r||qS r~   )r   Zclink_langsr   r~   r~   r   r  `       z4Interpreter.build_both_libraries.<locals>.<dictcomp>)r(  r	   r  r  r   r  Zpicr*  r   r  r  Z	generatedr   r   r  )r   r  r   rp   Z
shared_libZ
static_libZreuse_object_filesr~   r~   r   r*  F  s   z Interpreter.build_both_librariesc                 C  sp   | j td| jd}|dkr| |||tjS |dkr%| |||tjS |dkr0| |||S t	d| d)Ndefault_libraryr  sharedr   ZbothzUnknown default_library value: r  )
r   r5  r   r   r(  r	   r  r  r*  r)   )r   r  r   rp   r  r~   r~   r   r-  d  s   zInterpreter.build_libraryc                   s  t ddg dt dddgt dddgt ddd	gd
d }|| ||| |\}}| |}d|v r=|t|d 7 }tdd |D rPtdd| jd| tdd |D rctdd| jd| dd |D }| |}t|d}	t|d|d< | 	||d< d|v rt|d}
| |
|d< | 
tj| j| j|  tjtjtjtjtjhvrtdt  td| |  fdd| D }g }t }|D ]}t|tjr|| }q|| q|sd }nJ|j  D ]D}t! }|D ]<}t|trtj"|g}nt|t#j$r|j%g}n|& }|'|}|r,t(j)dd t*| |d!|+| qq| ,||d"<  || j| j||||	| j-| j.| |
}| j/|_/| 0|| d#| _1|S )$Nzbuild targetr!  )Zrust_crate_typeZbuild_rpathZimplicit_include_directoriesr7  Z	rust_argsrf  r:  rG  Zgnu_symbol_visibilityc                 S  s   dS r(  r~   r"  r~   r~   r   build_target_decorator_callerp  s   z?Interpreter.build_target.<locals>.build_target_decorator_callerr  c                 s      | ]	}t |tjV  qd S r  )rz   r	   r  r  r~   r~   r   r  }  r  z+Interpreter.build_target.<locals>.<genexpr>z4passing references to built targets as a source filer+  zoconsider using `link_with` or `link_whole` if you meant to link, or dropping them as otherwise they are ignoredc                 s  r  r  )rz   r	   r  r  r~   r~   r   r    r  zpassing object files as sourceszTpass these to the `objects` keyword instead, they are ignored when passed as sourcesc                 S  s"   g | ]}t |tjtjfs|qS r~   )rz   r	   r  r  r  r~   r~   r   r     s    
z,Interpreter.build_target.<locals>.<listcomp>r*  r   rJ  Zextra_fileszUnknown target type:zUnreachable codec                   s    i | ]\}}| j v r||qS r~   )Zknown_kwargsr   targetclassr~   r   r    r  z,Interpreter.build_target.<locals>.<dictcomp>z+Conflicting sources in structured sources: r   r  r9  T)2r1   r  r   r  r0   r   r   r!  r   r  check_sources_existr   r   r   r  r   r	   r  r  r  r  r  r   r,  r   r  kwarg_strings_to_includedirsr   r  rz   r   r  r   r   r  r   r}   r  get_outputsintersectionr*   r  r  r  r.  r   r   r   r  r  )r   r  r   rp   r  r  r  r  r  ZobjsZefZsrcsstructr  r   r@  r  r^  Z	conflictsr  r~   r  r   r(  o  s   







zInterpreter.build_targetc                 C  s   d|v rKt |d}g }|D ]6}t|tr?tj|| j	 r?t
jd| jd tj|tj| j	 | j}| |g}|| q||d< d S d S )Nr&  z}Building a path to the source dir is not supported. Use a relative path instead.
This will become a hard error in the future.r  )r   r   rz   r   r   r   r  r  r   r   r   rT  r  relpathr   r   r  r   )r   rp   r   Zcleaned_itemsr   r~   r~   r   r    s   
 z(Interpreter.kwarg_strings_to_includedirsc                 C  s8   |j  D ]}| jj|j |d }|r|| qd S r  )r   r  r	   r   r  r  Zadd_deps)r   r  r  r  r~   r~   r   r    s   
zInterpreter.add_stdlib_infoc                 C  sD   |D ]}t |ts
qtj||}tj|std| dqd S )Nz&Tried to add non-existing source file r  )rz   r   r   r   r   r  r)   )r   r   r  r  r  r~   r~   r   r    s   
zInterpreter.check_sources_existbuildtargetmesonlib.HoldableObjectc                 C  s   | j |j kr
tdd S )Nz5Tried to extract objects from a different subproject.)r   r)   )r   r"  r~   r~   r   validate_extraction  s   zInterpreter.validate_extractionc                 C  s
   | j dkS )Nr   r  r  r~   r~   r   r1    s   
zInterpreter.is_subprojectrK  T.Tuple[str, object]c                 C  s   |\}}| j ||dd d S )NT)Z	holderify)rK  )r   r  r   rp   varnamerv   r~   r~   r   r    s   zInterpreter.func_set_variabler6  3T.Tuple[T.Union[str, Disabler], T.Optional[object]]
'TYPE_var'c                 C  s\   |\}}t |tr|S z| j| W S  ty%   |d ur#| | Y S Y nw td| d)NzTried to get unknown variable "r  )rz   r-   r  r  Z
_holderifyr)   )r   r  r   rp   r&  r   r~   r~   r   rs    s   
zInterpreter.func_get_variablerA  c                 C  s   |d | j v S r   r  r"  r~   r~   r   r~    r#  zInterpreter.func_is_variablerR  c                 C  s6   |d }z| j |= W d S  ty   td| dw )Nr   z!Tried to unset unknown variable "r  )r  r  r)   )r   r  r   rp   r&  r~   r~   r   r    s   zInterpreter.func_unset_variablec                 C  s.   |  dd}t|tstd|rtjS tjS )Nr   Fz'Argument to "native" must be a boolean.)r  rz   r   r*   r   r  r  )rp   r   r~   r~   r   r    s   
z%Interpreter.machine_from_native_kwargr@  T.Tuple[object]c                 C  s   t |d tS r   )rz   r-   r"  r~   r~   r   r}    s   zInterpreter.func_is_disablerrH  .T.Tuple[int, T.Optional[int], T.Optional[int]]P_OBJ.RangeHolderc                 C  sj   |\}}}|d u r|}d}|d u rd}|dk rt d||k r#t d|dk r+t dtj|||| jdS )Nr   r<   zstart cannot be negativezstop cannot be less than startzstep must be >=1r  )r)   r  ZRangeHolderr   )r   r  r   rp   startstopstepr~   r~   r   r    s   
zInterpreter.func_range)
Nr   r   r   NFNFNN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rx   r   )rx   r  )rx   r   )r  r  r  r  rx   r   )r  r  rx   r   )r  r   r  r  rx   r   )rx   r  )r  r  rx   r   )rx   r  )r  r  r   r	  rp   r
  rx   r  )r  r  r   r  rp   r  rx   r   )r  r  r   r:  rp   r  rx   r   )r  r  r   rI  rp   rJ  rx   rC   F)
r  r  r   rI  rp   rJ  rM  r   rx   rC   )re  r  r   r	  rp   rg  rx   rA   )NN)rk  r   rl  ry   rU  rm  rx   rA   )rk  r   r   rp  rp   rq  rx   rA   )NNFN)rk  r   r   r   r   r  rp   rq  r   r   r  r  r   r   r   r   rx   rA   )rk  r   r   r   r  r   r   r  rp   rq  rx   rA   )r  r   rx   r  )re  r  r   r	  rp   r  rx   r  )r  r  r   r  rp   r  rx   r  )r  r  r   r  rp   r  rx   r   )r  r  r   r  rp   r  rx   r   )r  r  )r  r  r   r  rp   r  rx   r   )r   r   rp   r  rx   r   )r  r  r   r	  rp   rt   rx   r4   )r   r  r   r   r  r   rx   r   )r  r   rx   r   )r  r   r  r  rx   r  )r   r  r  r  r  r  rx   r  )r  r  r  r   rx   r  )r  r  rx   r   )r  r   r`  r  rx   r   )r   r  rx   r   )r   r  r  r   r   r   rQ  r   rC  r  r  r  r	  r
  rx   r  )r   r  r  r   r   r   r  r  r  r  rx   r  )
r   r   r   r  r   r   r  r  rx   r  )r  r  r   r  rp   r  rx   r  )r  r  r   r  rx   r   )r  r  r   r"  rx   r#  )r  r  r   r"  rx   r%  )r  r  r   r"  rx   r'  )r  r  r   r"  rx   r)  )r  r  r   r"  rx   r,  )r  r  r   r.  rx   r/  )r  r  r   r"  rx   r0  )r  r  r   r4  rp   r5  rx   r6  )r  r  r   rs   rp   rt   rx   r>  )r?  r   r@  rA  r  r   rx   r   )r  r  r   r	  rp   rH  rx   r6  )r  r  r   r	  rp   rV  rx   rW  )r  r  r   rY  rp   r  rx   rZ  )r  r  r   r[  rp   r\  rx   r]  )r  r  r   r`  rp   ra  rx   r   )r  r  r   r`  rp   rh  rx   r   )rp   ri  rx   rj  )r  r  r   r`  rp   rl  rx   rB   )r  r  r   rr  rp   r   rs  r   )r  r  r   ru  rp   rv  rx   rw  )r  r  r   ru  rp   r  rx   r  )r  r  r   r	  rx   r   )r  r  r   r  rx   r  )r  r  r   r  rp   r  rx   r  )r  r  r   r	  rp   r  rx   r   )rp   r   rx   r  )r  r   rx   r   )r  r  r   ru  rp   r  rx   r  )NNF)r  r   rN  ry   rJ  r   r  ry   r  ry   r  ry   r  ry   rx  r   rx   r  )r  r  r   r	  rp   r  rx   r  )r  r  r   r  rp   r  )r9  )r  r   )r  r  r   r  rp   r  rx   r  )r  r  r  r   rx   r  )r  r  r   r	  rp   r  rx   r   )r  r  r   r  rp   r  rx   r   )r  r  r   r  rp   r  rx   r   )r   r  rx   r   )
r  r  r  r  r   r  rp   r  rx   r   )
r  r  r  r  r   r  rp   r  rx   r   )r  r  r  r  r  r   r   r  rp   r  rx   r   )r  r  r   r  rp   r  rx   rj  )r  r  r   r  rp   r  rx   r   r   )r  r  rL  r   rx   r  )r  r  rL  r   rx   r  )r  r
  rx   r  )r  r  rL  r   rx   r  )r  r   rx   r   )r  r   r  r  rx   r   )r"  r#  rx   r   )rx   r   )r  r  r   r%  rp   r  rx   r   )r  r  r   r'  rp   r  rx   r(  )r  r  r   r	  rp   r  rx   r   )r  r  r   r	  rp   r  rx   r   )rp   r   rx   r   )r  r  r   r)  rp   r  rx   r   )r   r*  rp   r   rx   r+  )r   r   r   r   r  r  r
  r  r  r  r  r  r  r  r  r  r"   r   r!   rd   r  rT   r.   ru  r$   rn  r#   r    r   r{   rY   rU   rP   r]   r^   re   rf   rh   r	   r  rh  r   r`  rD  r  r   r   r  r   r}   rV   r  rL  rt  r  rO   r  ro  rj  r  r  r  rr  r   rd  r  r   r  rZ  r&   r  r  r/   objectr  r  r  r  rl  rg  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  rb   rp  ro  r1   r%   permitted_dependency_kwargsri  rj  r2   known_exe_kwargsr  r  r  r  r  rm  known_stlib_kwargsr  known_shlib_kwargsr  known_library_kwargsrb  Zknown_shmod_kwargsr  r  known_jar_kwargsr  known_build_target_kwargsrc  rK   rM   r  r  staticmethodr<  rG   rH   rI   rJ   rL   r_   rQ   rR   rS   rZ   r\   rf  r  Targetr_  rq  r  rg   ra  r  rk  rq  re  rc   r[   ry  rz  rx  r`   r|  r  r  r  rR  rw  r  r{  r   r  ri   rN   re  r.  rv  r  r^  ra   rX  rY  r[  r]  r   r   r\  r  r  r  r  rW   rX   rk  r  r  r  r  r  Toverloadr!  rS  r  r*  r-  r(  r  r  r  r$  r1  r'   r  r-   r(   rs  r~  r  r  r}  r  r  r~   r~   r  r   r   
  s   ADA#


=

%
M

M31# 
%
@5&
(,,,,,,(,
5

] 	+	




.	
	

"
$ 
C	
	, 
 S	


r   )rv   rw   rx   ry   r/  )r   r   r   r   rx   r   )
__future__r   r   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Zprogramsr   r   r   rI  r   Zinterpreterbaser   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r   r5   r6   r7   r8   r9   r}  r:   Zbackend.backendsr;   r=   r  r>   r  Z	mesonmainr?   Zdependencyfallbacksr@   rA   rB   rC   rD   rE   rF   Ztype_checkingrG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   r  pathlibrl   enumrm   r   r   r  r  r  r   typingr:  r  r  r  TYPE_CHECKINGargparsetyping_extensionsrn   rp   Zkwtypesrq   Zinterpreterbase.baseobjectsrr   rs   rt   ru   Unionr}   r  r  r  r  r  r  r   ZSourceInputsr  ZSourceOutputsZFileOrStringZGeneratedTypesZBuildTargetSourcer   r   r   r4  r3  r5  r2  r6  r7  r   r1  rT  r   r~   r~   r~   r   <module>   s   0  &
	D
