ðÕYfVã@srdZddlZddlmZddlTddlmZddlmZdd„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)Ú*)Úcustomize_compiler)ÚlogcCsddlm}|ƒdS)Nr)Úshow_compilers)Údistutils.ccompilerr)r©rúA/opt/alt/python35/lib64/python3.5/distutils/command/build_clib.pyrsrc@s eZdZdZd"d#d$d%d&gZdd gZdddefgZdd„Zdd„Z dd„Z dd„Z dd„Z dd„Z d d!„ZdS)'Ú build_clibz/build C/C++ libraries used by Python extensionsú build-clib=Úbú%directory to build C/C++ libraries toú build-temp=Útú,directory to put temporary build by-productsÚdebugÚgú"compile with debugging informationÚforceÚfú2forcibly build everything (ignore file timestamps)ú compiler=Úcúspecify the compiler typez help-compilerNzlist available compilerscCsUd|_d|_d|_d|_d|_d|_d|_d|_d|_dS)Nr) r Ú build_tempÚ librariesÚ include_dirsÚdefineÚundefrrÚcompiler)Úselfrrr Úinitialize_options4s        zbuild_clib.initialize_optionscCs–|jdddd d d ƒ|jj|_|jrD|j|jƒ|jdkrh|jjpbg|_t|jtƒr’|jjtj ƒ|_dS) NZbuildrr rrr)rr )rr)rr)rr)rr) Zset_undefined_optionsZ distributionrÚcheck_library_listrÚ isinstanceÚstrÚsplitÚosÚpathsep)r rrr Úfinalize_optionsDs  zbuild_clib.finalize_optionscCsö|js dSddlm}|d|jd|jd|jƒ|_t|jƒ|jdk rs|jj|jƒ|j dk r¯x*|j D]\}}|jj ||ƒqŒW|j dk râx!|j D]}|jj |ƒqÈW|j |jƒdS)Nr)Ú new_compilerrÚdry_runr)rrr)rr*rrrZset_include_dirsrZ define_macrorZundefine_macroÚbuild_libraries)r r)ÚnameÚvalueZmacrorrr Úrun^s    zbuild_clib.runcCsÞt|tƒstdƒ‚x¼|D]´}t|tƒ rVt|ƒdkrVtdƒ‚|\}}t|tƒs}tdƒ‚d|ks§tjdkr»tj|kr»td|dƒ‚t|tƒs"tdƒ‚q"Wd 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 separatorsrzMsecond element of each tuple in 'libraries' must be a dictionary (build info)N) r#ÚlistÚDistutilsSetupErrorÚtupleÚlenr$r&ÚsepÚdict)r rÚlibr,Ú build_inforrr r"vs"   "   *zbuild_clib.check_library_listcCs>|js dSg}x$|jD]\}}|j|ƒqW|S)N)rÚappend)r Z lib_namesÚlib_namer8rrr Úget_library_namesšs  zbuild_clib.get_library_namescCs‚|j|jƒg}xe|jD]Z\}}|jdƒ}|dks]t|ttfƒ rmtd|ƒ‚|j|ƒq W|S)NÚsourceszfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenames)r"rÚgetr#r1r3r2Úextend)r Ú filenamesr:r8r<rrr Úget_source_files¦s" zbuild_clib.get_source_filesc Csëxä|D]Ü\}}|jdƒ}|dksDt|ttfƒ rTtd|ƒ‚t|ƒ}tjd|ƒ|jdƒ}|jdƒ}|jj|d|j d|d|d|j ƒ}|jj ||d|j d|j ƒqWdS)Nr<zfin 'libraries' option (library '%s'), 'sources' must be present and must be a list of source filenameszbuilding '%s' libraryÚmacrosrZ output_dirr) r=r#r1r3r2rÚinforÚcompilerrZcreate_static_libr )r rr:r8r<rArZobjectsrrr r+µs$"     zbuild_clib.build_libraries)r r r )rrr)rrr)rrr)rrr)Ú__name__Ú __module__Ú __qualname__Z descriptionZ user_optionsZboolean_optionsrZ help_optionsr!r(r.r"r;r@r+rrrr r s*       $ r ) Ú__doc__r&Zdistutils.corerZdistutils.errorsZdistutils.sysconfigrZ distutilsrrr rrrr Ús