o bc<@sdZddlZddlZddlZddlmZddlmZddlm Z m Z m Z ddl m Z mZmZmZddlmZejdkr?ddlZGd d d e ZdS) a9distutils.unixccompiler Contains the UnixCCompiler class, a subclass of CCompiler that handles the "typical" Unix-style command-line C compiler: * macros defined with -Dname[=value] * macros undefined with -Uname * include search directories specified with -Idir * libraries specified with -lllib * library search directories specified with -Ldir * compile handled by 'cc' (or similar) executable with -c option: compiles .c to .o * link static library handled by 'ar' command (possibly with 'ranlib') * link shared library handled by 'cc -shared' N) sysconfig)newer) CCompilergen_preprocess_optionsgen_lib_options)DistutilsExecError CompileErrorLibError LinkError)logdarwinc @seZdZdZddgdgdgddgdgddgddZejddd kr'd ged <gd Zd Zd Z dZ dZ dZ dZ ZZeZejdkrDdZ  d'ddZddZ d(ddZ    d)ddZddZdd Zd!d"Zd#d$Zd*d%d&ZdS)+ UnixCCompilerunixNccz-sharedarz-cr) preprocessorcompiler compiler_so compiler_cxx linker_so linker_exearchiverranlibr r)z.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%scygwinz.exec Cs|d||}|\}}}t||} |j| } |r| d|g|r'|| dd<|r.| || ||js?|dus?t||rc|rJ|tj |z| | WdSt yb} zt | d} ~ wwdS)N-or)_fix_compile_argsrrextendappendforcermkpathospathdirnamespawnrr) selfsource output_filemacros include_dirs extra_preargsextra_postargs fixed_argsignorepp_optspp_argsmsgr1./usr/lib/python3.10/distutils/unixccompiler.py preprocessUs*      zUnixCCompiler.preprocessc Csd|j}tjdkrt|||}z||||d|g|WdSty1}zt|d}~ww)Nr r)rsysplatform _osx_supportcompiler_fixupr$rr) r%objsrcextcc_argsr+r.rr0r1r1r2_compileos  zUnixCCompiler._compilerc Cs|||\}}|j||d}|||rN|tj|||j|g||j |j rLz ||j |gWdSt yK}zt |d}~wwdSt d|dS)N) output_dirskipping %s (up-to-date))_fix_object_argslibrary_filename _need_linkr r!r"r#r$robjectsrrr r debug)r%rBoutput_libnamer=rC target_langoutput_filenamer0r1r1r2create_static_libzs*   zUnixCCompiler.create_static_libc s|||\}}||||}|\}}}gdtd}|r*d|d|gfdd|D}fdd|D}t||||}t|ttdfsPt d|dur[t j ||}| ||r||j|d |g}| rvd g|dd <| r~| |dd <| r|| |t j |zf|tjkr|jdd}n|jdd}| d kr|jrd }t j |d d krd}d||vr|d7}d||vst j ||dkrd}nd }|j||||<tjdkrt||}|||WdSty}zt|d}~wwtd|dS)N)z/libz/lib64z/usr/libz /usr/lib64 MULTIARCHz/lib/%sz /usr/lib/%scg|]}|vr|qSr1r1.0dirsystem_libdirsr1r2 z&UnixCCompiler.link..crIr1r1rJrMr1r2rOrPz%'output_dir' must be a string or Nonerz-grzc++env= ld_so_aixr r>) r? _fix_lib_argsrget_config_varrr isinstancestrtype TypeErrorr!r"joinrArBr r#r EXECUTABLErrrbasenamer4r5r6r7r$rr r rC)r% target_descrBrFr= libraries library_dirsruntime_library_dirsexport_symbolsrCr*r+ build_temprEr, multiarchlib_optsld_argslinkerioffsetr0r1rMr2linksl         zUnixCCompiler.linkcCd|S)N-Lr1)r%rLr1r1r2library_dir_optionz UnixCCompiler.library_dir_optioncstfdddDS)Nc3s|]}|vVqdS)Nr1)rKname compiler_namer1r2 sz(UnixCCompiler._is_gcc..)gcczg++clang)any)r%rqr1rpr2_is_gccszUnixCCompiler._is_gcccCstjtd}tjdddkrd|Stjdddkr#d|Stjddd kr=||r7d d|gSd d|gS||rQtd d krMd|Sd|Sd|S)NCCrr rlfreebsdz -Wl,-rpath=zhp-uxz-Wl,+sz+sGNULDyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r!r"r]rrVr4r5rv)r%rLrr1r1r2runtime_library_dir_options    z(UnixCCompiler.runtime_library_dir_optioncCrk)Nz-lr1)r%libr1r1r2library_optionrnzUnixCCompiler.library_optioncCs|j|dd}|j|dd}|j|dd}|j|dd}tjdkr>td}td|} | dur9ttd } n| d } |D]} t j | |} t j | |} t j | |}t j | |}tjdkr| d sr| d r| d st j | | d d|} t j | | d d|} t j | | d d|}t j | | d d|}t j | r| St j |r|St j | r| St j |r|Sq@dS)Nshared)lib_typedylib xcode_stubstaticr CFLAGSz-isysroot\s*(\S+)rwrRz/System/z/usr/z /usr/local/)r@r4r5rrVresearchr6_default_sysrootgroupr!r"r[ startswithexists)r%dirsr~rCshared_fdylib_f xcode_stub_fstatic_fcflagsmsysrootrLrrrrr1r1r2find_library_filesH         zUnixCCompiler.find_library_file)NNNNN)NrN) NNNNNrNNNN)r)__name__ __module__ __qualname__ compiler_type executablesr4r5src_extensions obj_extensionstatic_lib_extensionshared_lib_extensiondylib_lib_extensionxcode_stub_lib_extensionstatic_lib_formatshared_lib_formatdylib_lib_formatxcode_stub_lib_format exe_extensionr3r<rGrjrmrvr}rrr1r1r1r2r -sN      M*r )__doc__r!r4r distutilsrdistutils.dep_utilrdistutils.ccompilerrrrdistutils.errorsrrr r r r5r6r r1r1r1r2s