a „oeã@sXdZddlZddlmZddlmZddlmZddlm Z dd „Z Gd d „d eƒZ dS) z´distutils.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)ÚDistutilsSetupError)Úcustomize_compiler)ÚlogcCsddlm}|ƒdS)Nr©Úshow_compilers)Ú ccompilerrr©r úIC:\Program Files\Certbot\pkgs\setuptools\_distutils\command\build_clib.pyrs rc@sfeZdZdZgd¢ZddgZdddefgZdd „Zd d „Z d d „Z dd„Z dd„Z dd„Z dd„ZdS)Ú 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=Úczspecify the compiler typerrz help-compilerNzlist available compilerscCs:d|_d|_d|_d|_d|_d|_d|_d|_d|_dS)Nr) r Ú build_tempÚ librariesÚ include_dirsÚdefineÚundefrrÚcompiler©Úselfr r r Úinitialize_options/szbuild_clib.initialize_optionscCsh| dddddd¡|jj|_|jr0| |j¡|jdurH|jjpDg|_t|jtƒrd|j tj ¡|_dS)NÚbuild)rr )rr)rr)rr)rr) Zset_undefined_optionsZ distributionrÚcheck_library_listrÚ isinstanceÚstrÚsplitÚosÚpathseprr r r Úfinalize_options>sú    zbuild_clib.finalize_optionscCs¨|js dSddlm}||j|j|jd�|_t|jƒ|jdurN|j |j¡|j durv|j D]\}}|j  ||¡q^|j dur˜|j D]}|j  |¡q†|  |j¡dS)Nr)Ú new_compiler)rÚdry_runr)rr r%rr&rrrZset_include_dirsrZ define_macrorZundefine_macroÚbuild_libraries)rr%ÚnameÚvalueZmacror r r ÚrunYs   ÿ     zbuild_clib.runcCs–t|tƒstdƒ‚|D]z}t|tƒs8t|ƒdkr8tdƒ‚|\}}t|tƒsRtdƒ‚d|vsntjdkr~tj|vr~td|dƒ‚t|tƒstdƒ‚qd 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 tuplesrz*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 separatorsrzMsecond element of each tuple in 'libraries' must be a dictionary (build info)N) rÚlistrÚtupleÚlenr r"ÚsepÚdict)rrÚlibr(Ú build_infor r r rqs(  ÿÿÿ ÿzbuild_clib.check_library_listcCs,|js dSg}|jD]\}}| |¡q|S)N)rÚappend)rZ lib_namesÚlib_namer2r r r Úget_library_names–s  zbuild_clib.get_library_namescCsZ| |j¡g}|jD]>\}}| d¡}|dus>t|ttfƒsJtd|ƒ‚| |¡q|S)NÚsourcesúfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenames)rrÚgetrr,r-rÚextend)rÚ filenamesr4r2r6r r r Úget_source_files¡s  þÿ zbuild_clib.get_source_filescCs˜|D]Ž\}}| d¡}|dus,t|ttfƒs8td|ƒ‚t|ƒ}t d|¡| d¡}| d¡}|jj||j |||j d�}|jj |||j |j d�qdS)Nr6r7zbuilding '%s' libraryÚmacrosr)Ú output_dirr<rr)r=r) r8rr,r-rrÚinforÚcompilerrZcreate_static_libr )rrr4r2r6r<rZobjectsr r r r'°s,  þÿ   û  ÿzbuild_clib.build_libraries)Ú__name__Ú __module__Ú __qualname__Ú descriptionZ user_optionsZboolean_optionsrZ help_optionsrr$r*rr5r;r'r r r r r s ÿ% r ) Ú__doc__r"ZcorerÚerrorsrZ sysconfigrZdistutils._logrrr r r r r Ús