
    -PhuG                       d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	ddl
mZ ddl
mZ ddl
mZ ddl
mZ ddl
mZ 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 ddlmZ ej        r2d dlmZ d dlZ G d dej        e          Zej        e ej!        f         Z"d'dZ#d(dZ$ G d dej%                  Z& G d d          Z'd)d!Z(d)d"Z)d*d%Z*d+d&Z+dS ),    )annotationsN   )build)coredataoptions)environment)mesonlib)mintro)mlog)AstIDGeneratorIntrospectionInterpreter)MachineChoice)	OptionKey)OptionInterpreter)Protocolc                  8    e Zd ZU ded<   ded<   ded<   ded<   dS )	
CMDOptionsstrbuilddirbool
clearcachepagerzT.List[str]
unset_optsN)__name__
__module____qualname____annotations__     P/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mesonbuild/mconf.pyr   r      s<         r    r   parser'argparse.ArgumentParser'returnNonec                    t          j        |            |                     ddd           |                     dddd	           |                     d
ddd           |                     dddg d           d S )Nr   ?.)nargsdefaultz--clearcache
store_trueFz,Clear cached state (e.g. found dependencies))actionr*   helpz
--no-pagerstore_falser   z!Do not redirect output to a pager)r,   destr-   z-Uappendr   zRemove a subproject option.)r,   r/   r*   r-   )r   register_builtin_argumentsadd_argument)r"   s    r!   add_argumentsr3   +   s    '///

#s;;;
|UK  M M M
]@  B B B
XL":  < < < < <r    valT.Anyr   c                   t          | t                    r!t          |                                           S t          | t                    r%d                    d | D                       }d| dS | dS t          |           S )Nz, c              3  4   K   | ]}t          |          V  d S N)	stringify).0is     r!   	<genexpr>zstringify.<locals>.<genexpr>9   s(      00qill000000r    [] )
isinstancer   r   lowerlistjoin)r4   ss     r!   r9   r9   5   s~    #t 3xx~~	C		 II00C000001xxx	r3xxr    c                      e Zd ZdS )ConfExceptionN)r   r   r   r   r    r!   rF   rF   A   s        Dr    rF   c                  v    e Zd Zd dZd!dZd!dZd!dZd"dZd#dZd$dZ	d%dZ
d&dZd'dZd(dZd!dZd!dZdS ))Conf	build_dirr   c                \
   t           j                            t           j                            |                    | _        dt           j                            | j                  | j        fv r)t           j                            | j                  | _        d | _        d| _        g | _	        g | _
        g | _        g | _        t                      | _        t           j                            t           j                            | j        d                    rt          j        | j                  | _        | j        j                                        | _        | j        j        j        | _        d| _        | j        j                                        D ]x\  }}| t           j                            |d                   r|d         }t5          |d          5 }t7          j        |                                                                          }||d         k    ret?          | j        j         |          }|!                    |           | j        j         "                    |j#        |           ||f| j        j        |<   d d d            n# 1 swxY w Y   	t           j                            | j        d          }t           j                            |          s%t           j                            | j        d	          }t           j                            |          rt?          | j        j         |          }|!                    |           | j        j         "                    |j#        |           t5          |d          5 }t7          j        |                                                                          }d d d            n# 1 swxY w Y   ||f| j        j        |<   X| j        j         "                    i |           zd S t           j        $                    t           j                            | j        t$          j%                            rtM          j'                    5  t           j                            t           j                            | j                            | _        tQ          | j        d
