o
    ld 7                     @  s  U d dl mZ d dlmZ d dlZd dl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
Zg dZi ddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-Zd.ed/< i d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdMdOdPdQdRdSZd.edT< i eeZdUdVdWdXdYZd.edZ< G d[d\ d\eZG d]d^ d^Zed_d`G dadb dbeZG dcdd ddZG dedf dfZdS )g    )annotations)	dataclassN)Enum   )mesonlib)EnvironmentExceptionHoldableObject)mlog)Path)"aarch64alphaZarcarmZavrZc2000ZcskyZdspicZe2kZft32ia64loongarch64Zm68kZ
microblazeZmipsmips64Zmsp430ZpariscZpic24ppcppc64Zriscv32riscv64Zrl78ZrxZs390s390xZsh4Zsparcsparc64Zwasm32wasm64x86x86_64)r   r   r   r   r   r   r   r   r   r   r   cCCcppCXXcsZCSCdZDCZfortranZFCobjcZOBJCZobjcppZOBJCXXZrustZRUSTCZvalaZVALACZnasmZNASMZc_ldZCC_LDZcpp_ldZCXX_LDd_ldZDC_LD
fortran_ldZFC_LDZobjc_ldZOBJC_LD	objcpp_ldZ	OBJCXX_LDrust_ldZRUSTC_LDzT.Mapping[str, str]ENV_VAR_COMPILER_MAParARasZASldZLDnmZNMZobjcopyZOBJCOPYZobjdumpZOBJDUMPZranlibZRANLIBreadelfREADELFsizeZSIZEstringsZSTRINGSstripZSTRIPZwindresZWINDRESZcmakeZCMAKEZqmakeZQMAKEZ	pkgconfigZ
PKG_CONFIGz
pkg-configmakeZMAKEZVAPIGENZLLVM_CONFIG)Zvapigenzllvm-configENV_VAR_TOOL_MAPZD_LDZF_LDZRUST_LDZ	OBJCPP_LD)r    r!   r#   r"   DEPRECATED_ENV_PROG_MAPc                   @  s   e Zd ZdZdZdZdS )CMakeSkipCompilerTestalwaysneverZdep_onlyN)__name__
__module____qualname__ZALWAYSZNEVERDEP_ONLY r9   r9   shome/ych/rk3568/buildroot/output/rockchip_rk3568_recovery/host/lib/python3.10/site-packages/mesonbuild/envconfig.pyr2      s    r2   c                   @  s   e Zd Z	d2d3ddZd4d
dZd5ddZd6ddZd6ddZd7ddZd8ddZ	d9ddZ
d:ddZd8dd Zd9d!d"Zd;d%d&Zd<d)d*Zd=d-d.Zd2d>d0d1ZdS )?
PropertiesN
propertiesIT.Optional[T.Dict[str, T.Optional[T.Union[str, bool, int, T.List[str]]]]]c                 C  s   |pi | _ d S Nr<   )selfr<   r9   r9   r:   __init__   s   zProperties.__init__languagestrreturnboolc                 C  s   |d | j v S NZ_stdlibr?   )r@   rB   r9   r9   r:   
has_stdlib      zProperties.has_stdlibT.Union[str, T.List[str]]c                 C  sF   | j |d  }t|tr|S t|tsJ |D ]	}t|ts J q|S rF   )r<   
isinstancerC   list)r@   rB   stdlibir9   r9   r:   
get_stdlib   s   
zProperties.get_stdlibT.Optional[str]c                 C  (   | j dd }|d u st|tsJ |S )Nrootr<   getrJ   rC   )r@   rQ   r9   r9   r:   get_root      zProperties.get_rootc                 C  rP   )Nsys_rootrR   )r@   rV   r9   r9   r:   get_sys_root   rU   zProperties.get_sys_rootT.Optional[T.List[str]]c                 C  s@   | j dd }|d u r|S t|}|D ]	}t|tsJ q|S )NZpkg_config_libdir)r<   rS   r   listifyrJ   rC   )r@   presrM   r9   r9   r:   get_pkg_config_libdir   s   
z Properties.get_pkg_config_libdirc                 C  *   d| j vrdS | j d }t|tsJ |S )NZcmake_defaultsTr<   rJ   rE   r@   r[   r9   r9   r:   get_cmake_defaults   
   

zProperties.get_cmake_defaultsT.Optional[Path]c                 C  sJ   d| j vrd S | j d }t|tsJ t|}| s#td| d|S )Ncmake_toolchain_filezcmake_toolchain_file (z) is not absolute)r<   rJ   rC   r
   is_absoluter   )r@   rawrc   r9   r9   r:   get_cmake_toolchain_file   s   

z#Properties.get_cmake_toolchain_filer2   c              	   C  s\   d| j vrtjS | j d }t|tsJ zt|W S  ty-   td|dd tD w )NZcmake_skip_compiler_testzO"{}" is not a valid value for cmake_skip_compiler_test. Supported values are {}c                 S  s   g | ]}|j qS r9   )value).0er9   r9   r:   
<listcomp>   s    z;Properties.get_cmake_skip_compiler_test.<locals>.<listcomp>)r<   r2   r8   rJ   rC   
ValueErrorr   format)r@   re   r9   r9   r:   get_cmake_skip_compiler_test   s   


z'Properties.get_cmake_skip_compiler_testc                 C  r]   )NZcmake_use_exe_wrapperTr^   r_   r9   r9   r:   get_cmake_use_exe_wrapper   ra   z$Properties.get_cmake_use_exe_wrapperc                 C  s$   t d| jd}|rt|S d S )NrO   Z	java_home)Tcastr<   rS   r
   )r@   rg   r9   r9   r:   get_java_home   s   zProperties.get_java_homeotherobjectc                 C  s   t |t| r| j|jkS tS r>   )rJ   typer<   NotImplemented)r@   rr   r9   r9   r:   __eq__   s   zProperties.__eq__key0T.Optional[T.Union[str, bool, int, T.List[str]]]c                 C  s
   | j | S r>   r?   )r@   rw   r9   r9   r:   __getitem__      
zProperties.__getitem__item$T.Union[str, bool, int, T.List[str]]c                 C  s
   || j v S r>   r?   )r@   r{   r9   r9   r:   __contains__   rz   zProperties.__contains__defaultc                 C  s   | j ||S r>   )r<   rS   )r@   rw   r~   r9   r9   r:   rS      rH   zProperties.getr>   )r<   r=   )rB   rC   rD   rE   )rB   rC   rD   rI   )rD   rO   )rD   rX   rD   rE   )rD   rb   )rD   r2   )rr   rs   rD   rE   )rw   rC   rD   rx   )r{   r|   rD   rE   )rw   rC   r~   rx   rD   rx   )r5   r6   r7   rA   rG   rN   rT   rW   r\   r`   rf   rm   rn   rq   rv   ry   r}   rS   r9   r9   r9   r:   r;      s"    


	


	







