
    -Ph$                    v   d dl mZ d dlZd dlZd dlZd dlZddlmZ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 dd
lmZmZmZmZmZ ddlmZmZ ddlmZ ej        r4ddlmZ ddlmZ ddl m!Z! d dl"m#Z#  G d de#          Z$ G d de#          Z% G d dej&                  Z' G d de          Z(ddZ)dS )    )annotationsN   )ExtensionModule
ModuleInfo)ModuleReturnValue   )mesonlibbuild)mlog)DEPEND_FILES_KW
DEPENDS_KWINCLUDE_DIRECTORIES)ContainerTypeInfo
FeatureNew	KwargInfotyped_kwargstyped_pos_args)MachineChoiceMesonException)ExternalProgram)ModuleState)Compiler)Interpreter)	TypedDictc                  8    e Zd ZU ded<   ded<   ded<   ded<   d	S )
CompileResourcesT.List[mesonlib.FileOrString]depend_files6T.List[T.Union[build.BuildTarget, build.CustomTarget]]dependsz'T.List[T.Union[str, build.IncludeDirs]]include_directorieszT.List[str]argsN__name__
__module____qualname____annotations__     Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/mesonbuild/modules/windows.pyr   r      sB         3333GGGGDDDDr)   r   c                  L    e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   ded<   dS )RcKwargsstroutputz?T.List[T.Union[mesonlib.FileOrString, build.CustomTargetIndex]]inputzT.Optional[str]depfiler   r   r   r    z%T.List[T.Union[str, ExternalProgram]]commandNr#   r(   r)   r*   r,   r,   #   sW         NNNN    3333GGGG666666r)   r,   c                      e Zd ZdZdZdZdS )ResourceCompilerTyper   r      N)r$   r%   r&   windresrcwrcr(   r)   r*   r3   r3   +   s        G	
B
CCCr)   r3   c                  0    e Zd Z ed          Zd fdZdd	ZddZ ede	e
j        ej        ej        fd           ed ej        d           ej        d          e ed eee	          g d                    dd                        Z xZS )WindowsModulewindowsinterpreter'Interpreter'c                    t                                          |           d | _        | j                            d| j        i           d S )Ncompile_resources)super__init___rescompmethodsupdater>   )selfr;   	__class__s     r*   r@   zWindowsModule.__init__4   sS    %%%TX!7
 	 	 	 	 	r)   	compilersT.Dict[str, 'Compiler']return
'Compiler'c                F    dD ]}||v r
||         c S t          d          )N)ccppz2Resource compilation requires a C or C++ compiler.)r   )rD   rF   ls      r*   detect_compilerzWindowsModule.detect_compiler;   s>     	$ 	$AI~~ |### QRRRr)   state'ModuleState'.T.Tuple[ExternalProgram, ResourceCompilerType]c                j   t           j        }| j        r| j        S t          j        |j        |d          }|r|                                sk|                     |j        j        j	        |                   }|j
        dv s|j        r |j        j
        dv rt          dd          }nt          dd          }|                                st          d          dd	t          j        fdd
t          j        fddt          j        fddt          j        ffD ]\  }}}t#          j        |                                |gz             \  }}	}
t)          j        ||	t(          j                  }|r4t/          j        d|                                z             ||f| _         nt          d          | j        S )Nr5   >   clang-clintel-clmsvc>   lld-linklinkr6   T)silentz(Could not find Windows resource compilerz/?z"^.*Microsoft.*Resource Compiler.*$zLLVM Resource Converter.*$z	--versionz^.*GNU windres.*$z^.*Wine Resource Compiler.*$zWindows resource compiler: %sz5Could not determine type of Windows resource compiler)r   HOSTrA   r   from_bin_listenvironmentfoundrN   coredatarF   idlinkerr   r3   r6   r5   r7   r	   
Popen_safeget_commandresearch	MULTILINEr   loggroup)rD   rO   for_machinerescompcompargmatchrc_typepoems               r*   _find_resource_compilerz%WindowsModule._find_resource_compilerA   s    $(= 	!=  "/0A;PYZZ 	Bgmmoo 	B''(9(B(L[(YZZDw:::t{:t{~auOuOu)$t<<<))DAAA}} 	M !KLLL ;=Q=TU35I5LM13G3OP<>R>VW	&
 	Z 	Z!S% )'*=*=*?*?3%*GHHGAq!	%BL11A 817799DEEE!(' 2
 !!XYYY}r)   zwindows.compile_resourcesr   )varargsmin_varargsz0.47.0)sincer"   T)defaultlistifyYT.Tuple[T.List[T.Union[str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex]]]kwargs'CompileResources'r   c                T   |d                                          }|d         }|d         }|D ]}t          |t          j                  rj|                    t          j        dg dt          j                            d| j	        j
                            |                    g          g          z  }|                    |d                   z  }|                               \  }}	|	t          j        k    r