dtS                      g          }|*                                 d d d            n# 1 swxY w Y   |j        | _        d| _        d S tW          d| d          )Nzmeson.build<   zmeson-privateFr   rbr   zmeson.optionszmeson_options.txtr?   ninja)visitorsTz
Directory zC is neither a Meson build directory nor a project source directory.),ospathabspathrealpathrI   basenamedirnamer   max_choices_line_lengthname_col	value_colchoices_col	descr_colsetall_subprojectsisdirrC   loadr	   get_source_dir
source_dirr   default_values_onlyoptions_filesitemsexistsopenhashlibsha1read	hexdigestr   optstoreprocessupdate_project_optionsr   isfilebuild_filenamer   
no_loggingr   r   analyzerF   )	selfrI   subconf_optionsopfilefophashoiintrs	            r!   __init__zConf.__init__F   s   )9)9))D)DEERW--dn==t~NNNW__T^<<DN
')$)+*,,.*,+.557==dnoFFGG )	}DN33DJ"j4CCEEDO J2;DM',D$
 &*]%@%F%F%H%H O O!\+|A0O0O+)!_Ffd++ Pq!(affhh!7!7!A!A!C!C!\!_44!24=3I3!O!OBJJv... M2II"*VYZZZ@F?ODM7<P P P P P P P P P P P P P P P  W\\$/?KKF7>>&11 T!#do?R!S!Sw~~f-- O.t}/EsKK

6***.EEbjRUVVV!&$// H1%,\!&&((%;%;%E%E%G%GFH H H H H H H H H H H H H H H<BF;K3C88.EEb#NNNN-O O. W^^BGLL9STTUU 		}""  "$'//"'2B2B4>2R2R"S"S/WZhZjZjYklll               !MDM'+D$$$ {Y { { {|||s8   B*JJ	J		9OO	O	/B S;;S?S?r$   r%   c                8    | j                                          d S r8   )r   clear_cacherp   s    r!   rz   zConf.clear_cache}   s    !!#####r    c                V    | j         rd S t          j        | j        | j                   d S r8   )r`   r   saverI   r{   s    r!   r}   z	Conf.save   s.    # 	FdmT^44444r    c                   t          j        d          d         }t          |dz  d          }|d|z  z
  dz
  }||||dk    r|n|ft          | j        | j        | j        | j                  D ]}t          |          st          j
        d           '|d         r2t          |dd	                   st          j
        |d                    add} ||d         d                   } ||d         d                   } ||d         d                   } ||d         d                   }	t          j        ||||	d          D ],fdt          d          D             }
t          j
        |
  -d	S )a  Do the actual printing.

        This prints the generated output in an aligned, pretty form. it aims
        for a total width of 160 characters, but will use whatever the tty
        reports its value to be. Though this is much wider than the standard
        80 characters of terminals, and even than the newer 120, compressing
        it to those lengths makes the output hard to read.

        Each column will have a specific width, and will be line wrapped.
        )   r   )fallbackr            r   r?   NtextLOGLINEwidthintr$   mlog.TV_LoggableListc                j    t           t          j                  r j        n }|                    d          rdnd}t          j        ||          }t           t          j                  r"t          j        d fd|D                       }nt          j        d|          }fd|D             S )Nr=    r?   )subsequent_indentzT.List[LOGLINE]c                D    g | ]}t          j        |j                  S r   )r   AnsiDecoratorcode)r:   r;   r   s     r!   
<listcomp>z9Conf.print_aligned.<locals>.wrap_text.<locals>.<listcomp>   s)    8l8l8l^_9KAty9Y9Y8l8l8lr    c                Z    g | ]'}t          |          d t          |          z
  z  z   (S r   )r   len)r:   r;   r   s     r!   r   z9Conf.print_aligned.<locals>.wrap_text.<locals>.<listcomp>   s3    IIIAAA!77IIIr    )	r@   r   r   r   