r;   T)unsafe_hashc                   @  s   e Zd ZU ded< ded< ded< ded< d3dd	Zd4d
dZed5ddZd6ddZd6ddZ	d6ddZ
d6ddZd6ddZd6ddZd6ddZd6d d!Zd6d"d#Zd6d$d%Zd6d&d'Zd6d(d)Zd6d*d+Zd4d,d-Zd4d.d/Zd6d0d1Zd2S )7MachineInforC   system
cpu_familycpuendianrD   Nonec                 C  s   | j tv | _d S r>   )r   CPU_FAMILIES_64_BITZ	is_64_bitr@   r9   r9   r:   __post_init__     zMachineInfo.__post_init__c                 C  s   d| j  d| j d| j dS )Nz<MachineInfo:  z (z)>)r   r   r   r   r9   r9   r:   __repr__  s   zMachineInfo.__repr__literalT.Dict[str, str]'MachineInfo'c                 C  s   h d}t ||k rtd| dd|t |  |d }|tvr,td| d |d }|d	vr<td
|  | |d ||d |S )N>   r   r   r   r   zMachine info is currently 
zbut is missing {}.r   zUnknown CPU family zF, please report this at https://github.com/mesonbuild/meson/issues/newr   )littlebigzUnknown endian r   r   )setr   rl   known_cpu_familiesr	   warning)clsr   Zminimum_literalr   r   r9   r9   r:   from_literal  s   
zMachineInfo.from_literalrE   c                 C  
   | j dkS )z%
        Machine is windows?
        windowsr   r   r9   r9   r:   
is_windows      
zMachineInfo.is_windowsc                 C  r   )z$
        Machine is cygwin?
        cygwinr   r   r9   r9   r:   	is_cygwin&  r   zMachineInfo.is_cygwinc                 C  r   )z#
        Machine is linux?
        linuxr   r   r9   r9   r:   is_linux,  r   zMachineInfo.is_linuxc                 C  s
   | j dv S )z4
        Machine is Darwin (iOS/tvOS/OS X)?
        >   ZiosZtvosdarwinr   r   r9   r9   r:   	is_darwin2  r   zMachineInfo.is_darwinc                 C  r   )z%
        Machine is Android?
        Zandroidr   r   r9   r9   r:   
is_android8  r   zMachineInfo.is_androidc                 C  r   )z#
        Machine is Haiku?
        Zhaikur   r   r9   r9   r:   is_haiku>  r   zMachineInfo.is_haikuc                 C  r   )z$
        Machine is NetBSD?
        Znetbsdr   r   r9   r9   r:   	is_netbsdD  r   zMachineInfo.is_netbsdc                 C  r   )z%
        Machine is OpenBSD?
        Zopenbsdr   r   r9   r9   r:   
