o
    uJAf                 
   @  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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/m0Z0m1Z1 ddl"m2Z2m3Z3 ddl"m4Z4m5Z5m6Z6m7Z7 ddl"m8Z8m9Z9 ddl"m:Z: ddl;m<Z<m=Z=m>Z>m?Z?m@Z@ ddl	mAZA ddlmBZC ddlmDZE ddlFmGZG ddlHmIZI dd lBmJZJmKZKmLZLmMZMmNZNmOZO dd!lPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZcmdZdmeZemfZfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z} dd"lm~Z d d#lmZ d d$lmZ d d%lZd d%lZd d%lZd d%lZd d%lZd d%lZd d%lZd d%lZd d%lZd d%lZejrd d%lZdd&lmZ dd'lmZ dd(lmZmZmZ dd)lmZ dd*lPmZ ejejejejejejejejejef	 Zejejejejejejejejejf Zejejejejf Zejejeejef gef Zd>d/d0ZG d1d2 d2ZejejB d3d4 e
jd5h D B d6d4 e
jd5h D B ZeejB ejB d7hB ZG d8d9 d9eZh d:Zd;ZG d<d= d=e$eZd%S )?    )annotations   )mparser)environment)coredata)dependencies)mlog)build)optinterpreter)	compilers)	envconfig)wrapWrapMode)mesonlib)EnvironmentVariablesExecutableSerialisationMesonBugExceptionMesonExceptionHoldableObjectFileModeMachineChoice	OptionKeylistifyextract_as_listhas_path_seppath_is_in_root
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FeatureBrokenFeatureNewKwargs)ObjectHolderContextManagerObject)stringifyUserArguments)ExtensionModuleModuleObjectMutableModuleObjectNewExtensionModuleNotFoundExtensionModule)optname_regex   )interpreterobjects)compiler)	MesonMain)DependencyFallbacksHolder)SubprojectHolderTest
RunProcessextract_required_kwargextract_search_dirsNullSubprojectInterpreter)-BUILD_TARGET_KWS
COMMAND_KWCT_BUILD_ALWAYSCT_BUILD_ALWAYS_STALECT_BUILD_BY_DEFAULTCT_INPUT_KWCT_INSTALL_DIR_KWEXECUTABLE_KWSJAR_KWSLIBRARY_KWS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INSTALL_FOLLOW_SYMLINKSLINK_WITH_KWLINK_WHOLE_KWCT_INSTALL_TAG_KWINSTALL_TAG_KWLANGUAGE_KW	NATIVE_KWPRESERVE_PATH_KWREQUIRED_KWSHARED_LIB_KWSSHARED_MOD_KWSDEPENDENCY_SOURCES_KWSOURCES_VARARGSSTATIC_LIB_KWSVARIABLES_KWTEST_KWSNoneTypein_set_validatorenv_convertor_with_method)
primitives)Path)EnumNkwargs)Backend)InterpreterObjectTYPE_varTYPE_kwargs)OverrideProgram)SourcesVarargsType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)r    r   G/usr/lib/python3.10/site-packages/mesonbuild/interpreter/interpreter.py_project_version_validator   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_namestrproject_versionc                 C  s"   || _ || _tt| _d| _d S Nr   )r   r   collectionsdefaultdictdictsectionsmax_key_len)selfr   r   r   r   r   __init__   s   
zSummary.__init__sectionvaluesT.Dict[str, T.Any]bool_ynboollist_sepr   
subprojectr   Nonec                 C  s`  |  D ]\}}|| j| v rtd|d|g }t|D ]{}	t|	trB|r8||	r1tdnt	d q||	r>dnd qt|	t
tfrQ|t
|	 qt|	ttfrgtdd| ||	  qt|	tr|t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NOtruefalsez)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)itemsr   r,   r   r   r   appendr   greenredr   intr   r   r2   
single_usesummary_valuer0   r   
UserOptionprintable_valueformatmaxr   r   )r   r   r   r   r   r   kvZformatted_valuesimr   r   r   add_section   s2   
 
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d d S t j}g }|}| | }|D ](}t|t| }	|rE||	 |krEt j|||d |}g }|| ||	7 }q&t j||dd d S )N
r   F)sepdisplay_timestamp)r   r   )r   r   shutilget_terminal_sizecolumnsrstripr   r   )
r   arrr   r   Z	lines_sepZmax_lenlineline_lenr   Zv_lenr   r   r   r      s"   


zSummary.dump_valueN)r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   )__name__
__module____qualname__r   r   r   r   r   r   r   r   r      s
    

r   c                 C     h | ]}| d qS )_shared_argsr   .0lr   r   r   	<setcomp>       r   javac                 C  r   )_static_argsr   r   r   r   r   r      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   >   requiredinclude_type
cmake_args
componentscmake_package_versionversionmethodallow_fallbackZoptional_modulesfallbacknot_found_messagemoduleslanguagecmake_module_pathnativestaticmaindefault_optionsZprivate_headerszYou 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dddZddd Zdd!d"Zdd#d$Zdd)d*Zdd-d.Z	dd2d3Z
dd4d5Zdd7d8Zdd;d<Zdd>d?Zdd@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d^eee$j%efdWg d_d`e&jdaedbidceddee'fedeeee(j)dWg dfd`ddjdkZ*edle+egdmeddodpZ,dqdr Z-edse(j.e/e0j1e$j%efe(j.e/e0j1e$j%efdNedsedte+e'fdudDedve+dWdudwe2jdxdDdd|d}Z3	ddddZ4dd Z5ed	eed	ee6jddDeddeeeg dWddddZ7		ddddZ8ddddZ9			ddddZ:dddZ;dddZ<dddZ=edeedddZ>ede?gdmedddZ@dddZAedeedNede6edee'feddee$j%e'efdeBdd dedeeee'fddWdedeeeg dWdfdededddddZCedede+e'fdadDeededNdddZDdddńZEeFedddǄZGddɄ ZHeFeIdd˃edee?feJgdmedededdede+ddedee'fdadDddd҄ZKdddԄZLdddքZMeFeIdd؃eddڄ ZNeFedd܄ ZOeFeIddރedd ZPeedd ZQedeedededeRddhddddZSdddZTdddZUdddZVdddZWdddZXdϐddZYdАddZZdѐd	d
Z[dҐddZ\e]j^ddWdWdddfdӐddZ_dԐddZ`dՐddZad֐d d!Zbed"ee$j%fd#d$ed"ejd%dDeceed&eeeg dWddeddeeeg dWd'de6jd(dDedאd,d-Zdeed.d/d0geed.dbd1geed.dad2geed.d'd3geed.dxg d4eed.d%d5geed.d6d7geefeged.ed#d$ed.e6jddDdWd8dؐd:d;ZheId5d؃eed<d= Ziefe(jjed>eekdNed>gelR d?dWidِdCdDZmefe(jnedEeekdNedEgeoR d?dWidڐdHdIZpefe(jqedJeekdNedJgerR d?dWidېdMdNZsefetedOeekdNedOgeuR d?dWidܐdRdSZveIdTdUefe(jwedTeekdNedTgexR d?dWidݐdXdYZyefetedZeekdNedZgeuR d?dWidސd[d\Zzefe(j{ed]eee$j%e(j|e(j}e(j~e(j)e(jfdNed]geR d?dWidߐdadbZeedcd6dddegefeedceekdNedcgeR d?dWiddhdiZeedjejdWdkeedleeee(je(j|e(j}e/e$j%fdWg dXedee'fedmedndddrdsZeIdtd]eeddwdxZedd|d}Zed~egdmed~eeeeeeeeeeee2jd/dDeejdudDede+ddCdwedve+ddede+dddwdddZedeedeee2jd/dDdddZeIdd'edee(jd#d$edddZede(j.e/fededeeedddWdWdedeeedddWdWdeeedve+dddwdddZedee(j.e(je/e$j%fedgeR  dddZedee(j.e(je/e$j%fedgeede+dWdR  dddZdddZdddZdddZedee$j%fdNedeedee'fejdudDeedddZedee$j%fdNededee'fddDejdudDedddZeIddedeedee'fdZdDdddZeIddÃedeedededWdkededWdkeddȐdɄZeIddZedeJe?gdmeeFdd͐d΄ZedeededeeeJdd dg dWdэddӐdԄZddאd؄Zedee$j%fdNededeeee$j%fdWg dXedeeeg dWd]dejddDejddDeejddDeddߐdZ			ddddZedeedededWdk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edddZeedejd'dDejddDejddDedve+dddwedleee(j.e/e0j1e$j%efdde'fdWdedee?eee+fe(je'fede+ddudܐddededdudweded d]eRh ddedeee$j%efdWg dXede+e'fdxdDedee+fddd deededdudd(ieRh d	d
edee'fdd(dwdddZddddZededNede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/d`ed!e+dd%dwe2dd#d$Zed%edNed%ecedd'd(Zed)edNed%ecedd*d+Zed,edNed,ecedd-d.Zed/edNed%ecedd0d1ZeId2dރed2ejdNed2ecedd4d5Zd d6d7Zdd:d;Zdd=d>Zdd@dAZeFedBeee?fgdmedBeejdZdDddDdEZedFed#d$eddGdHZǐd fdIdJZȐddKdLZɐddMdNZʐdOdP Zej͐dddTdUZej͐dddVdUZej͐d	dYdUZej͐dd
d\dUZej͐ddd^dUZΐdd
d_dUZedd`daZϐddddeZeIdOd]dܐdfdgZѐddhdiZҐddldmZӐddodpZej͐ddsdtZej͐ddvdtZej͐ddxdtZej͐ddzdtZej͐dd|dtZՐdddtZՐdddZ֐dd Zאdd ZؐdddZِdddZedeeJeeFeېdddZedeefeJgdmeeFeސdddZedeedddZeIddedeedddZedddZeIdd'edeJedddZeeIddedeeegdmd d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']r   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	   get_coredatar   r   summaryr   splitospathr   Zsubproject_directory_namer   setr   load_root_meson_filesanity_check_astr   builtinupdaterB   
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_filesjoinr   build_filenameadd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__N     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_machinehost_machinetarget_machine)r	   r   machinesmiss_defaultingdetect_machine_infor   r   default_missingcpuhosttargetOBJMachineHolderr  )r   r*  r   r   r   r   Q  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<d4 d5t=j>v r| j d6| j?i d7t=j>v r| j d8| j@i 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filesfind_program	generator
get_optionget_variable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	exceptionMESON_RUNNING_IN_PROJECT_TESTSexpect_error)A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_programfunc_generatorfunc_get_optionfunc_get_variable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  c  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_OBJArrayHolderr   
DictHolderr   IntegerHolderr   BooleanHolderr   StringHolderZMesonVersionStringZMesonVersionStringHolderDependencyVariableStringZDependencyVariableStringHolderOptionStringZOptionStringHolderr   r   r1  Z
FileHolderr	   SharedLibraryZSharedLibraryHolderStaticLibraryZStaticLibraryHolderBothLibrariesZBothLibrariesHolderSharedModuleZSharedModuleHolder
ExecutableExecutableHolderJarZ	JarHolderCustomTargetCustomTargetHolderCustomTargetIndexCustomTargetIndexHolder	GeneratorZGeneratorHolderGeneratedListGeneratedListHolderExtractedObjectsZGeneratedObjectsHolder	RunTargetZRunTargetHolderAliasTargetZAliasTargetHolderHeadersZHeadersHolderManZ	ManHolderEmptyDirZEmptyDirHolderDataZ
DataHolderSymlinkDataZSymlinkDataHolder
InstallDirZInstallDirHolderIncludeDirsZIncludeDirsHolderr   ZEnvironmentVariablesHolderStructuredSourcesZStructuredSourcesHolderr   	RunResultcompilerOBJZTryRunResultHolderr   ExternalLibraryZExternalLibraryHolderr   UserFeatureOptionZFeatureOptionHolderr   MachineInfor2  ConfigurationDataConfigurationDataHolderbound_holder_mapr   DependencyHolderr   ExternalProgramHolderCompilerCompilerHolderr:   ZModuleObjectHolderr;   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   r   r6   r,   r	   BuildTargetr  r  
add_targetnamer   process_new_valuesr   r   install_scriptsr   r  datar  symlinksr   InternalDependencysourcesr  install_dirsrE   testsr   r   r   r0   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   version_comparer   stable_versionr,   	from_noder   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   linesr   r   FunctionNodeargsr{   r   IdNoder   BaseStringNoder  )r   r\  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   )r   r   r   is_builtr	  r
  normpathrelative_nameisfile
startswithrx   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%  s8   





zInterpreter.add_build_def_fileT.Dict[str, InterpreterObject]c                 C  r  r  	variablesr%  r   r   r   get_variablesH  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   _stdlibT)Zforce_fallback)r   HOSTr   is_cross_buildr   BUILDr	   r   
propertiesr   keysr   stringlistify
get_stdlibKeyErrorr   r2   r   r   current_noderC   set_fallbacklookupstdlibs)
r   Zmachine_choicesfor_machinepropsr   dir{   r  dfdepr   r   r   check_stdlibsK  s*   

zInterpreter.check_stdlibsrM  0.59.0)sincer  r  T.Tuple[str]r{   '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)rG   r   r=   r  r   deprecationreplacer   r   	importlibimport_moduleImportErrorr-   
initializer   r9   r<   r	   r   INFOZaddedr2   r   r  
deprecatedr3   r>  Z
stabilizedri  )r   r  r  r{   modnamedisabledr   r;  Zexpect_unstableZreal_modnamemoduleZ
ext_moduler   r   r   r  `  sj   	