d}
|g d	z   }nW|	t          j        k    r>d
}
|ddgz   }d}|D ]/}d|v r)t!          j        |                    |          d           0n	d
}
|g dz   }g }dfd} |            D ]'\  }}}|                    dd                              dd                              dd          }|                    dd                              dd                              dd          }| d|
 }g }|                    |           |                    |           d }|	t          j        k    r| d}|                    g d           |                    t          j        |j        j        j        ||g|g|||d                     )t3          ||g          S )Nr"   r   r     Fz@BUILD_ROOT@r!   res)z/nologoz/fo@OUTPUT@@INPUT@rn   r}   @OUTPUT@zArgument {!r} has a space which may not work with windres due to a MinGW bug: https://sourceware.org/bugzilla/show_bug.cgi?id=4933 )fatal)r}   z-or~   rH   ST.Iterable[T.Tuple[str, str, T.Union[str, mesonlib.File, build.CustomTargetIndex]]]c               3    K   d         D ]} t          | t                    r+t          j                            j        |           | | fV  Ct          | t          j                  r|                                 | j	        | fV  |t          | t          j                  rt          j        ddj        j                   |                                  d| j                                                            | j                   d|                                  | fV  t-          |                                           dk    r"t          j        ddj        j                   t/          |                                           D ]/\  }}|                                  d| d| d| | |         fV  0d S )	Nr   zBwindows.compile_resource CustomTargetIndex in positional argumentsz0.61.0)location_windows_compile_resources_r   zSwindows.compile_resource CustomTarget with multiple outputs in positional arguments)
isinstancer-   ospathjoinsubdirr	   Filerelative_namefnamer
   CustomTargetIndexr   
single_use
subprojectcurrent_nodeget_idtargetget_outputsindexr.   get_filenamelen	enumerate)srcioutr"   rO   s      r*   	get_namesz2WindowsModule.compile_resources.<locals>.get_names   s     Aw d dc3'' d',,u|S993CCCCCX]33 d++--sy#=====U%<== d)*npx*/*:UEWY Y Y Y "jjllYYSZ-C-C-E-E-K-KCJ-W-WYYL8H8H8J8JLLcS S S S S 3??,,--11"-  /D.68HSXSeg g g g"+COO,=,=">"> d d3 "%33335[RS5[5[VY5[5[]`ab]ccccccd!d dr)   /r   \:z_@BASENAME@.z.d)z--preprocessor-arg=-MDz--preprocessor-arg=-MQ@OUTPUT@z--preprocessor-arg=-MF@DEPFILE@zCompiling Windows resource {})r0   r   extra_dependsdescription)rH   r   )copyr   r
   CustomTargetget_include_argsIncludeDirsr   r   r   r;   backendget_target_dirrq   r3   r6   r5   r   warningformatreplaceappendextendr   r   r[   r   )rD   rO   r"   rx   
extra_argswrc_depend_fileswrc_dependsdrh   rescomp_typesuffixres_argsrp   rj   res_targetsr   namename_formattedr   r.   r1   r0   s    ``                   r*   r>   zWindowsModule.compile_resourcesi   sM    F^((**
!.1Y' 	 	A!U/00 e44%b"ebgll>SWScSkSzSz{|S}S}6~6~5  A  A6   
 	e,,V4I-JKKK
 $ < <U C C/222 F!$I$I$IIHH1999 F!Y
$;;HTA! = =#::L#e<<<<= F!$A$A$AAH24	d 	d 	d 	d 	d 	d 	d, *3 	 	%D.#<<S))11$<<DDS#NND+33C==EEdCPPXXY\^abbN22&22F=?GNN7###NN8$$$'+G3;;;#---  C  C  C D D D u1 !-);          !{m<<<r)   )r;   r<   )rF   rG   rH   rI   )rO   rP   rH   rQ   )rO   rP   r"   rw   rx   ry   rH   r   )r$   r%   r&   r   INFOr@   rN   rq   r   r-   r	   r   r
   r   r   r   r   evolver   r   r   r   listr>   __classcell__)rE   s   @r*   r9   r9   0   sA       :i  D     S S S S& & & &P ^/#x}eN`bgby9z  IJ  K  K  K\#X...
)))	&++D#66DQQQ Y= Y= Y=  K  KY= Y= Y= Y= Y=r)   r9   interpr<   rH   c                     t          |           S )N)r9   )r   s    r*   
initializer      s       r)   )r   r<   rH   r9   )*
__future__r   enumr   rb   typingTr{   r   r   r   r	   r
   r   interpreter.type_checkingr   r   r   interpreterbase.decoratorsr   r   r   r   r   r   r   programsr   TYPE_CHECKINGr   rF   r   r;   r   typing_extensionsr   r   r,   Enumr3   r9   r   r(   r)   r*   <module>r      s+   # " " " " "  				 				     * ) ) ) ) ) ) )                     X X X X X X X X X X o o o o o o o o o o o o o o 4 4 4 4 4 4 4 4 & & & & & &? 7$$$$$$))))))++++++    9   7 7 7 7 79 7 7 7    49   
Z= Z= Z= Z= Z=O Z= Z= Z=x! ! ! ! ! !r)   