a  ze9@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 ZZeZejdkrdZd'ddZddZd(ddZd)ddZddZdd Zd!d"Zd#d$Zd*d%d&ZdS)+ 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.exec 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) selfsourceZ output_fileZmacrosZ include_dirs extra_preargsextra_postargs fixed_argsignorepp_optsZpp_argsmsgr*K/opt/bitninja-python-dojo/embedded/lib/python3.9/distutils/unixccompiler.py preprocessUs$      zUnixCCompiler.preprocessc Csr|j}tjdkr t|||}z ||||d|g|Wn,tyl}zt|WYd}~n d}~00dS)Nr r)rsysplatform _osx_supportcompiler_fixupr!rr) r"objsrcextZcc_argsr%r(rr)r*r*r+_compileos  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_linkrrrr r!robjectsrrr r debug)r"r:Zoutput_libnamer5r; target_langoutput_filenamer)r*r*r+create_static_libzs$    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 Nonerz-grzc++env=Z ld_so_aixr r6)r7Z _fix_lib_argsr isinstancestrtype TypeErrorrrjoinr9r:rrr rZ EXECUTABLErrrbasenamer-r.r/r0r!rr r r;)r"Z target_descr:r=r5Z librariesZ library_dirsZruntime_library_dirsZexport_symbolsr;r$r%Z build_tempr<r&Zlib_optsZld_argsZlinkerioffsetr)r*r*r+linksZ        zUnixCCompiler.linkcCsd|S)N-Lr*)r"dirr*r*r+library_dir_optionsz UnixCCompiler.library_dir_optioncstfdddDS)Nc3s|]}|vVqdS)Nr*).0name compiler_namer*r+ z(UnixCCompiler._is_gcc..)Zgcczg++Zclang)any)r"rQr*rPr+_is_gccszUnixCCompiler._is_gcccCstjtd}tjdddkr,d|StjdddkrFd|Stjddd krz||rnd d|gSd d|gS||rtd d krd|Sd|Snd|SdS)NCCrr rKZfreebsdz -Wl,-rpath=zhp-uxz-Wl,+sz+sZGNULDZyesz-Wl,--enable-new-dtags,-Rz-Wl,-Rz-R)rrrGrget_config_varr-r.rU)r"rLrr*r*r+runtime_library_dir_options     z(UnixCCompiler.runtime_library_dir_optioncCsd|S)Nz-lr*)r"libr*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+)rVr@z/System/z/usr/z /usr/local/)r8r-r.rrYresearchr/Z_default_sysrootgrouprrrF startswithexists)r"dirsr[r;Zshared_fZdylib_fZ xcode_stub_fZstatic_fZcflagsmZsysrootrLr]r^r`r_r*r*r+find_library_file sF        zUnixCCompiler.find_library_file)NNNNN)NrN) NNNNNrNNNN)r)__name__ __module__ __qualname__Z compiler_typeZ executablesr-r.Zsrc_extensionsZ obj_extensionZstatic_lib_extensionZshared_lib_extensionZdylib_lib_extensionZxcode_stub_lib_extensionZstatic_lib_formatZshared_lib_formatZdylib_lib_formatZxcode_stub_lib_formatZ exe_extensionr,r4r>rJrMrUrZr\rhr*r*r*r+r -sL       B*r )__doc__rr-raZ distutilsrZdistutils.dep_utilrZdistutils.ccompilerrrrZdistutils.errorsrrr r r r.r/r r*r*r*r+s