""




zInterpreter.func_importrH  )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  r{   r   r   r   r       zInterpreter.func_filesrC  compile_argsT)r   defaultd_import_dirs0.62.0)r  r6  	link_argsz0.46.0extra_filesz1.2.0)r   rT  r6  0.54.0r   )r6  since_valuesr   objects1.1.0T.List[TYPE_var]kwtypes.FuncDeclareDependencydependencies.Dependencyc                 C  sJ  |d }|  |}|d }|d }|d }| |d }	| |d }
|d }|d }|d	 }|d
 }|d u r:| j}|d }|  |d}t| jj}| D ]C\}}zt|}W n	 tya   Y qNw |  so|| j	 |j
v roqN| r| r|| j |gtttj|j
 v rt|||< qNt|||||||	|
|||||}|S )Nr   	link_with
link_wholer[  r  rX  rS  rW  r  r   d_module_versionsrU  )extract_incdirsrP  r   rx   r   
source_dirr   
ValueErroris_subprojectr   r  is_absoluteis_dirroot_subdirr   r	  r
  abspathr  r  r   r  )r   r  r  r{   depsZincsZlibsZ
libs_wholer[  r  rX  rS  rW  r  r   rb  rU  r  r   r   pr3  r   r   r   r~    sB   
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: )
r2   r   r   r   rp  r  	argumentsacceptresultr,   )r   r  r  r{   r   rZ  rp  printerr   r   r   rv    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-   zipr   )r   r  ZargcountZ	arg_typesactualwantedr   r   r   validate_arguments  s   
zInterpreter.validate_argumentsr^  check0.47.0capture)rT  r6  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'rF   c                 C  s   |  ||S r  )run_command_implrQ  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rX| jj	
 D ]\}}||krC|} nq7td| d	t||| t|trl| skt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 ]d}t|tr|| qt|tjr||||	 qt|tr||  qt|tjrtjdd| j | j!d t|j"d dd}| std|d||  qt||j#| | $|  |D ]}tj%|sEtj|r?|	n|| j|}| $| q.t&|||||	| j| j ' dg ||
|d
S )Nr{  envry  TonceFzoProgram {!r} was overridden with the compiled executable {!r} and therefore cannot be used during configurationzProgram zK is a compiled executable and therefore cannot be used during configurationzcommand z not found or not executabler   silentr?   )r  
search_dirzProgram or command z7Compiler object as a variadic argument to `run_command`0.61.0r!  
introspect)r  ry  r{  )(r   r  r  r   ri  implicit_check_false_warningr   r	   r  find_overridesr   r,   descriptionr   r   foundget_namer   r  get_exelistr   r   absolute_pathr	  r
  r  r   r   r   get_pathr2   r   r   r+  exelistr  r  isabsrF   get_build_command)r   r  r{   r  cmdcargsr{  r  r  r  ry  Zoverridden_msgZexpanded_argsr  exeZprognamer  progr  ar   r   r   r  	  sz   





zInterpreter.run_command_implc                 C  r$  )NzYTried to call option() in build description file. All options must be in the option file.)r,   )r   nodesr  r{   r   r   r   r  U  r'  zInterpreter.func_optionz0.38.0)rT  r   r  kwtypes.SubprojectrD   c                 C  s,   |d |d |d d g d}|  |d |S )Nr   r   r   )r   r   r   optionscmake_optionsr   )do_subproject)r   r  r  r{   r  r   r   r   r  X  s   	zInterpreter.func_subproject	subp_namedisabled_featurer   rj  T.Optional[Exception]c                 C  s,   t t tj| j|||d}|| j|< |S )N)r  rj  )rD   rI   r	  r
  r  r   r   )r   r  r  rj  subr   r   r   disabled_subprojecti  s
   
