a oe@sXdZddlZddlmZddlmZddlmZddlm Z dd Z Gd 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)DistutilsSetupError)customize_compiler)logcCsddlm}|dS)Nrshow_compilers) ccompilerrrr IC:\Program Files\Certbot\pkgs\setuptools\_distutils\command\build_clib.pyrs rc@sfeZdZdZgdZddgZdddefgZdd Zd d Z d d Z ddZ ddZ ddZ ddZdS) 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)debuggz"compile with debugging information)forcefz2forcibly 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_dirsdefineundefrrcompilerselfr r r initialize_options/szbuild_clib.initialize_optionscCsh|dddddd|jj|_|jr0||j|jdurH|jjpDg|_t|jtrd|jtj |_dS)Nbuild)rr )rr)rr)rr)rr) Zset_undefined_optionsZ distributionrcheck_library_listr isinstancestrsplitospathseprr 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| |jdS)Nr) new_compiler)rdry_runr)rr r%rr&rrrZset_include_dirsrZ define_macrorZundefine_macrobuild_libraries)rr%namevalueZmacror r r runYs        zbuild_clib.runcCst|tstd|D]z}t|ts8t|dkr8td|\}}t|tsRtdd|vsntjdkr~tj|vr~td|dt|tstdqd 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) rlistrtuplelenr r"sepdict)rrlibr( build_infor r r rqs(   zbuild_clib.check_library_listcCs,|js dSg}|jD]\}}||q|S)N)rappend)rZ lib_nameslib_namer2r r r get_library_namess  zbuild_clib.get_library_namescCsZ||jg}|jD]>\}}|d}|dus>t|ttfsJtd|||q|S)Nsourcesfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenames)rrgetrr,r-rextend)r filenamesr4r2r6r r r get_source_filess   zbuild_clib.get_source_filescCs|D]\}}|d}|dus,t|ttfs8td|t|}td||d}|d}|jj||j |||j d}|jj |||j |j dqdS)Nr6r7zbuilding '%s' librarymacrosr) output_dirr<rr)r=r) r8rr,r-rrinforcompilerrZcreate_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"ZcorererrorsrZ sysconfigrZdistutils._logrrr r r r r s