startswithtextwrapwrapTcast)r   r   rawindentwrapped_wrappeds   ``    r!   	wrap_textz%Conf.print_aligned.<locals>.wrap_text   s    #-dD4F#G#GQdiiT #s 3 3;#=evNNN dD$677 Bf%68l8l8l8lck8l8l8lmmGGf%6AAG JIIIIIIIr       )	fillvaluec                F    g | ]}|         r|         n
d |         z  S r   r   )r:   r;   four_columnls     r!   r   z&Conf.print_aligned.<locals>.<listcomp>   s3    RRRA1?13Q+?RRRr       )r   r   r   r   r$   r   )shutilget_terminal_sizemaxziprV   rW   rX   rY   anyr   log	itertoolszip_longestrange)rp   total_width_collast_columnliner   namer4   choicedescrb   r   r   s              @@r!   print_alignedzConf.print_aligned   s    .AAA!D;!#R((!QX.2T4aTRt~t7GXX #	! #	!Dt99  Aw s48}} a!!!J J J J$ 9T!Wk!n55D)DG[^44CYtAwA77F9T!Wk!n55D*4fdbQQQ ! !RRRRRqRRR%   !C#	! #	!r    opts@T.Union[options.MutableKeyedOptionDictType, options.OptionStore]/T.Dict[str, options.MutableKeyedOptionDictType]c                    i }|                                 D ]I\  }}|j        r| j                            |j                   ||                    |j        i           |<   J|S r8   )rb   
subprojectr[   add
setdefault)rp   r   resultkos        r!   split_options_per_subprojectz!Conf.split_options_per_subproject   si    BDJJLL 	7 	7DAq| 7$((66656FalB//22r    r   r   valuechoicesdescrc                T   t          |t          j                  rd| j        z  |j        z   |_        nd| j        z  |z   }| j                            |           | j                            |           | j                            |           | j	                            |           d S )Nr   )
r@   r   r   print_marginr   rV   r0   rW   rX   rY   )rp   r   r   r   r   s        r!   	_add_linezConf._add_line   s    dD.// 	2d//$);DII**T1DT"""e$$$(((e$$$$$r    r5   c                    t          |          }t          |          }|                     t          j        |          t          j        |          t          j        |          |           d S r8   )r9   r   r   greenyellowblue)rp   r   r   r   r   s        r!   
add_optionzConf.add_option   sY    %  G$$tz$''U););TYw=O=OQVWWWWWr    titlec           	        t          j        |          }t          j        d          }t          j        | j        rdnd          }t          j        d          }|                     dddd           |                     ||||           |                     dt	          |          z  dt	          |          z  dt	          |          z  dt	          |          z             d S )NDescriptionzDefault ValuezCurrent ValuezPossible Valuesr?   -)r   cyanr`   r   r   )rp   r   newtitler   r   r   s         r!   	add_titlezConf.add_title   s    9U##	-((	T-EZ//?[[)-..r2r2&&&x777sS]]*C#e**,<cCLL>PRUX[\aXbXbRbcccccr    sectionc                    d| _         |                     dddd           |                     t          j        |dz             ddd           d| _         d S )Nr   r?   :r   )r   r   r   normal_yellow)rp   r   s     r!   add_sectionzConf.add_section   sW    r2r2&&&t)'C-88"b"EEEr    c                   |sd S |r|                      |           t          |                                          D ]M\  }}|                                }|                     |j        |j        ||                                           Nd S r8   )r   sortedrb   printable_valuer   r   descriptionprintable_choices)rp   r   r   r   r   r   s         r!   print_optionszConf.print_options   s     	F 	"NN5!!!4::<<(( 	[ 	[DAq//11O OOAFAM?ADWDWDYDYZZZZ	[ 	[r    r   r   c                n    |rt          j                     dd} j        r |             t          j        d           t          j        d           t          j        d j                    j        st          j        d j                   t          t          j                  }t          d          t          d	          h}i }i }i }t          j        t                    } j        j        j                                        D ]\  }	}
|	|v r|
||	<   |	|v r|
||	<   |	                                r6|	                                } j        r| j        j        vrW|
||         |	<   c j        j                            |	          r|
||	<                        d
 |                                D                       }                     d |                                D                       }                      fd j        j                                        D                       }                      fd j        j                                        D                       }                      fd j        j                                        D                       } j        p j        j                                        }                     d                                d|d                     |r|r                     d|d                                          d fd j        j                                        D                                             d fd j        j                                        D                                             d|                    di                      |r*                     d|                    di                      |                                D ]\  }}                     | d|                                d|                                d|                                d|                    di                      t7           j                  D ]}|dk    r	                     d|z              ||v r                     d||                    ||v r|r                     d||                    ||v r                     d||                    ||v r|r                     d||                    ||v r                     d||                    Ɖ                                   j        rt          j        d            |                                                                                 d S )Nr$   r%   c                 V    t          j        d           t          j        d           d S )NzBThe source directory instead of the build directory was specified.z4Only the default values for the project are printed.)r   warningr   r    r!   print_default_values_warningz5Conf.print_conf.<locals>.print_default_values_warning   s*    L]^^^LOPPPPPr    r?   zCore properties:z  Source dirz  Build dir 	errorlogsstdsplitc                @    i | ]\  }}|j         t          j        u ||S r   )machiner   HOSTr:   r   vs      r!   
<dictcomp>z#Conf.print_conf.<locals>.<dictcomp>  sU      ?I  ?I  ?I1hihq  vC  vH  iH  iHq!  iH  iH  iHr    c                @    i | ]\  }}|j         t          j        u ||S r   )r   r   BUILDr   s      r!   r   z#Conf.print_conf.<locals>.<dictcomp>  sX      @K  @K  @KAijir  wD  wJ  jJ  jJ1  jJ  jJ  jJr    c                    i | ]:\  }}j         j                            |          $|j        t          j        u 7||;S r   )r   ri   is_compiler_optionr   r   r   r:   r   r   rp   s      r!   r   z#Conf.print_conf.<locals>.<dictcomp>  s      CH  CH  CHDAqvz  wD  wM  w`  w`  ab  wc  wc  CH  hi  hq  uB  uG  hG  hG1a  hG  hG  hGr    c                    i | ]:\  }}j         j                            |          $|j        t          j        u 7||;S r   )r   ri   r   r   r   r   r   s      r!   r   z#Conf.print_conf.<locals>.<dictcomp>  s      DJ  DJ  DJTQPQw{  xE  xN  xa  xa  bc  xd  xd  DJ  ij  ir  vC  vI  iI  iIAq  iI  iI  iIr    c                Z    i | ]'\  }}j         j                            |          $||(S r   )r   ri   is_project_optionr   s      r!   r   z#Conf.print_conf.<locals>.<dictcomp>   sg      =]  =]  =]daptp}  qG  qY  qY  Z[  q\  q\  =]Q  =]  =]  =]r    zMain project optionszCore optionszBackend optionsc                Z    i | ]'\  }}j         j                            |          $||(S r   )r   ri   is_backend_optionr   s      r!   r   z#Conf.print_conf.<locals>.<dictcomp>'  sc      /O  /O  /O1bfbobx  cK  cK  LM  cN  cN  /Oq!  /O  /O  /Or    zBase optionsc                Z    i | ]'\  }}j         j                            |          $||(S r   )r   ri   is_base_optionr   s      r!   r   z#Conf.print_conf.<locals>.<dictcomp>(  sc      ,I  ,I  ,ITQ_c_l_u  `E  `E  FG  `H  `H  ,IAq  ,I  ,I  ,Ir    zCompiler optionsz module optionsDirectorieszTesting optionszProject optionszSubproject r$   r%   ) r   start_pagerr`   r   r_   rI   rZ   r   BUILTIN_DIR_OPTIONSr   collectionsdefaultdictdictr   ri   rb   has_module_prefixget_module_prefixr   modulesis_builtin_optionr   r	   is_cross_buildr   r   getr   r[   r   "print_nondefault_buildtype_optionsprint_augments)rp   r   r   dir_option_namestest_option_namesdir_optionstest_optionscore_optionsmodule_optionsr   r   modnamehost_core_optionsbuild_core_optionshost_compiler_optionsbuild_compiler_optionsproject_optionsshow_build_optionsmodmod_optionsr   s   `                    r!   
print_confzConf.print_conf   s    		Q 	Q 	Q 	Q # 	((***HRLLL#$$$111' 	5H^T^444w:;;&{33&z224 ;=;=;=JUJabfJgJgM*288:: 	$ 	$DAq$$$!"A'''"#Q$$&& $ --//: '1C"C"C-.w'**'99!<< $"#Q ==  ?I  ?IP\PbPbPdPd  ?I  ?I  ?I  J  J!>>  @K  @KQ]QcQcQeQe  @K  @K  @K  L  L $ A A  CH  CH  CH  CHTXTaTjTpTpTrTr  CH  CH  CH  !I  !I!%!B!B  DJ  DJ  DJ  DJUYUbUkUqUqUsUs  DJ  DJ  DJ  "K  "K;;  =]  =]  =]  =]dmNdNjNjNlNl  =]  =]  =]  ^  ^!5`9O9^9^9`9`/000>+<T+BCCC 	="4 	=r#5d#;<<<,  /O  /O  /O  /O@V@\@\@^@^  /O  /O  /O  	P  	P  	P>  ,I  ,I  ,I  ,IT]=S=Y=Y=[=[  ,I  ,I  ,I  	J  	J  	J-/D/H/HR/P/PQQQ 	Gr#9#=#=b"#E#EFFF . 4 4 6 6 	E 	EC#666DDDD=+666,l;;;,o.A.A"b.I.IJJJ !566 	S 	SJR]Z7888..."">3DZ3PQQQ///4F/""2'9*'EFFF222""#57LZ7XYYY3338J3""2'=j'IJJJ_,,""#4oj6QRRR # 	+HRLLL((***//111r    c                    | j                                         }|sd S t          j        d           t          j        d           |D ]1}t          j        |d         d|d         d|d         d           2d S )NzL
The following option(s) have a different value than the build type default
z                current   defaultr   21r   10r   )r   get_nondefault_buildtype_argsr   r   )rp   mismatchingms      r!   r  z'Conf.print_nondefault_buildtype_optionsI  s    mAACC 	Fabbb3444 	5 	5AH!33133!A$3334444	5 	5r    c                   | j         j        j        rYt          j        d           | j         j        j                                        D ]\  }}t          j        |d|d            d S t          j        d           d S )Nz
Currently set option augments:r  r  z
There are no option augments.)r   ri   augmentsr   r   rb   )rp   r   r   s      r!   r  zConf.print_augmentsR  s    =!* 	8H7888.7==?? * *1A!))))* * H677777r    N)rI   r   r   )r   r   r$   r   )
r   r   r   r   r   r   r   r   r$   r%   )
r   r   r   r   r   r5   r   r5   r$   r%   )r   r   r$   r%   )r   r   r$   r%   )r   r   r   r   r$   r%   )r   r   r$   r%   )r   r   r   rx   rz   r}   r   r   r   r   r   r   r   r  r  r  r   r    r!   rH   rH   E   s/       5} 5} 5} 5}n$ $ $ $5 5 5 53! 3! 3! 3!j   % % % %X X X X
d d d d   [ [ [ [S S S Sj5 5 5 58 8 8 8 8 8r    rH   r   r   c                *    | j         rdS | j        rdS dS )NTF)cmd_line_optionsr   r   s    r!   has_option_flagsr  Z  s'     t t5r    c                :    t          |           rdS | j        rdS dS )NFT)r  r   r   s    r!   is_print_onlyr  a  s,       u u4r    r   r   c                   t          |           }d }	 t          |          }|j        r|st          j        d          |j        s|r|                    | j                   dS d}t          |           r2||j        	                    |           z  }t          j
        ||            | j        r|                                 d}|rW|                                 t          j        |j        |j        j        j                   t          j        |j        g            nW# t(          $ r?}t+          j        d           |"|j        t          j        |j        |g           |d }~wt.          $ r Y nw xY wdS )Nz6No valid build directory found, cannot modify options.r   FTz(Meson configurator encountered an error:)r  rH   r`   r
   MesonExceptionr  r   r  r   set_from_configure_commandupdate_cmd_line_filer   rz   r}   r   update_build_optionsr   r	   info_dirwrite_meson_info_filerF   r   r   BrokenPipeError)r   r   