zInterpreter.disabled_subprojectkwtypes.DoSubprojectforce_methodT.Optional[wrap.Method]c                   sF  t || j\}}}|r"tdt ddt|d | j |dS  fdd|d  D } d	kr7td
 d dkrAtdd v rItdtj	
 rStdt r_tjd| jd  | jv rw| 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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 | j | j!| j"d)}z
||  |||W S  tyU     t#y } zA|st$  tj%|t&d*d+ W d    n	1 s{w   Y  td,t|dtdd | j |d W  Y d }~S |d }~ww )-N
Subprojectr   skipped: featurerI  )r  c                   s   i | ]\}}|j  d |qS r   )evolver   r   r   r  r   r   
<dictcomp>v      z-Interpreter.do_subproject.<locals>.<dictcomp>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"Recursive include of subprojects: zSubproject "z" required but not found.r   	undefinedSubproject  version is  but 
 required.zis buildable:r   z(disabling))rj  Texist_okz
Executing subprojectr  r   r   nestedF)r  cmakecargoz
Exception:)prefixz
Subproject)'rG   r   r   r   r   r  r   r,   r	  r
  r  r   ri  r+  r  r  r.   r   r  r   r	   r   version_compare_manyr   wrap_resolverr  r   ZWrapExceptionr   makedirsr  r  _do_subproject_meson_do_subproject_cmake_do_subproject_cargo	Exceptionr  rj  yellow)r   r  r{   r  rI  r   featurer   Z	fullstackZincpathr   r  rw  rr   r   estackr   Zmethods_mapr   r  r   r  p  s    




 
zInterpreter.do_subprojectr   T.Dict[OptionKey, str]r  T.Optional[T.List[str]]c                 C  sJ  t | |rXddlm}m}	 |	dd}
||  ||
 |
  tj	| j
j |d}t|ddd}||
j W d    n1 sHw   Y  t d	| t | | j
 }t|| j||| j|||d u|| jd

}| j|_| j|_| j|_| j|_| j|_| j|g |_| j}t   |  t   }W d    n1 sw   Y  t dt !|d W d    n1 sw   Y  t   |d r|j"}|d }|dkst#$||d st%d| d| d| d|| _| j&|j t'|||| jd| j|< |r| j(&| | j(&|j( | j
)|j
 |j"| j
j|< | j| S )Nr   )AstIndentationGeneratorrp  T)Zupdate_ast_line_nosmeson.buildwutf-8encodingzGenerated Meson AST:)r   r   r   r   r  z	finished.r   r  r   r  r  r  r  )warnings	callstack)*r   r  r   r  rp  rr  Zpost_processr	  r
  r  r	   r   r  openwriters  r   cmd_ci_includer  r   r   r   r   r   r   r  r  r  r  r  nested_warningsrunget_warning_countr   r   r   r  r,   r  rD   r  merge)r   r  r   r   r{   r   r  r   r  rp  rt  Zmeson_filenamer  Z	new_buildZsubiZcurrent_activeZsubi_warningsr  rw  r   r   r   r    sb   






#
z Interpreter._do_subproject_mesonc              
   C  s   ddl m} t|] | jjtd j}ddlm	} |
dp"| }|
dg |j }	|t|t|| jj| j}
|
|	 |
  |
|j}| j|||||dd |
jD tjhd	}|
|_W d    |S 1 skw   Y  |S )
Nr   )CMakeInterpreterr  )CMakeSubprojectOptionsr  r  c                 S  s   g | ]}t |qS r   r   )r   r  r   r   r   
<listcomp>
      z4Interpreter._do_subproject_cmake.<locals>.<listcomp>)r   )r  r  r   r  r   r  r   r   Zmodules.cmaker  getr  rx   r	   r   r   Z
initialiseZanalyseZpretend_to_be_mesonZtarget_optionsr  Zbs_filesr   r   Zcm_interpreter)r   r  r   r   r{   r  r  r  r  r  Zcm_intr   rs  r   r   r   r    s,   

z Interpreter._do_subproject_cmakec                 C  s   ddl m} tjdd| j| jd t|  |||| j	}| 
|||||tj|dgW  d    S 1 s9w   Y  d S )Nr   )r  zCargo subproject1.3.0r!  z
Cargo.toml)r   r  r2   r   r   r+  r   r  Z	interpretr   r  r	  r
  r  )r   r  r   r   r{   r  r   r   r   r   r    s   
$z Interpreter._do_subproject_cargo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)	Nr  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   from_stringr  r   
is_projectr   r  r   base_optionsr  yieldingas_rootr   r   typer"  r   lowerr   ri  r   r+  r*  r,   )	r   r  keyoptsr   optZpoptopt_typeZ	popt_typer   r   r   get_option_internal  s8   
zInterpreter.get_option_internalrK  (T.Union[coredata.UserOption, 'TYPE_var']c                 C  s   |d }d|v rt dt|jdddd d ur!t d|| |}t|tjr1||_|S t|tj	rKt|j
trHt|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?   )maxsplitr  zInvalid option name {})r,   r>   searchr  r  r   r   r  r  r   r   r   r  r  )r   r  r  r{   r  r  r   r   r   r  A  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=  )r2   r   r   r   r   r   r   r   r-   r	   r  )r   r  r  r{   initial_valuesr   r   r   r   r   rz  X  s   
z#Interpreter.func_configuration_datac                 C  s2  | j d urd S ddl m} td| jj v r)| jtd}||| j	| | _ n| jtd}|
|| j	| | _ | j d u rGtd| d|| j jkr|| j jdr_tdt| j j | jjsotd	| d
| j j | jjtd| j jdd | jjr| j| dd | jj D }| j| d S )Nr   )backends	genvsliter   zUnknown backend "".vsz$Auto detected Visual Studio backend:zBackend changed from z to T)first_invocationc                 S  s   i | ]\}}|  r||qS r   )
is_backendr  r   r   r   r    r  z+Interpreter.set_backend.<locals>.<dictcomp>)r   r  r   r   cmd_line_optionsr'  r   rK  Zget_genvslite_backendr	   get_backend_from_namer,   r  r  r   r   r   r   r  r   
set_optioninit_backend_optionsr  r   set_options)r   r  backend_namer  r   r   r   set_backende  s(   

zInterpreter.set_backendr\  r  r  c                 C  s   t | tr	| d S | S r   r   r   xr   r   r   <lambda>  r   zInterpreter.<lambda>)rT  	validator	convertorlicenselicense_files)rT  r   r6  )rT  T.Tuple[str, T.List[str]]'kwtypes.Project'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  |  jr fdd|d  D  _n|d  _ 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'r2t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 rA j1 j"_1|d d u rUdg}|d rTt dn|d }g } 2|d D ]}|( jj) jj*}|3||f qbt"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rt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  ! s> j<t=d+} j<t=d,}|p8|:d-}t&G|  H|d.tIjJ  H|d/tIjK  L   ! s] M  d S d S )0Nr   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 insteadc                   s    i | ]\}}|j  jd |qS r  )r  r   r  r%  r   r   r    s    z,Interpreter.func_project.<locals>.<dictcomp>r   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.r  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   rB  r   r2   r   r   r
   ZOptionInterpreterprocessr   update_project_optionsr  r  r   r  r   r  initialized_subprojectsr  r  r   init_builtinsr  set_default_optionsrf  r	   r   r  r   r   r   r  rd  	build_dirrx   	read_textr  FileNotFoundErrorr,   r   r   rP  r   DepManifestdep_manifestprojectsr.   r   r  r  r   rK  r   r   	nopromoter   ZResolverr  r  Zmerge_wrapsr   r   setup_vsenvr5  r   r#  r%  r  r4  )r   r  r  r{   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_projectr5  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 languager  rI  FrY  zXadd_languages is missing native:, assuming languages are wanted for both host and build.r!  )rG   r   sortedr   
sort_clinkr   r   r   r5  machine_from_native_kwargr2   get_target_versioncheck_versionri  r   r%  r#  )r   r  r  r{   langsrI  r   r  r   langtvsuccessr   r   r   rp  #  s"    zInterpreter.func_add_languages	func_nameT.List[str]c              
     sD   z
 fdd|D W S  t y! } zt | dt| d }~ww )Nc                   s   g | ]}t | jqS r   )r8   r   r   r   r%  r   r   r  =      z9Interpreter._stringify_user_arguments.<locals>.<listcomp>z(): )r-   r   )r   r  r0  r  r   r%  r   _stringify_user_arguments;  s   z%Interpreter._stringify_user_argumentsc                 C  s:   t |dkrtjdd| j|d | |d}| | d S )Nr?   z#message with more than one argumentrY  r!  rZ  )r   r2   r   r   r4  message_implr   r  r  r{   args_strr   r   r   r  A  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   r5  I  s   zInterpreter.message_implr  ro  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   )r   r   r,   r   summary_impl)r   r  r  r{   r   r   r   r   r  L  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   r{   r   r   r   r;  a  s
   zInterpreter.summary_implc                 C  s  t  }t| j D ]G\}}| g}|jr"|d|jdg7 }n|jr.|t|jg7 }n|j	dkr<||j	 dg7 }|j
