
    ZQdV                     `    d Z ddlZddlmZ ddlT ddlmZ ddlmZ d Z	 G d d	e          Z
dS )
zdistutils.command.build_clib

Implements the Distutils 'build_clib' command, to build a C/C++ library
that is included in the module distribution and needed by an extension
module.    N)Command)*)customize_compiler)logc                  &    ddl m}   |              d S )Nr   show_compilers)distutils.ccompilerr	   r   s    3/usr/lib/python3.11/distutils/command/build_clib.pyr	   r	      s(    222222N    c                   Z    e Zd ZdZg dZddgZdddefgZd Zd	 Z	d
 Z
d Zd Zd Zd ZdS )
build_clibz/build C/C++ libraries used by Python extensions))zbuild-clib=bz%directory to build C/C++ libraries to)zbuild-temp=tz,directory to put temporary build by-products)debuggz"compile with debugging information)forcefz2forcibly build everything (ignore file timestamps))z	compiler=czspecify the compiler typer   r   zhelp-compilerNzlist available compilersc                     d | _         d | _        d | _        d | _        d | _        d | _        d | _        d| _        d | _        d S )Nr   )	r   
build_temp	librariesinclude_dirsdefineundefr   r   compilerselfs    r   initialize_optionszbuild_clib.initialize_options4   sJ      !


r   c                 \   |                      dddddd           | j        j        | _        | j        r|                     | j                   | j        | j        j        pg | _        t          | j        t                    r+| j                            t          j	                  | _        d S d S )Nbuild)r   r   )r   r   )r   r   )r   r   )r   r   )
set_undefined_optionsdistributionr   check_library_listr   
isinstancestrsplitospathsepr   s    r   finalize_optionszbuild_clib.finalize_optionsD   s     	""7#?#?#;#5#5	7 	7 	7 *4> 	4##DN333$ $ 1 > D"Dd'-- 	D $ 1 7 7
 C CD	D 	Dr   c                    | j         sd S ddlm}  || j        | j        | j                  | _        t          | j                   | j        | j                            | j                   | j	        (| j	        D ] \  }}| j        
                    ||           !| j        $| j        D ]}| j                            |           |                     | j                    d S )Nr   )new_compiler)r   dry_runr   )r   r
   r,   r   r-   r   r   r   set_include_dirsr   define_macror   undefine_macrobuild_libraries)r   r,   namevaluemacros        r   runzbuild_clib.run^   s   ~ 	F 	544444$dm-1\+/:7 7 7 	4=)))(M**4+<===;" $ 8 8e**47777:! 4 4,,U3333T^,,,,,r   c                    t          |t                    st          d          |D ]}t          |t                    s"t	          |          dk    rt          d          |\  }}t          |t
                    st          d          d|v st          j        dk    r&t          j        |v rt          d|d         z            t          |t                    st          d          d	S )
a`  Ensure that the list of libraries is valid.

        `library` is presumably provided as a command option 'libraries'.
        This method checks that it is a list of 2-tuples, where the tuples
        are (library_name, build_info_dict).

        Raise DistutilsSetupError if the structure is invalid anywhere;
        just returns otherwise.
        z+'libraries' option must be a list of tuples   z*each element of 'libraries' must a 2-tuplezNfirst element of each tuple in 'libraries' must be a string (the library name)/z;bad library name '%s': may not contain directory separatorsr   zMsecond element of each tuple in 'libraries' must be a dictionary (build info)N)	r%   listDistutilsSetupErrortuplelenr&   r(   sepdict)r   r   libr2   
build_infos        r   r$   zbuild_clib.check_library_listv   s.    )T** 	A%?A A A  	; 	;Cc5)) Dc#hh!mm)BD D D  #D*dC(( =)<= = = d{{rv}}4) +>@CA+G H H H j$// ;):; ; ;;!	; 	;r   c                 `    | j         sd S g }| j         D ]\  }}|                    |           |S )N)r   append)r   	lib_nameslib_namer@   s       r   get_library_nameszbuild_clib.get_library_names   sK     ~ 	4	&*n 	' 	'"XzX&&&&r   c                    |                      | j                   g }| j        D ]_\  }}|                    d          }|t          |t          t
          f          st          d|z            |                    |           `|S )Nsourcesfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenames)r$   r   getr%   r9   r;   r:   extend)r   	filenamesrD   r@   rG   s        r   get_source_fileszbuild_clib.get_source_files   s    ///	&*n 	& 	&"Xz nnY//Gj4-&H&H)46>?@ @ @
 W%%%%r   c                    |D ]\  }}|                     d          }|t          |t          t          f          st	          d|z            t          |          }t          j        d|           |                     d          }|                     d          }| j                            || j	        ||| j
                  }| j                            ||| j        | j
                   d S )NrG   rH   zbuilding '%s' librarymacrosr   )
output_dirrN   r   r   )rO   r   )rI   r%   r9   r;   r:   r   infor   compiler   r   create_static_libr   )r   r   rD   r@   rG   rN   r   objectss           r   r1   zbuild_clib.build_libraries   s   &/ 	> 	>"Xz nnY//Gj4-&H&H)46>?@ @ @ 7mmGH,h777
  ^^H--F%>>.99Lm++G7;399E26*	 , > >G M++GX7;26* , > > > >3	> 	>r   )__name__
__module____qualname__descriptionuser_optionsboolean_optionsr	   help_optionsr   r*   r5   r$   rE   rL   r1    r   r   r   r      s        CK
 
 
L (O 
$	#^	5
L
   D D D4- - -0!; !; !;H	 	 	  > > > > >r   r   )__doc__r(   distutils.corer   distutils.errorsdistutils.sysconfigr   	distutilsr   r	   r   r[   r   r   <module>ra      s      
			 " " " " " "     2 2 2 2 2 2        
u> u> u> u> u> u> u> u> u> u>r   