ef<dZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z m Z ddlmZmZmZmZddlmZdd lmZd Zd Zd ZGd de 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)log)compiler_fixupcd}tj|ddkrd}d||vr|dz }d||v|d|||dfS)z For macOS, split command into 'env' portion (if any) and the rest of the linker command. >>> _split_env(['a', 'b', 'c']) ([], ['a', 'b', 'c']) >>> _split_env(['/usr/bin/env', 'A=3', 'gcc']) (['/usr/bin/env', 'A=3'], ['gcc']) renvr=Nospathbasenamecmdpivots /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/setuptools/_distutils/unixccompiler.py _split_envr-sq E wA5((SZ QJESZ vv;EFF ##c|tj|ddk}|d|||dfS)a AIX platforms prefix the compiler with the ld_so_aix script, so split that from the linker command. >>> _split_aix(['a', 'b', 'c']) ([], ['a', 'b', 'c']) >>> _split_aix(['/bin/foo/ld_so_aix', 'gcc']) (['/bin/foo/ld_so_aix'], ['gcc']) r ld_so_aixNrrs r _split_aixr?s= G  SV $ $ 3E vv;EFF ##rcXt|}|d||kr|nd}||dS)a The linker command usually begins with the compiler command (possibly multiple elements), followed by zero or more params for shared library building. If the LDSHARED env variable overrides the linker command, however, the commands may not match. Return the best guess of the linker parameters by stripping the linker command. If the compiler command does not match the linker command, assume the linker command is just the first element. >>> _linker_params('gcc foo bar'.split(), ['gcc']) ['foo', 'bar'] >>> _linker_params('gcc foo bar'.split(), ['other']) ['foo', 'bar'] >>> _linker_params('ccache gcc foo bar'.split(), 'ccache gcc'.split()) ['foo', 'bar'] >>> _linker_params(['gcc'], ['gcc']) [] Nr)len) linker_cmd compiler_cmdc_lenrs r_linker_paramsr$Ms<.   E'<77EEQE eff rc $eZdZdZddgdgdgddgdgddgddZejddd krd ged <gd Zd Zd Z dZ dZ dZ dxZ xZZeZejdkrdZ ddZdZ d dZ d!dZdZdZdZdZedZd"dZdS)# UnixCCompilerunixNccz-sharedarz-cr) preprocessorcompiler compiler_so compiler_cxx linker_so linker_exearchiverranlibdarwinr1)z.cz.Cz.ccz.cxxz.cppz.mz.oz.az.soz.dylibz.tbdzlib%s%scygwinz.exec$|d||}|\}}}t||} |j| z} |r| d|g|r|| dd<|r| || ||jp|dupt ||} | sdS|r2|tj | | | dS#t$r} t| d} ~ wwxYw)N-or)_fix_compile_argsrr*extendappendforcermkpathrrdirnamespawnr r ) selfsource output_filemacros include_dirs extra_preargsextra_postargs fixed_argsignorepp_optspp_args preprocessmsgs rrIzUnixCCompiler.preprocesssD++D&,GG '1$ (>>#g-  0 NND+. / / /  ('GBQBK  + NN> * * *v ZT;$#6T% :T:T   F  6 KK 44 5 5 5 $ JJw     ! $ $ $s## # $sC11 D;D  Dct|j||z} |||z|d|gz|zdS#t$r}t |d}~wwxYw)Nr6)rr,r=r r ) r>objsrcextcc_argsrDrGr,rJs r_compilezUnixCCompiler._compilesy$T%5w7OPP  $ JJ{W,T3/??.P Q Q Q Q Q! $ $ $s## # $s!= AAArc|||\}}|||}|||r|tj|||j|gz|z|j z|j rB ||j |gzdS#t$r}t|d}~wwxYwdStjd|dS)N) output_dirskipping %s (up-to-date))_fix_object_argslibrary_filename _need_linkr;rrr<r=r0objectsr1r r r debug)r>rWoutput_libnamerRrX target_langoutput_filenamerJs rcreate_static_libzUnixCCompiler.create_static_libs#33GZHH//:/VV ??7O 4 4 C KK88 9 9 9 JJt}'887BT\Q R R R{ ((JJt{o->>?????)((("3--'( ( ( I0/ B B B B Bs*C C(C##C(cP|||\}}||||}|\}}}t||||}t|tt dfst d| tj ||}| ||r\||j z|zd|gz}| rdg|dd<| r| |dd<| r| | | tj| |tjk}|r|jn|jdd}| dkrt|jrmt)|\}}t+|\}}t)|j\}}t)|j\}}t-||}||z|z|z}t/||}|||zdS#t2$r}t5|d}~wwxYwt7jd|dS)Nz%'output_dir' must be a string or Noner6z-grzc++rS)rT _fix_lib_argsr isinstancestrtype TypeErrorrrjoinrVrWr8r;r<r EXECUTABLEr/r.r-rrr$rr=r r r rX)r> target_descrWr[rR libraries library_dirsruntime_library_dirsexport_symbolsrXrCrD build_temprZrElib_optsld_args building_exelinkerr linker_neaix linker_na_compiler_cxx_ne linker_exe_neparamsrJs rlinkzUnixCCompiler.linksX #33GZHH'' dirs rlibrary_dir_optionz UnixCCompiler.library_dir_option czrctjd}tjt j|d}d|vpd|vS)NCCrgcczg++)rget_config_varrrrshlexsplit)r>cc_varr+s r_is_gcczUnixCCompiler._is_gccsK)$//7##EK$7$7$:;; 5EX$55rcxtjdddkr/ddlm}m}|}|r||ddgkrd|zSd|zStjdd d krd |zStjddd kr|rd ndd|zgSt jddkrd|zSd|zS)Nr2r3r)get_macosx_target_ver split_version z -Wl,-rpath,rxfreebsdz -Wl,-rpath=zhp-uxz-Wl,+sz+sGNULDyesz-Wl,--enable-new-dtags,-Rz-Wl,-R)sysplatformdistutils.utilrrrrr)r>rzrrmacosx_target_vers rruntime_library_dir_optionz(UnixCCompiler.runtime_library_dir_options < x ' ' K K K K K K K K 5 5 7 7   "]]3D%E%E"a%P%P$s**cz! \"1"  * * 3& & \"1"  ( ( LLNN4s    #G , , 5 5/4 4c> !rc d|zS)Nz-lry)r>libs rlibrary_optionzUnixCCompiler.library_optionDr|rcvtjd}tjd|}tjdkoA|o?|dp*|do|d }|r;tj | d|ddn|S) a macOS users can specify an alternate SDK using'-isysroot'. Calculate the SDK root if it is specified. Note that, as of Xcode 7, Apple SDKs may contain textual stub libraries with .tbd extensions rather than the normal .dylib shared libraries installed in /. The Apple compiler tool chain handles this transparently but it can cause problems for programs that are being built with an SDK and searching for specific libraries. Callers of find_library_file need to keep in mind that the base filename of the returned SDK library file might have a different extension from that of the library file installed on the running system, for example: /Applications/Xcode.app/Contents/Developer/Platforms/ MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/ usr/lib/libedit.tbd vs /usr/lib/libedit.dylib CFLAGSz-isysroot\s*(\S+)r3z/System/z/usr/z /usr/local/rN) rrresearchrr startswithrrrcgroup)rzcflagsmatch apply_roots r _library_rootzUnixCCompiler._library_rootGs*)(33 .77 LH $  z**SNN7++QCNN=4Q4Q0Q 9CKrw||EKKNNCG444KrcfddD}tj|}dtj||D}t t jj|}t|dS)a/ Second-guess the linker with not much hard data to go on: GCC seems to prefer the shared library, so assume that *all* Unix C compilers do, ignoring even GCC's "-static" option. >>> compiler = UnixCCompiler() >>> compiler._library_root = lambda dir: dir >>> monkeypatch = getfixture('monkeypatch') >>> monkeypatch.setattr(os.path, 'exists', lambda d: 'existing' in d) >>> dirs = ('/foo/bar/missing', '/foo/bar/existing') >>> compiler.find_library_file(dirs, 'abc').replace('\\', '/') '/foo/bar/existing/libabc.dylib' >>> compiler.find_library_file(reversed(dirs), 'abc').replace('\\', '/') '/foo/bar/existing/libabc.dylib' >>> monkeypatch.setattr(os.path, 'exists', ... lambda d: 'existing' in d and '.a' in d) >>> compiler.find_library_file(dirs, 'abc').replace('\\', '/') '/foo/bar/existing/libabc.a' >>> compiler.find_library_file(reversed(dirs), 'abc').replace('\\', '/') '/foo/bar/existing/libabc.a' c3FK|]}|VdS))lib_typeN)rU).0rarr>s r z2UnixCCompiler.find_library_file..sJ    ! !# ! 5 5      rzdylib xcode_stub shared staticc3\K|]'\}}tj||V(dS)N)rrrc)rrootlib_names rrz2UnixCCompiler.find_library_file..sJ  h GLLx ( (      rN) rmapr itertoolsproductfilterrrexistsnext)r>dirsrrX lib_namesrootssearchedfounds` ` rfind_library_filezUnixCCompiler.find_library_filejs.     8>>@@   D&--  "+"3E9"E"E    rw~x00E4   r)NNNNN)NrN) NNNNNrNNNN)r)__name__ __module__ __qualname__ compiler_type executablesrrsrc_extensions obj_extensionstatic_lib_extensionshared_lib_extensiondylib_lib_extensionxcode_stub_lib_extensionstatic_lib_formatshared_lib_formatdylib_lib_formatxcode_stub_lib_format exe_extensionrIrPr\rvr{rrr staticmethodrrryrrr&r&isMFvI&f5M  K |BQB8##!) H?>>NM "%?HHH),<, |x #$#$#$#$J$$$NRCCCC:!9C9C9C9C~666 &"&"&"P L L\ LD&!&!&!&!&!&!rr&)__doc__rrrrrr _modifiedr ccompilerrrrerrorsr r r r _logr _macos_compatrrrr$r&ryrrrs6   IIIIIIIIIIIIIIIIIIIIII))))))$$$$$ $ $ $8g!g!g!g!g!Ig!g!g!g!g!r