rNd|j
}|d| dg7 }|||< q|r_| d|d	d
d | jrt  }| jjrp| jj|d< | jjrz| 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	 warningsr  z(from )ZSubprojectsTr   )r   r   zCross fileszNative filesc                 S  s   i | ]	\}}t ||qS r   r  r  r   r   r   r        z.Interpreter._print_summary.<locals>.<dictcomp>zUser defined optionsFr   )r   OrderedDictr'  r   r   r  r  rj  r   r  r  r  r;  r   
cross_filenative_filer   r  r   r   r  popr   )r   all_subprojectsr  Zsubpr   r  r   Zsorted_optionsZmain_summaryr  r  r   r   r   _print_summaryg  sL   



zInterpreter._print_summaryri  z0.44.0c                 C  s@   t |dkrtjdd| j|d | |d}tj|d|i d S )Nr?   z#warning with more than one argumentrY  r!  ri  r  )r   r2   r   r   r4  r   ri  r6  r   r   r   r    s   zInterpreter.func_warningc                 C  s>   t |dkrtjdd| j|d | |d}tdd| )Nr?   z!error with more than one argumentr   r!  rF  zProblem encountered: r   )r   r2   r   r   r4  r,   r  r6  r   r   r   r    s   zInterpreter.func_errorrB  0.63.0c                 C  s"   |  |d}tjdg|R   d S )NrB  zDebug:)r4  r   rB  r6  r   r   r   r}    s   zInterpreter.func_debugc                 C  r$  )Nzunit test traceback :))RuntimeErrorrQ  r   r   r   r    s   zInterpreter.func_exceptionrl  howliteralre)rT  r  r   r7   c                 C  s&   G dd dt }||d |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   rF  r   r   r   c                   s   t  | || _|| _d S r  )r  r   rI  rF  )r   rI  rF  r   r!  r   r   r     s   
zAInterpreter.func_expect_error.<locals>.ExpectErrorObject.__init__c                 S  sn   |d u rt dt|tjr5t|}| jdkr| j|ks(| jdkr3t| j|s3t d| jd|dS d S )Nz+Expecting an error but code block succeededrG  rH  zExpecting error z	 but got T)	r,   r   r   r   r   rF  rI  rH  match)r   exc_typeZexc_valZexc_tbrI  r   r   r   __exit__  s   zAInterpreter.func_expect_error.<locals>.ExpectErrorObject.__exit__)rI  r   rF  r   r   r   r   r   )r   r   r   r   rL  __classcell__r   r   r!  r   ExpectErrorObject  s    rN  r   rF  )r7   r   )r   r  r  r{   rN  r   r   r   r    s   zInterpreter.func_expect_errorr   r/  r   c                 C  s.   |  |||}| j s| j  |   |S r  )add_languages_forr   r$  $copy_build_options_from_regular_onesr   )r   r  r   r/  r/  r   r   r   r5    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 )Nskip_sanity_checkFz+Option skip_sanity_check must be a boolean.)
r   r&  r/  r  r   r   r,   r   r#  r$  )r   r/  Zshouldr   r   r   should_skip_sanity_check  s   
z$Interpreter.should_skip_sanity_checkc                 C  s<  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%| |}	|	rmtjddd t| j|||	}|d u rtd| d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   r  r   r   r   r    r  z1Interpreter.add_languages_for.<locals>.<listcomp>valaczAdding Vala language without Cr5  r!  nasmzAdding NASM languager   Tr%  z8Cross compiler sanity tests disabled via the cross file.r  zTried to use unknown language "r  r&  zfor thezmachine not found.Fr  zcompiler for thezmachine:r   zlinker for the))r  r   r'  r  r2   r   r   r+  r   r'  r(  get_lower_case_namer   r  rR  r   r   detect_compiler_forr   r-   r   r   r   get_optionsr  r  r  add_compiler_optionsr   r#  r$  rB  get_display_languager  r  get_version_stringlinkeridr   r	   ensure_static_linker)r   r  r   r/  r,  r/  r-  Zmachine_namecomprQ  r  r   r   Z
logger_funr   r   r   rO    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)	r   r   r   r   r,   r   from_bin_listr   r   )r   r/  ra  rl  r  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)r  extra_search_dirsr  (r   r<  )r	  r
  r  r   r  r   r   r   r   r	  r  fnamer   r-   r   r  r   get_command)	r   r  rf  rg  rd  Zexenamer  ri  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))r   r   r	   r  r   r   blue)r   rn  rg  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  )r   r   r	   searched_programsr  )r   rn  r  r   r   r   store_name_lookupsJ  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	   rs  r,   r  )r   r  r  r   r   r   add_find_program_overrideO  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   )r   r   r  r   rd  r  rS  r%  r   r   r  X  s    &z0Interpreter.notfound_program.<locals>.<listcomp>)r   r  r8  r   r%  r   notfound_programV  s
   
zInterpreter.notfound_programCT.Optional[T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]]r  rw  T.Union[str, T.List[str]]version_funcT.Optional[ProgramVersionFunc]AT.Union['ExternalProgram', 'build.Executable', 'OverrideProgram']c	              
   C  s   t |}g }	| ||||||||	}
|
d u s| |
|||	s$| |}
t|
trR|
 sR|sCtj	dt
|
 dtdg|	R   |rPd}t||
 |
S | | |sltj	dt
|
jdtdg|	R   t|
tjrud|
_|
S )NProgramfound:r   z(Program {!r} not found or not executabler   T)r   r   program_lookupcheck_program_versionrw  r   r   r  r   r   r   r  r   r,   r   rt  r  r   r	   r  was_returned_by_find_program)r   r  r/  r   r   r  rw  rf  rz  rg  progobjr   r   r   r   find_program_impl]  s$   

(
&zInterpreter.find_program_implGT.Optional[T.Union[ExternalProgram, build.Executable, OverrideProgram]]c	                 C  sX  |  ||}	|	r
|	S |d dkrtd| j ddS d }
| jtd}|tjkr4| jj	r4| jj	
|}
|
rD|tjkrD| |
||||S | ||}	|	d u rU| |||}	|	d u rp|d drptdtjdd}| rn|nd }	|	r|| |	|||s|d }	|	d u r|
r|r| |}	tjdt|	 dtd	g|R   |  | |
||||}	|	S )
Nr   r  Tr  r  python3r}  r~  r   )rr  r   r   r  r   rK  r   r   
nofallbackr  Zfind_program_providerforcefallbackfind_program_fallbackre  rm  endswithr   python_commandr  r  rw  r   r   r   r  r   clear)r   r  r/  r   r   rf  rw  rz  rg  r  r   r  r  r   r   r   r  |  s2   
(zInterpreter.program_lookupr  ;T.Union[ExternalProgram, build.Executable, OverrideProgram]c           
   	   C  s   |rZ|r	||}n#t |tjr'|jr| j|j j}n| }t |ts#J |j}n|| }t	
||\}}}	|sQdt|dtddd |D g|d d< dS |dt| dS )	Nr  z	but need:, c                 S  s   g | ]}d | d qS )'r   )r   r  r   r   r   r    r3  z5Interpreter.check_program_version.<locals>.<listcomp>r   FT)r   r	   r  r   r   held_objectr   r   get_versionr   r  r   r   r   r  insert)
r   r  rw  rz  rg  r   Zinterpis_found	not_foundr;  r   r   r   r    s$   

z!Interpreter.check_program_versionr   7T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]c              
   C  sN   t dt |dt d| ||pi g g d d}| || | ||S )NzFallback to subprojectzwhich provides programr   )r   r   r   r  r  )r   r   r   r  r  rr  )r   r   r  r   r   rg  Z	sp_kwargsr   r   r   r    s   z!Interpreter.find_program_fallbackrI  r?   )rK  min_varargsr  dirs0.52.0r  &T.Tuple[T.List[mesonlib.FileOrString]]'kwtypes.FindProgram'?T.Union['build.Executable', ExternalProgram, 'OverrideProgram']c           	   	   C  s   t || j\}}}|r&tdtd|d dt|d | |d S t|}|d }| j|d |d ||d|d	 |d
