o bcV@sTdZddlZddlmZddlTddlmZddlmZddZ 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)*)customize_compiler)logcCsddlm}|dS)Nrshow_compilers)distutils.ccompilerrrr 3/usr/lib/python3.10/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_options4s zbuild_clib.initialize_optionscCsl|dddddd|jj|_|jr||j|jdur$|jjp"g|_t|jtr4|jtj |_dSdS)Nbuild)rr )rr)rr)rr)rr) set_undefined_options distributionrcheck_library_listr isinstancestrsplitospathseprr r r finalize_optionsDs    zbuild_clib.finalize_optionscCs|jsdSddlm}||j|j|jd|_t|j|jdur'|j|j|j dur;|j D] \}}|j ||q/|j durL|j D]}|j |qC| |jdS)Nr) new_compiler)rdry_runr)rrr&rr'rrrset_include_dirsr define_macrorundefine_macrobuild_libraries)rr&namevaluemacror r r run^s"      zbuild_clib.runcCst|ts td|D]=}t|tst|dkrtd|\}}t|ts)tdd|vs7tjdkr?tj|vr?td|dt|tsHtdq 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 tuplesz*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 listDistutilsSetupErrortuplelenr!r#sepdict)rrlibr, build_infor r r rvs0   zbuild_clib.check_library_listcCs,|jsdSg}|jD] \}}||q |S)N)rappend)r lib_nameslib_namer9r r r get_library_namess  zbuild_clib.get_library_namescCsZ||jg}|jD]\}}|d}|dust|ttfs%td|||q |S)Nsourcesfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenames)rrgetr r2r4r3extend)r filenamesr<r9r>r r r get_source_filess   zbuild_clib.get_source_filescCs|D]G\}}|d}|dust|ttfstd|t|}td||d}|d}|jj||j |||j d}|jj |||j |j dqdS)Nr>r?zbuilding '%s' librarymacrosr) output_dirrDrr)rEr) r@r r2r4r3rinforcompilerrcreate_static_libr )rrr<r9r>rDrobjectsr r r r+s.      zbuild_clib.build_libraries)__name__ __module__ __qualname__ description user_optionsboolean_optionsr help_optionsrr%r/rr=rCr+r r r r r s $ r ) __doc__r#distutils.corerdistutils.errorsdistutils.sysconfigr distutilsrrr r r r r s