is_openbsdJ  r   zMachineInfo.is_openbsdc                 C  r   )zMachine is DragonflyBSD?Z	dragonflyr   r   r9   r9   r:   is_dragonflybsdP     
zMachineInfo.is_dragonflybsdc                 C  r   )zMachine is FreeBSD?Zfreebsdr   r   r9   r9   r:   
is_freebsdT  r   zMachineInfo.is_freebsdc                 C  r   )zMachine is illumos or Solaris?sunosr   r   r9   r9   r:   is_sunosX  r   zMachineInfo.is_sunosc                 C  r   )z&
        Machine is GNU/Hurd?
        Zgnur   r   r9   r9   r:   is_hurd\  r   zMachineInfo.is_hurdc                 C  s   | j dS )zMachine is IRIX?Zirix)r   
startswithr   r9   r9   r:   is_irixb  s   zMachineInfo.is_irixc                 C  s   |   s|  r
dS dS )Nexe r   r   r   r9   r9   r:   get_exe_suffixi  s   zMachineInfo.get_exe_suffixc                 C  s   |   rdS dS )Nobjo)r   r   r9   r9   r:   get_object_suffixo  s   zMachineInfo.get_object_suffixc                 C  s   |   p|  S r>   r   r   r9   r9   r:   libdir_layout_is_winu  r   z MachineInfo.libdir_layout_is_winN)rD   r   )rD   rC   )r   r   rD   r   r   )r5   r6   r7   __annotations__r   r   classmethodr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r9   r9   r9   r:   r     s2   
 
















r   c                   @  s\   e Zd Z	ddddZeddd	Zedd
dZedddZedddZ	dddZ
dS )BinaryTableNbinaries2T.Optional[T.Dict[str, T.Union[str, T.List[str]]]]c                 C  sZ   i | _ |r)| D ]!\}}t|ttfs td|d|dt|| j |< q	d S d S )NzInvalid type z for entry z in cross file)r   itemsrJ   rK   rC   r   ZMesonExceptionrY   )r@   r   namecommandr9   r9   r:   rA   z  s   zBinaryTable.__init__rD   T.List[str]c                	   C  >   zt jddgt jt jd W dgS  tt jfy   g  Y S w )Nccache	--versionstdoutstderr
subprocess
check_callPIPEOSErrorCalledProcessErrorr9   r9   r9   r:   detect_ccache     zBinaryTable.detect_ccachec                	   C  r   )Nsccacher   r   r   r9   r9   r9   r:   detect_sccache  r   zBinaryTable.detect_sccachec                  C  s   t  } | r| S t  S r>   )r   r   r   )cacher9   r9   r:   detect_compiler_cache  s   z!BinaryTable.detect_compiler_cacheentryrI   !T.Tuple[T.List[str], T.List[str]]c                 C  sf   t |}|d dkr|dd  }|  }||fS |d dkr-|dd  }|  }||fS g }||fS )Nr   r   r   r   )r   Zstringlistifyr   r   )r   r   compilerr   r9   r9   r:   parse_entry  s   
zBinaryTable.parse_entryr   rC   rX   c                 C  s(   | j |}|s
dS |d  sdS |S )zLookup binary in cross/native file and fallback to environment.

        Returns command with args as list if found, Returns `None` if nothing is
        found.
        Nr   )r   rS   r.   )r@   r   r   r9   r9   r:   lookup_entry  s   zBinaryTable.lookup_entryr>   )r   r   )rD   r   )r   rI   rD   r   )r   rC   rD   rX   )r5   r6   r7   rA   staticmethodr   r   r   r   r   r   r9   r9   r9   r:   r   x  s    r   c                   @  s"   e Zd ZddddZdd	d
ZdS )CMakeVariablesN	variablesT.Optional[T.Dict[str, T.Any]]rD   r   c              
   C  sn   |pi }i | _ | D ])\}}t|}|D ]}t|ts.td| d| dt|j dq|| j |< qd S )NzValue 'z' of CMake variable 'z!' defined in a machine file is a z and not a str)	r   r   r   rY   rJ   rC   r   rt   r5   )r@   r   rw   rg   rM   r9   r9   r:   rA     s   

"zCMakeVariables.__init__T.Dict[str, T.List[str]]c                 C  s   | j S r>   )r   r   r9   r9   r:   get_variables  s   zCMakeVariables.get_variablesr>   )r   r   rD   r   )rD   r   )r5   r6   r7   rA   r   r9   r9   r9   r:   r     s    r   )
__future__r   dataclassesr   r   typingro   enumr   r   r   r   r   r	   pathlibr
   r   r   r$   r   r0   ZENV_VAR_PROG_MAPr1   r2   r;   r   r   r   r9   r9   r9   r:   <module>   s   '	
	
bvB