print_onlycr}   es         r!   run_implr+  h  s   w''JANN  	d 	d)*bccc  	J 	LL'''1G$$ 	=AJ99'BBBD)(G<<< 	MMOOOD 	6FFHHH'
AG4G4PQQQ("555   ;<<<=QW0(1#666    1s%   AD $B9D 
E2(:E""E21E2c                    t          j        |            t          j                            t          j                            | j                            }t          | |          S r8   )r   parse_cmd_line_optionsrO   rP   rQ   rR   r   r+  )r   r   s     r!   runr.    sI    #G,,,wrw//0@AABBHGX&&&r    )r"   r#   r$   r%   )r4   r5   r$   r   )r   r   r$   r   )r   r   r   r   r$   r   )r   r   r$   r   ),
__future__r   r   re   r   rO   r   typingr   r   r?   r   r   r   r	   r
   r   r   astr   r   r   r   optinterpreterr   TYPE_CHECKINGtyping_extensionsr   argparseSharedCMDOptionsr   Unionr   r   r   r3   r9   r!  rF   rH   r  r  r+  r.  r   r    r!   <module>r8     sx  
 # " " " " "       				                                                    9 9 9 9 9 9 9 9 # # # # # #       - - - - - -? /******OOO         X.       gc4--.G< < < <	 	 	 		 	 	 	 	H+ 	 	 	S8 S8 S8 S8 S8 S8 S8 S8j         @' ' ' ' ' 'r    