S )Nr}  r   r   r  rI  r   r   Fr   )r   r   r  rw  rf  )	rG   r   r   r   r   r  rw  rH   r  )	r   r  r  r{   rI  r   r  rf  r   r   r   r   r    s   (zInterpreter.func_find_programrD  r   r   r   r   r   )r   r   r   rE  0.40.0r   )allow_unknownr   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   r2   user   r  r   r   r-   rC   r,  r   r-  r  r5  r   r  get_include_typer   rB  generate_system_dependencyfeature_sincer   r  featurechecks)r   r  r  r{   namesr   r   r   r2  r   drw  rv  r   	extra_msgr  r   r   r   r    sJ   





 



zInterpreter.func_dependencyc                 C  s   t  S r  )r0   rQ  r   r   r   r       zInterpreter.func_disablerrG  r   T.Tuple[str, SourcesVarargsType]kwtypes.Executablebuild.Executablec                 C     |  |||tjS r  )r>  r	   r  rQ  r   r   r   r        zInterpreter.func_executablerd  kwtypes.StaticLibrarybuild.StaticLibraryc                 C  r  r  )r>  r	   r  rQ  r   r   r   r  (  r  zInterpreter.func_static_librb  kwtypes.SharedLibrarybuild.SharedLibraryc                 C  s   |  |||tj}d|_|S NT)r>  r	   r  shared_library_only)r   r  r  r{   holderr   r   r   r  0  s   zInterpreter.func_shared_libr=  kwtypes.Librarybuild.BothLibrariesc                 C     |  |||S r  )build_both_librariesrQ  r   r   r   rx  :     zInterpreter.func_both_librc  z0.37.0kwtypes.SharedModulebuild.SharedModulec                 C  r  r  )r>  r	   r  rQ  r   r   r   r  B  s   zInterpreter.func_shared_modulerY  c                 C  r  r  )build_libraryrQ  r   r   r   r  K  r  zInterpreter.func_libraryrW  GT.Tuple[str, T.List[T.Union[str, mesonlib.File, build.GeneratedTypes]]]kwtypes.Jar	build.Jarc                 C  r  r  )r>  r	   r  rQ  r   r   r   r  S  r  zInterpreter.func_jarr>  ra  override_optionskwtypes.BuildTargetwT.Union[build.Executable, build.StaticLibrary, build.SharedLibrary, build.SharedModule, build.BothLibraries, build.Jar]c                 C  s   |d }|dkr|  |||tjS |dkr|  |||tjS |dkr+|  |||tjS |dkr8|  |||tjS |dkrC| |||S |dkrN| |||S |  |||tjS )Nr   rG  rb  rc  rd  r=  rY  )	r>  r	   r  r  r  r  r  r  r  )r   r  r  r{   r   r   r   r   ry  [  s   	zInterpreter.func_build_targetrh  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!  r  z(.*)r  r   z'vcs_tag with file as the first argumentrV  Fr  zGvcs_tag with custom_tgt, external_program, or exe as the first argumentrD  zFound {} repository at {}r  wc_dirget_rev	rev_regexr   inputr?   outputrh  z
--internalZ	vcstaggerz@INPUT0@z	@OUTPUT0@T)build_by_defaultbuild_always_stale)r2   r   r   r   r	  r
  r
  r  r   r  r   r   r   r   r   r  r  
