a ۅg;@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 krNd ged <gd Zd Zd Z dZ dZ dZ dZ ZZeZejdkrdZfddZd)ddZddZd*ddZd+ddZdd Zd!d"Zd#d$Zd%d&Zd,d'd(ZZS)- UnixCCompilerZunixNZccz-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.execs@t|||\}}}td}|r6||vr6|||||fS)z'Remove standard library path from rpathZLIBDIR)super _fix_lib_argsrget_config_varremove)self libraries library_dirsruntime_library_dirslibdir __class__//usr/lib64/python3.9/distutils/unixccompiler.pyrUs    zUnixCCompiler._fix_lib_argsc Cs|d||}|\}}}t||} |j| } |r>| d|g|rN|| dd<|r\| || ||js~|dus~t||r|r|tj |z| | Wn,t y} zt | WYd} ~ n d} ~ 00dS)N-or)Z_fix_compile_argsrrextendappendforcermkpathospathdirnamespawnrr) rsourceZ output_fileZmacrosZ include_dirs extra_preargsextra_postargs fixed_argsignorepp_optsZpp_argsmsgr$r$r% preprocess^s$      zUnixCCompiler.preprocessc Csr|j}tjdkr t|||}z ||||d|g|Wn,tyl}zt|WYd}~n d}~00dS)Nr r&)rsysplatform _osx_supportcompiler_fixupr.rr) robjsrcextZcc_argsr1r4rr5r$r$r%_compilexs  zUnixCCompiler._compilerc Cs|||\}}|j||d}|||r|tj|||j|g||j |j rz||j |gWqt y}zt |WYd}~qd}~00n t d|dS)N) output_dirskipping %s (up-to-date))_fix_object_argslibrary_filename _need_linkr*r+r,r-r.robjectsrrr r debug)rrDZoutput_libnamer?rE target_langoutput_filenamer5r$r$r%create_static_libs$    zUnixCCompiler.create_static_libc Cs|||\}}||||}|\}}}t||||}t|ttdfsPtd|durftj ||}| ||r||j |d|g}| rdg|dd<| r| |dd<| r| | | tj|z|tjkr|jdd}n|jdd}| dkrr|jrrd}tj|ddkr@d}d||vr@|d7}q&tj||d kr\d}nd}|j||||<tjd krt||}|||Wn.ty}zt|WYd}~n d}~00n td |dS) Nz%'output_dir' must be a string or Noner&z-grzc++env=Z ld_so_aixr r@)rArr isinstancestrtype TypeErrorr+r,joinrCrDr'r*r-rZ EXECUTABLErrrbasenamer7r8r9r:r.rr r rE)rZ target_descrDrGr?rrr Zexport_symbolsrEr0r1Z build_temprFr2Zlib_optsZld_argsZlinkerioffsetr5r$r$r%linksZ        zUnixCCompiler.linkcCsd|S)N-Lr$)rdirr$r$r%library_dir_optionsz UnixCCompiler.library_dir_optioncstfdddDS)Nc3s|]}|vVqdS)Nr$).0name compiler_namer$r% z(UnixCCompiler._is_gcc..)Zgcczg++Zclang)any)rr[r$rZr%_is_gccszUnixCCompiler._is_gcccCstjtd}tjdddkr,d|StjdddkrFd|Stjddd krz||rnd d|gSd d|gS||rtd d krd|Sd|Snd|SdS)NCCrr rUZfreebsdz -Wl,-rpath=zhp-uxz-Wl,+sz+sZGNULDZyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)r+r,rQrrr7r8r_)rrVrr$r$r%runtime_library_dir_options     z(UnixCCompiler.runtime_library_dir_optioncCsd|S)Nz-lr$)rlibr$r$r%library_optionszUnixCCompiler.library_optioncCs|j|dd}|j|dd}|j|dd}|j|dd}tjdkr|td}td|} | durrttd } n | d } |D] } t j | |} t j | |} t j | |}t j | |}tjdkrL| d s| d rL| d sLt j | | d d|} t j | | d d|} t j | | d d|}t j | | d d|}t j | rb| St j |rx|St j | r| St j |r|SqdS)Nshared)Zlib_typedylib xcode_stubstaticr ZCFLAGSz-isysroot\s*(\S+)r`rJz/System/z/usr/z /usr/local/)rBr7r8rrresearchr9Z_default_sysrootgroupr+r,rP startswithexists)rdirsrdrEZshared_fZdylib_fZ xcode_stub_fZstatic_fZcflagsmZsysrootrVrfrgrirhr$r$r%find_library_filesF        zUnixCCompiler.find_library_file)NNNNN)NrN) NNNNNrNNNN)r)__name__ __module__ __qualname__Z compiler_typeZ executablesr7r8Zsrc_extensionsZ obj_extensionZstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZxcode_stub_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZxcode_stub_lib_formatZ exe_extensionrr6r>rHrTrWr_rcrerq __classcell__r$r$r"r%r -sN        B*r )__doc__r+r7rjZ distutilsrZdistutils.dep_utilrZdistutils.ccompilerrrrZdistutils.errorsrrr r r r8r9r r$r$r$r%s