B fƅI @ sT d Z ddlZddlmZ ddlT ddlmZ ddlmZ dd Z G d d d eZ dS )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 C s ddl m} | d S )Nr )show_compilers)distutils.ccompilerr )r r A/opt/alt/python37/lib64/python3.7/distutils/command/build_clib.pyr s r c @ sl e Zd ZdZdddddgZddgZd d defgZdd Zdd Z dd Z dd Zdd Zdd Z dd Zd S ) build_clibz/build C/C++ libraries used by Python extensions)zbuild-clib=bz%directory to build C/C++ libraries to)zbuild-temp=tz,directory to put temporary build by-products)debuggz"compile with debugging information)forcefz2forcibly build everything (ignore file timestamps))z compiler=czspecify the compiler typer r z help-compilerNzlist available compilersc C s: d | _ d | _d | _d | _d | _d | _d | _d| _d | _d S )Nr ) r build_temp librariesinclude_dirsdefineundefr r compiler)selfr r r initialize_options4 s zbuild_clib.initialize_optionsc C sh | dddddd | jj| _| jr0| | j | jd krH| jjpDg | _t| jtrd| jtj | _d S )NZbuild)r r )r r )r r )r r )r r ) Zset_undefined_optionsZdistributionr check_library_listr isinstancestrsplitospathsep)r r r r finalize_optionsD s zbuild_clib.finalize_optionsc C s | j s d S ddlm} || j| j| jd| _t| j | jd k rN| j| j | j d k rzx | j D ]\}}| j || q`W | jd k rx| jD ]}| j| qW | | j d S )Nr )new_compiler)r dry_runr )r r r! r r" r r r Zset_include_dirsr Zdefine_macror Zundefine_macrobuild_libraries)r r! namevalueZmacror r r run^ s zbuild_clib.runc C s t |tstdx|D ]z}t |ts:t|dkr:td|\}}t |tsTtdd|ksptjdkrtj|krtd|d t |tstdqW 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 listDistutilsSetupErrortuplelenr r sepdict)r r libr$ build_infor r r r v s" zbuild_clib.check_library_listc C s0 | j s d S g }x| j D ]\}}|| qW |S )N)r append)r Z lib_nameslib_namer0 r r r get_library_names s zbuild_clib.get_library_namesc C s^ | | j g }xH| jD ]>\}}|d}|d ks@t|ttfsLtd| || qW |S )Nsourceszfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenames)r r getr r) r+ r* extend)r filenamesr2 r0 r4 r r r get_source_files s zbuild_clib.get_source_filesc C s x|D ]\}}| d}|d ks.t|ttfs:td| t|}td| | d}| d}| jj|| j ||| j d}| jj||| j| j d qW d S )Nr4 zfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenameszbuilding '%s' librarymacrosr ) output_dirr9 r r )r: r ) r5 r r) r+ r* r infor compiler r Zcreate_static_libr )r r r2 r0 r4 r9 r Zobjectsr r r r# s$ zbuild_clib.build_libraries)__name__ __module____qualname__ZdescriptionZuser_optionsZboolean_optionsr Zhelp_optionsr r r&