detect_vcsr   r   r   r  _validate_custom_target_outputsr   r  r	   r  rP  r  r  )r   r  r  r{   r   r  Zregex_selectorZvcs_cmdrd  Zmaincmdvcsr  tgr   r   r   r  s  sb   



zInterpreter.func_vcs_tagre  r~   
T.NoReturnc                 C  s   t  r  )r/   rQ  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_outputsrA  feedconsolez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depfiler  r  z&substitutions in custom_target depfilerz  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   r  )strictr  r?   r  zKcustom_target: "feed" keyword argument can only be used with a single inputr  r{  zOcustom_target: "capture" keyword argument can only be used with a single outputr  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)rA  depend_filesdependsr  )r  r  r{  r  r  r  extra_dependsr  r  r  r  r  r  r   )r2   r   r   _warn_kwarg_install_mode_stickyr,   rP  r   r   r  r   r-   validate_forbidden_targetsr  r	   r  r   r   r   r  r  )r   r  r  r{   r  r  r  r  inputsr  rU  tr  r   r   r   r|    s     


zInterpreter.func_custom_targetr_  '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 )Nr  z%Tried to use non-existing executable r   r  r  )r  r   r   r   r  r,   r  r   r  r	   r  r   r   r   r  )r   r  r  r{   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  r{   r  rk  r  r   r   r   ru  Q  s   zInterpreter.func_alias_targetrJ  rq  )allow_empty)r   r   r  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 )
Nr  r  r  zAEvery element of "output" must contain @BASENAME@ or @PLAINNAME@.z0"output" must not contain a directory separator.r?   r  z:Tried to use @OUTPUT@ in a rule with more than one output.r   )r-   r   r   r	   r  r  r   )r   r  r  r{   Zruleogenr   r   r   r  [  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_testrQ  r   r   r   rw  u     zInterpreter.func_benchmarkrf  is_parallel'kwtypes.FuncTest'c                 C  r  r  r  rQ  r   r   r   r  |  r  zInterpreter.func_testOT.Union[EnvironmentVariables, T.Dict[str, 'TYPE_var'], T.List['TYPE_var'], str]r   c                 C  s>   | d}|d u rt S t|}|rtd| t|S )Nr  z"env": )r  r   r]   r  r-   r  )r   r{   ZenvlistrI  r   r   r   unpack_env_kwarg  s   


zInterpreter.unpack_env_kwarg'kwtypes.BaseTest'rE   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   r  r  Fr  Zshould_failworkdirprotocolpriorityverbose)r   r@  rA  r   r   r  r-   r   r   r  r  r2   r   r   rf  r	   r   r   rE   r  )
r   r  r  r{   r  r  r  Zprjr  r  r   r   r   	make_test  sJ   

 
zInterpreter.make_testr   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)	r	  r	   r  r   r   rB  r   r  
benchmarks)r   r  r  r{   r
  r  r   r   r   r    s   zInterpreter.add_testrQ  (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j|| tj|||d || j|d	 d
}|| | jj| qV|S )Nr  r   r   r  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follow_symlinks)r  )r  rP  r,   r	  r
  r  r   r@  r   r   r   dirnamerk  r   extendr	   r  r  r   headers)r   r  r  r{   r  Zsource_filesrS  r  Zret_headersfiler  childdirhr   r   r   r    s4   


z Interpreter.func_install_headersrR  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 )
Nr  r   r  r?   r  	   z?Man file must have a file extension of a number between 1 and 9r  r  )r  rP  r   rsplit
IndexErrorre  r-   r	   r  r   manr   )	r   r  r  r{   r  r  r  numr   r   r   r   r    s$   

zInterpreter.func_install_manrP  r  r  c                 C  s0   t |d |d | j|d }| j j| |S )Nr   r  r  )r	   r  r   emptydirr   )r   r  r  r{   r  r   r   r   r  	  s   z!Interpreter.func_install_emptydirrT  r  Zsymlink_namepointing_tor  build.SymlinkDatac                 C  s>   |d }|d }t |||d | j|d }| j j| |S )Nr   r   r  r  )r	   r  r   r  r   )r   r  r  r{   r  r0  r   r   r   r   r  	  s   
z Interpreter.func_install_symlinkra  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   r   r-   r  from_source_filer   rd  r   r   r   r  )	r   r  r  r{   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 )r  N)r  r   r	  r   r   r   	<genexpr>H	  s    'Interpreter.<lambda>.<locals>.<genexpr>z"Objects must have a found() method)all)r  r   r   r   r
  H	  r=  )r  r6  rT  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 )Nr  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.Tr  zNonexistent build file 'r  r  r  )!r   check_direntry_issuesr-   r   r   r  r  r	  r
  r  r  r   r  realpathr  r  r  r  r  r  r  r,   r  readr   r   r   Parserparser   r  evaluate_codeblockr/   )r   r  r  r{   r   prev_subdirr   absdirsymlinkless_dir
build_filebuildfilenameabsnamer  code	codeblockmer   r   r   r  B	  s`   



zInterpreter.func_subdirmoder   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   r  	  s   z+Interpreter._warn_kwarg_install_mode_stickyrO  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 }|sb| j}ttj| j	
 |tjd|}|  rTtd	d
| jd| |d rbtdd
| jd| | |d }| j|||||d |d |d dS )Nr   r  rB  z_"rename" and "sources" argument lists must be the same length if "rename" is given. Rename has z elements and sources has r  r  z	{datadir}z9install_data() without install_dir inside of a subprojectr  zSThis was broken and would install to the project name of the parent project insteadr  z9install_data() with preserve_path and without install_dirzFThis was broken and would not add the project name to the install pathr  r  r  )r  r  )rP  r   r-   r  r  r  r	  r
  r  r   get_datadirrf  r2   r   r   r  install_data_impl)	r   r  r  r{   r  rB  r  r   r  r   r   r   r  	  s<   &zInterpreter.func_install_datar  taginstall_data_typer  r  T.Optional[bool]c	                 C  s   t |tjr	|jn|}	tt}
|r&|D ]}tj	|j
}|
| | qn|
d | g }|
 D ]!\}}t|tj||tj|	||| j||||	}|| q3| jj| |S Nr   )r   r  r  r  r   r   r   r	  r
  r  rk  r   r  r   r	   r  r  r   r  )r   r  r  r  rB  rG  rH  r  r  install_dir_namer  r  r  Zret_datar  rH  r  r   r   r   rF  	  s"   
zInterpreter.install_data_implrS  strip_directoryexclude_filesz0.42.0c                 C     t dd | D rdS d S )Nc                 s      | ]	}t j|V  qd S r  r	  r
  r  r   r  r   r   r   r(  	      r)  cannot be absoluteanyr  r   r   r   r
  	  r=  )rT  r   r6  r  exclude_directoriesc                 C  rN  )Nc                 s  rO  r  rP  rQ  r   r   r   r(  	  rR  r)  rS  rT  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 d
}| jj| |S )NrM  rV  r   z#install_subdir with empty directoryrz  r!  r  zAIt worked by accident and is buggy. Use install_emptydir instead.r  r  rL  r  r  )r  r  )r  r	  r
  r  r   rd  r   isdirrU  listdirr2   r   r   r3   r  r   r  r  r  r	   r  r  r   )	r   r  r  r{   excluder  r  	idir_nameidirr   r   r   r  	  s2   zInterpreter.func_install_subdirr@  z0.47.0,r  )r   configurationr  zUse fs.copyfile instead)rT  r6  rG  deprecated_messager  r  r   r  >   zcmake@r  r  )rT  r6  r  r  r  c                 C  s   | du rdS d S )NTzmust be `false` if booleanr   r  r   r   r   r
  
  s    output_formatrU  json>   rV  ra  rU  )rT  r6  rZ  r  
macro_name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 d0 } t,||||  d|_-n d d urt|
d$krtjd1d2| j|d t||g}|	rtj| j. |	}	|	|d3< t d |}!t&d"t|d4 |!^}"}| /|"|fddt0 d5d}# d
 rF|d6 }$ d' }t1|$d7|d8}|2|#j3 W d    n	1 s0w   Y  |r@t45|d |$ t6||$ |	rt&d9t|	 t1|	d:d8}t7|8 }%|%9|}&|&D ]}'| |' qfW d    n	1 szw   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@dA| jdB|d  dC d urȈ dC n|(d?k})|)r |(stdD|(}*t|*t<j=r|*j>}*tj	?||}+ dE },| j$j@
t$jA|+g|(|*|| j|,dFdG tj	?| j|S )HNc                 3  s     | ]} | d vr|V  qdS )r  Nr   r'  rz   r   r   r(  
  s    z2Interpreter.func_configure_file.<locals>.<genexpr>)r^  r  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.   z]Must specify one of {!r}, {!r}, and {!r} keyword arguments since they are mutually exclusive.r{  r  z=configure_file: "capture" keyword requires "command" keyword.r  r   r`  r  r  z*Inputs can only be strings or file objectsr  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 moder  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.rz  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.0rb  z#multiple inputs in configure_file()r  z	@DEPFILE@zwith command)r{  ry  r  ~r  r  zReading depfile:r  r  z1Exactly one input file must be given in copy moder  Fr   z!configure_file install_dir: falser|  z Use the `install:` kwarg insteadr  zJ"install_dir" must be specified when "install" in a configure_file is truer  	configure)r  	data_type)Br'  r   r,   r   r-   r  rP  r   r   r   r   r  r   rd  r  r  get_filenames_templates_dictsubstitute_valuesr	  r
  r  r   r  current_linenor   ri  r   r  r   r2   r   r   r   r   r   r   r	   r  r   r  do_conf_filebasenamer*  r+  dump_conf_headerusedget_scratch_dirr  r   r  
writelinesstdoutr   copymodereplace_if_differentr    	readlinesZget_all_dependenciescopy2r3   r  r  r  from_built_filer  r  )-r   r  r  r{   actionsZnum_actionsr  fmtr`  r  r  Z
inputs_absr  r  r   r  Zofile_rpathZmesonbuildfileZcurrent_callZ
first_callZ
ofile_pathZofile_fnameZ	ofile_absZconfr   r   file_encodingmissing_variablesconfdata_uselessZvar_listZifbaser.  rb  Z_cmdr  resdst_tmpr2  rk  r3  r]  r  r\  Zcfiler  r   rz   r   r{  	  s  (






zInterpreter.func_configure_filerN  r  T.List[build.IncludeDirs]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 )NrN  z(include_directories kwarg of type stringr|  zUse include_directories(z	) insteadr!  zRInclude directory objects can only be created from strings or include directories.)r   r   r   r2   r   r   r+  r	   r  r   build_incdir_objectr,   )r   r{   r  Zprospectivesr   rs  rl  r   r   r   rc  
  s"   


zInterpreter.extract_incdirs	is_system 'kwtypes.FuncIncludeDirectories'build.IncludeDirsc                 C  s   |  |d |d S )Nr   r  )r  rQ  r   r   r   r  
  s   z$Interpreter.func_include_directoriesincdir_stringsc              
   C  s  t |ts	td| j }| j }tj|| j	}tj|| j	}|D ]Z}t
t|t|r7ttdz	| | j	| W n ty\   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.)r   r   r-   r   r  r  r	  r
  r  r   r   rx   textwrapdedentvalidate_within_subprojectr,   r   ri  r+  printrY  r	   r  )r   r  r  Zsrc_rootZ
build_rootZabsbase_srcZabsbase_buildr  Z
absdir_srcZabsdir_buildr   r   r   r   r  
  s0   


zInterpreter.build_incdir_objectr9  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  r  r  )rH  	fullmatchr,   r   r	   r   r   r   r   r  rl  r2   r  test_setup_default_name	TestSetuptest_setups)r   r  r  r{   Z
setup_namer  r   r  r   r   r   rt    s,   
zInterpreter.func_add_test_setupr3  'kwtypes.FuncAddProjectArgs'c                 C  $   |  || jj|d  |d | d S Nr   r   )_add_global_argumentsr	   global_argsrQ  r   r   r   rn  9     $z%Interpreter.func_add_global_argumentsr4  c                 C  r  r  )r  r	   global_link_argsrQ  r   r   r   ro  >  r  z*Interpreter.func_add_global_link_argumentsr6  c                 C  r  r  )_add_project_argumentsr	   projects_argsrQ  r   r   r   rq  C  r  z&Interpreter.func_add_project_argumentsr8  c                 C  r  r  )r  r	   projects_link_argsrQ  r   r   r   rs  H  r  z+Interpreter.func_add_project_link_argumentsr7  (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   get_leaf_external_dependenciesr   get_compile_argsr  get_include_dirsr   to_string_listr   r  r  r  get_include_argsr  r	   r  r  get_link_args)r   r  r  r{   r/  r-  r  rS  Zsystem_incdirr   r`  r]  r   r   r   rr  M  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   ri  r+  r  )r   r  Zwarnargsrm  r%  r   r   r   _warn_about_builtin_argsb  s:   
z$Interpreter._warn_about_builtin_argsargsdictT.Dict[str, T.List[str]]c                 C  sB   |   rd|j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.)rf  r0  r   r.   r  r  _add_arguments)r   r  r  r  r{   rI  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  r{   r   r   r   r    s
   

z"Interpreter._add_project_argumentsargs_frozenc                 C  sL   |rd|j 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   )r0  r   r.   r  r  )r   r  r  r  r  r{   rI  r-  r   r   r   r    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  r2  r   r   r   r(    s    z/Interpreter.func_environment.<locals>.<genexpr>z"List of string in dictionary valuerV  r   	separator)r2   r   r   r]   r  r-   r   r   rU  r   rv   r   )r   r  r  r{   initrI  r   r   r   r    s   
 zInterpreter.func_environmentrX  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?   \/r  )	r	  r
  r  rA  r   r  r  r  r  )r   r  r  r{   partsotherretr  r   r   r   r    s   $
zInterpreter.func_join_pathsc                   sl   t    tdttt| jj t	
| j t
| j t
| j |  s4|   |   d S d S )NzBuild targets in project:)r  r  r   r   r   r   r   r	   targetsr2   reportr   r3   r4   rf  print_extra_warningsrC  r%  r!  r   r   r    s   
zInterpreter.runc                 C  s2   | j jj D ]}| dkr|    d S qd S )Nclang)r   r   r/  r   get_idcheck_clang_asan_lundef)r   rU  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 )Nb_lundef
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   r  r   r   ri  r  r  r+  )r   r   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fpathrx   r   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   rx   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  rx   r  r  r   r  )r  Zinstallablefilesr  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  rx   r   r   )rx   r   rd  r  r   r  r  r	  r
  rj  rY  r   r   r   r  ri  r   r,   r  )r   r   rk  r  ZnormZ	inputtypeZproject_rootr   r   r  r   r    s0   


