o
    ld%                     @  s6  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rddlmZ ddlmZ ddl m!Z! d dl"m#Z# G dd de#Z$G dd de#Z%G dd dej&Z'G dd deZ(d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                   @  s.   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__ r&   r&   yhome/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/lib/python3.10/site-packages/mesonbuild/modules/windows.pyr   &   s
   
 r   c                   @  s>   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(   -   s   
 r(   c                   @  s   e Zd ZdZdZdZdS )ResourceCompilerTyper   r      N)r"   r#   r$   windresrcwrcr&   r&   r&   r'   r.   5   s    r.   c                      s   e Zd ZedZd fddZd d
dZd!ddZede	e
jejejfddedejddejddeedeee	g ddd"ddZ  ZS )#WindowsModulewindowsinterpreter'Interpreter'c                   s(   t  | d | _| jd| ji d S )Ncompile_resources)super__init___rescompmethodsupdater7   )selfr5   	__class__r&   r'   r9   >   s
   
zWindowsModule.__init__	compilersT.Dict[str, 'Compiler']return
'Compiler'c                 C  s&   dD ]}||v r||   S qt d)N)ccppz2Resource compilation requires a C or C++ compiler.)r   )r=   r@   lr&   r&   r'   detect_compilerE   s
   zWindowsModule.detect_compilerstate'ModuleState'.T.Tuple[ExternalProgram, ResourceCompilerType]c                 C  s   t j}| jr	| jS t|j|d}|r| s3| |jjj	| }|j
dv r-tddd}ntddd}| s;tdddtjfd	d
tjfd	dtjffD ].\}}}t| |g \}}	}
t||	tj}|rztd|   ||f| _ | jS qLtd)Nr0   >   msvczintel-clzclang-clr1   T)Zsilentz(Could not find Windows resource compilerz/?z"^.*Microsoft.*Resource Compiler.*$z	--versionz^.*GNU windres.*$z^.*Wine Resource Compiler.*$zWindows resource compiler: %sz5Could not determine type of Windows resource compiler)r   ZHOSTr:   r   Zfrom_bin_listenvironmentfoundrG   Zcoredatar@   idr   r.   r1   r0   r2   r   Z
Popen_safeZget_commandresearch	MULTILINEr
   loggroup)r=   rH   Zfor_machinerescompcompargmatchZrc_typepoemr&   r&   r'   _find_resource_compilerK   s0   




z%WindowsModule._find_resource_compilerzwindows.compile_resourcesr   )varargsZmin_varargsz0.47.0)Zsincer    T)defaultZlistifyYT.Tuple[T.List[T.Union[str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex]]]kwargs'CompileResources'r   c                   s  |d   }|d }|d }|D ]!}t|tjr1|tdg dtjd| j	j
|gg7 }q||d 7 }| \}}	|	tjkrPd}
|g d	 }n+|	tjkrsd
}
|ddg }d}|D ]}d|v rqtj||dd qand
}
|g d }g }d fd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
 qt||gS )Nr    r   r    Fz@BUILD_ROOT@r   res)z/nologoz/fo@OUTPUT@@INPUT@rY   rd   @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)rd   z-ore   rB   ST.Iterable[T.Tuple[str, str, T.Union[str, mesonlib.File, build.CustomTargetIndex]]]c                  3  s    d D ]} t | trtjj| | | fV  qt | tjr)|  | j	| fV  qt | t
jrTtjddjjd |   d| j | j d|   | fV  qt|  dkrgtjddjjd t|  D ]\}}|   d| d| d| | | fV  qmqd S )	Nr   zBwindows.compile_resource CustomTargetIndex in positional argumentsz0.61.0)location_Zwindows_compile_resources_r   zSwindows.compile_resource CustomTarget with multiple outputs in positional arguments)
isinstancer)   ospathjoinsubdirr   FileZrelative_namefnamer	   CustomTargetIndexr   Z
single_use
subprojectZcurrent_nodeZget_idtargetget_outputsindexr*   get_filenamelen	enumerate)srcioutr    rH   r&   r'   	get_names   s*   

,z2WindowsModule.compile_resources.<locals>.get_names/rj   \:z_@BASENAME@.z.d)z--preprocessor-arg=-MDz--preprocessor-arg=-MQ@OUTPUT@z--preprocessor-arg=-MF@DEPFILE@)r,   r   Zextra_depends)rB   rh   )copyrk   r	   CustomTargetZget_include_argsZIncludeDirsrl   rm   rn   r5   ZbackendZget_target_dirr\   r.   r1   r0   r
   warningformatreplaceappendextendro   rs   rL   r   )r=   rH   r    r`   
extra_argsZwrc_depend_filesZwrc_dependsdrT   Zrescomp_typesuffixZres_argsr[   rV   Zres_targetsr~   nameZname_formattedrz   r*   r-   r,   r&   r}   r'   r7   q   sf   $






zWindowsModule.compile_resources)r5   r6   )r@   rA   rB   rC   )rH   rI   rB   rJ   )rH   rI   r    r_   r`   ra   rB   r   )r"   r#   r$   r   INFOr9   rG   r\   r   r)   r   rp   r	   r   rr   r   r   Zevolver   r   r   r   listr7   __classcell__r&   r&   r>   r'   r3   :   s    

&

r3   interpr6   rB   c                 C  s   t | S )N)r3   )r   r&   r&   r'   
initialize   s   r   )r   r6   rB   r3   )*
__future__r   enumrl   rO   typingTrb   r   r   r   r   r	   r
   Zinterpreter.type_checkingr   r   r   Zinterpreterbase.decoratorsr   r   r   r   r   r   r   Zprogramsr   TYPE_CHECKINGr   r@   r   r5   r   typing_extensionsr   r   r(   Enumr.   r3   r   r&   r&   r&   r'   <module>   s0    