z&Interpreter.validate_within_subprojectT.List['mesonlib.FileOrString']r  T.List['mesonlib.File']c                 C     d S r  r   r   r  r  r   r   r   rP       z#Interpreter.source_strings_to_filesc                 C  r  r  r   r  r   r   r   rP    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   rP    r  T.List['SourceInputs']T.List['SourceOutputs']c                 C  r  r  r   r  r   r   r   rP    r  T.List[SourcesVarargsType]c                 C  r  r  r   r  r   r   r   rP    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-  r   r   r   r  r   r  r   r   ri  r+  r  r   r   r$  rd  r	   r  r  r  r  r  r  r,   )r   r  r  resultsr  r   r   r   rP    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   FORBIDDEN_TARGET_NAMES)r  r   r   r   r  ?  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	| | | }| }||f}|| jjv rgtd
| dt|tjr|| jjv rtjd|j dd| j| jd t|tjr| |jd|j |   | !| || jj|< t|tjr| jj"|g || 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.z*multiple executables with the same name, "z/", but different suffixes in the same directoryr  r!  T))r   r  r,   stripr   r	  r
  r  r   r  r  r  r-   r  r  r  r  
get_subdirr	   r  r.   r   r  targetnamesr2   r   r   r+  r  r5  missing_languagesr/  process_compilers_lateadd_stdlib_infor  r   target_guidsr   uuiduuid4upper)r   r  r  Zpathsegidnamer   Znamedirr   r   r   r  K  sD   


zInterpreter.add_targetc                 C  s   |  |||tj}|  |||tj}| jjdkrd}n| r"d}ntdd | D r0d}n|j	}|rT|j
t||j|jg  g |_g |_dd |j D |_t||S )NxcodeFc                 s  s"    | ]\}}| d o|V  qdS ))Zstatic_argsZshared_argsN)r  r  r   r   r   r(    s     z3Interpreter.build_both_libraries.<locals>.<genexpr>c                 S  s    i | ]\}}|t jv r||qS r   )r   clink_langsr  r   r   r   r    s     z4Interpreter.build_both_libraries.<locals>.<dictcomp>)r>  r	   r  r  r   r  	uses_rustrU  r   picr[  r   r  r  	generatedr   r  )r   r  r  r{   Z
shared_libZ
static_libZreuse_object_filesr   r   r   r  t  s   z Interpreter.build_both_librariesc                 C  s   | j td| jd}t|tsJ d|dkr%| ||td|t	j
S |dkr6| ||td|t	jS |dkrA| |||S td	| d
)Ndefault_libraryr  r  sharedr  r   r  bothzUnknown default_library value: r  )r   rK  r   r   r   r   r>  Tcastr	   r  r  r  r,   )r   r  r  r{   r  r   r   r   r    s   zInterpreter.build_libraryraw+T.Tuple[T.List[mesonlib.File], T.List[str]]c                 C  sd   g }g }t | j | j }|D ]}t|t jr(|| ||| q|| q||fS )a(  Convert raw target arguments from File | str to File.

        This removes files from the command line and replaces them with string
        values, but adds the files to depends list

        :param raw: the raw arguments
        :return: A tuple of file dependencies and raw arguments
        )	r   relpathr   r  r  r   r   r   rel_to_builddir)r   r  r  r  Zbuild_to_sourcer  r   r   r   Z__convert_file_args  s   	
zInterpreter.__convert_file_args*T.Dict[str, T.List[mesonlib.FileOrString]]c                 C  sX   | dg }tt}tjD ]}| || d \}}|||< || q||d< dS )aJ  Convert split language args into a combined dictionary.

        The Meson DSL takes arguments in the form `<lang>_args : args`, but in the
        build layer we store these in a single dictionary as `{<lang>: args}`.
        This function extracts the arguments from the DSL format and prepares
        them for the IR.
        r  _argslanguage_argsN)
setdefaultr   r   r   r   all_languages_Interpreter__convert_file_argsr  )r   r{   r  new_argsr   rk  r  r   r   r   Z__process_language_args  s   

z#Interpreter.__process_language_argstargetclassT.Type[build.Executable]c                 C  r  r  r   r   r  r  r{   r  r   r   r   r>       zInterpreter.build_targetT.Type[build.StaticLibrary]c                 C  r  r  r   r  r   r   r   r>    r  T.Type[build.SharedLibrary]c                 C  r  r  r   r  r   r   r   r>    r  T.Type[build.SharedModule]c                 C  r  r  r   r  r   r   r   r>    r  T.Type[build.Jar]c                 C  r  r  r   r  r   r   r   r>    r  lT.Union[kwtypes.Executable, kwtypes.StaticLibrary, kwtypes.SharedLibrary, kwtypes.SharedModule, kwtypes.Jar]jT.Type[T.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]]bT.Union[build.Executable, build.StaticLibrary, build.SharedModule, build.SharedLibrary, build.Jar]c                   s2  |\}}|d }| ddkrtj}||d  }tdd |D r+tdd| jd	| td
d |D r>tdd| jd| dd |D }t|d tsVtdd| jd| | 	|}|d }t
|d|d< | 	|d |d< | tj| j| j|  tjtjtjtjtjhvrtdt  td| |  tju rtjdh D ] }	| | |	 dg \}
}|d |	 | |d |
 qn, tju rtjdh D ] }	| | |	 dg \}
}|d |	 | |d |
 qӈ tjur|  |  fdd|! D }g }t" }|D ]}t|tj"r || }q|#| q|s-d }nL|j$% D ]F}t& }|D ]=}t|trItj'|g}nt|t(j)rU|j*g}n|+ }|,|}|rpt-j.dd t/| |d!|0| q9q2| 1||d"<  tju rt23d#|}|d$ d ur|d% d urt-j.d&|d!|d$ rd'|d%< |d% d u rd(|d%< |d) r|d* d+u rt4jd,d| j5d-|d. d/|d*< n|d* r|d) d+u rt-d0d/|d)< |d* d u rd+|d*< |d) d u rd+|d)<  || j| j||||| j6| j| |
}| 7|| d/| _8|S )1Nr   rust_crate_typez
proc-macror  c                 s      | ]	}t |tjV  qd S r  )r   r	   r  r  r   r   r   r(    rR  z+Interpreter.build_target.<locals>.<genexpr>z4passing references to built targets as a source filer\  zpConsider using `link_with` or `link_whole` if you meant to link, or dropping them as otherwise they are ignored.c                 s  r  r  )r   r	   r  r  r   r   r   r(    rR  zpassing object files as sourceszUPass these to the `objects` keyword instead, they are ignored when passed as sources.c                 S  s"   g | ]}t |tjtjfs|qS r   )r   r	   r  r  r  r   r   r   r    s    
z,Interpreter.build_target.<locals>.<listcomp>r  z$install kwarg with non-boolean valuer  zjThis was never intended to work, and is essentially the same as using `install: true` regardless of value.r[  r   rX  zUnknown target type:zUnreachable coder   r   r  r  r   c                   s&   i | ]\}}| j d hB v r||qS )r  )known_kwargsr  r  r   r   r    s   & z,Interpreter.build_target.<locals>.<dictcomp>z+Conflicting sources in structured sources: r  r  rN  r  gui_appwin_subsystemzZExecutable got both "gui_app", and "win_subsystem" arguments, which are mutually exclusivewindowsr  implibexport_dynamicFz+implib overrides explict export_dynamic offzCDo not set ths if want export_dynamic disabled if implib is enabledr!  TzM"implib" keyword" must not be false if "export_dynamic" is set and not false.)9r  r   r%  rU  r4   r   r   r   r   rP  r   check_sources_existr	  r
  r  r  r   r	   r  r  r  r  r  r   rB  r   rE  #_Interpreter__process_language_argsr   r  r  r  kwarg_strings_to_includedirsr   r  r   r  r   r  rm  r   r   rk  get_outputsintersectionr-   r  r'  r  rc  r  r  r3   Z	subprojctr   r  r  )r   r  r  r{   r  r  r  r/  Zobjsr-  rk  srcsstructr  r   r  r  r  	conflictsr0  r   r  r   r>    s   











kwtypes._BuildTargetc                 C  s   |d rI|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 )NrU  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   r	  r
  r
  r  r   r  r   ri  r+  r  r  r   r  r   )r   r{   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  add_deps)r   r0  r   r3  r   r   r   r  n  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  )r   r   r	  r
  r  r  r,   )r   r   r  r  rk  r   r   r   r  t  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 rJ  r  r%  r   r   r   rf    s   
zInterpreter.is_subprojectr`  T.Tuple[str, object]c                 C  s   |\}}| j ||dd d S )NT)	holderify)r`  )r   r  r  r{   varnamer   r   r   r   r    s   zInterpreter.func_set_variablerL  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  )r   r0   r  r*  
_holderifyr,   )r   r  r  r{   r  r   r   r   r   r    s   
zInterpreter.func_get_variablerV  c                 C  s   |d | j v S r   r  rQ  r   r   r   r    rR  zInterpreter.func_is_variablerg  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  r{   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  r   r   r-   r   r%  r#  )r{   r   r   r   r   r)    s   
z%Interpreter.machine_from_native_kwargrU  T.Tuple[object]c                 C  s   t |d tS r   )r   r0   rQ  r   r   r   r    s   zInterpreter.func_is_disablerr]  .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  r{   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   r   r   )r   r#  )r   r   )r  r  r  r  r   r   )r  r  r   r   )r  r   r  r  r   r   )r   r  )r  r  r   r   )r   r  )r  r  r  r7  r{   r8  r   r9  )r  rL  r  rM  r{   rN  r   rO  )r  r  r  r]  r{   r^  r   r_  )r  rL  r  rn  r{   rN  r   r   )r  r  r  r}  r{   r~  r   rF   )F)r  r}  r{   r~  r  r   r   rF   )r  r  r  r7  r{   r  r   rD   )NN)r  r   r  r   rj  r  r   rD   r  )r  r   r{   r  r  r  r   rD   )NNN)r  r   r   r   r   r  r{   r  r   r   r  r  r   r   r   rD   )
r  r   r   r   r   r  r{   r  r   rD   )r  r   r   r  )r  r  r  r7  r{   rN  r   r  )r  r  r  r  r{   rN  r   r  )r  rL  r  r  r{   r  r   r   )r  rL  r  rM  r{   r$  r   r   )r  r]  r0  r   r   r1  )r  r  )r  r  r  r9  r{   r:  r   r   )r   r   r{   r:  r   r   )r  r  r  r7  r{   r   r   r7   )r  r1  r   r   r/  r   r   r   )r/  r   r   r   )r/  r   ra  rb  r   rc  )r  rb  rf  r1  rg  rh  r   rc  )rn  rb  rg  ro  r   rp  )rn  rb  r   r   )r  r   r  ru  r   r   )r  rb  r   r   )r  rb  r/  r   r   rx  r   r   r  r   rw  ry  rf  r  rz  r{  r   r|  )r  rb  r/  r   r   rx  r   r   rf  r1  rw  ry  rz  r{  rg  rh  r   r  )
r  r  rw  ry  rz  r{  rg  rh  r   r   )r   r   r  rb  r   r  r   r   rg  rh  r   r  )r  r  r  r  r{   r  r   r  )r  r  r  rM  r   r   )r  r  r  r  r{   r  r   r  )r  r  r  r  r{   r  r   r  )r  r  r  r  r{   r  r   r  )r  r  r  r  r{   r  r   r  )r  r  r  r  r{   r  r   r  )r  r  r  r  r{   r  r   r  )r  r  r  r  r{   r  r   r  )r  r  r  r  r{   r  r   r  )r  r  r  r  r{   r  r   r  )r  r  r  r~   r{   r   r   r  )r  r   r  r  r  r   r   r   )r  rL  r  r7  r{   r  r   r  )r  rL  r  r7  r{   r  r   r  )r  r  r  r  r{   rN  r   r  )r  rL  r  r  r{   r  r   r  )r  r  r  r  r{   r  r   r   )r  r  r  r  r{   r  r   r   )r{   r   r   r   )r  r  r  r  r{   r  r   rE   )r  r  r  r  r{   r   r
  r   )r  r  r  r  r{   r  r   r  )r  r  r  r  r{   r  r   r  )r  r  r  r7  r   r   )r  r  r  rM  r   r!  )r  r  r  r"  r{   rN  r   r#  )r  r  r  r7  r{   r+  r   r   )r<  r   r   r   )r  r  r  r  r{   rC  r   rD  )NFN)r  rO  r  r   r  r   rB  r   rG  r   rH  r   r  r   r  rI  r   rD  )r  r  r  r7  r{   rW  r   rX  )r  r  r  r]  r{   rc  )rN  )r  r   r   r  )r  r  r  rM  r{   r  r   r  )r  r1  r  r   r   r  )r  r  r  r7  r{   r  r   r   )r  rL  r  rM  r{   r  r   r   )r  rL  r  r  r{   r  r   r   )r  r1  r   r   )
r  rL  r  r  r  r1  r{   r  r   r   )
r  rL  r  r  r  r1  r{   r  r   r   )r  rL  r  r  r  r   r  r1  r{   r  r   r   )r  rL  r  r  r{   rN  r   r   )r  r  r  rM  r{   rN  r   r   )T)r  r  r  r   r   r  )r  r  r  r   r   r  )r  r  r   r  )r  r  r  r   r   r  )r  r  r  r   r   r  )r  r   r   r   )r  r   r  r  r   r   )r  r  r  r  r{   r  )r  rb  r   r  )r{   r  r   r   )
r  r  r  r  r{   r  r  r  r   r  )
r  r  r  r  r{   r  r  r  r   r  )
r  r  r  r  r{   r  r  r  r   r  )
r  r  r  r  r{   r  r  r  r   r  )
r  r  r  r  r{   r  r  r  r   r  )
r  r  r  r  r{   r  r  r  r   r  )r{   r  r   r   )r  r  r   r   )r   r   )r  r  r  r  r{   rN  r   r   )r  r  r  r  r{   rN  r   r  )r  r  r  r7  r{   rN  r   r   )r  r  r  r7  r{   rN  r   r   )r{   r   r   r   )r  r  r  r  r{   rN  r   r   )r  r  r{   r   r   r  )r   r   r   r   r&  r   r  r  r  r  r  r   r  r  r  r4  r%   r   r$   rl   r  r[   r1   r  r'   r  r&   r#   r!   r   r`   r\   rW   re   rf   ro   r   r   rr   rt   r	   r  r~  r   rv  rx  r  r   r   r  r]   r  r  r  rV   r  r  r  r  r  r  r  r  r   rz  r  r   r  rp  r4  r)   r  r5  r2   objectr  r;  rC  r  r  r}  r  ru   r  r5  rR  rO  re  rm  rr  rt  rv  rw  r   r#  r  r  r  r  rj   r  r5   r(   permitted_dependency_kwargsr  r  known_exe_kwargsrp   rQ   r  known_stlib_kwargsrq   r  known_shlib_kwargsrm   r  known_library_kwargsrS   rx  known_shmod_kwargsrn   r  r  known_jar_kwargsr  r  r  r  rR   r  known_build_target_kwargsrJ   ry  rO   rT   r  r  staticmethodr  rK   rL   rM   rN   rP   rg   rX   rY   rZ   ra   rc   r|  r  Targetru  r  r  rs   rw  r  r  r	  r  rk   rb   rd   r  r  r  rh   r  r  r  r  r  rF  r  r   r  rU   r{  rc  r  r  rt  ri   rn  ro  rq  rs  r   r   rr  r  r  r  r  r^   r_   r  r  r  r  r  r  r  overloadrP  r  r  r  r  r  r  r>  r  r  r  r  rf  r*   r  r0   r+   r  r  r  r)  r  r  rM  r   r   r!  r   r     sJ   ABA#


=

$

L

M=#  
(
?)	&
((
5

] 	+
 



3	

 

"
% 
C	

, 
)$|	


r   )r   r   r   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   r   r   r   programsr   r   r   r  r    interpreterbaser!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r   r9   r:   r;   r<   r=   r>   r@   r1  rA   r  	mesonmainrB   ZdependencyfallbacksrC   rD   rE   rF   rG   rH   rI   Ztype_checkingrJ   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   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   r  pathlibrx   enumry   r	  r   r  rH  r  r   typingr  r  rB  r  TYPE_CHECKINGargparser{   ZkwtypesZbackend.backendsr|   Zinterpreterbase.baseobjectsr}   r~   r   r   r   Unionr   r  r  r  r  r  r  r   ZSourceInputsr  ZSourceOutputsFileOrStringZGeneratedTypesZBuildTargetSourceCallabler  ZProgramVersionFuncr   r   r"  r!  r  r#  r   r%  r&  r   r  r  r   r   r   r   r   <module>   s   <  /
G
