3 \W:@sxdZddlZddlmZmZmZmZmZmZddl m Z m Z m Z ddl mZddlmZddlmZGdd d e ZdS) zdistutils.bcppcompiler Contains BorlandCCompiler, an implementation of the abstract CCompiler class for the Borland C++ compiler. N)DistutilsExecErrorDistutilsPlatformError CompileErrorLibError LinkErrorUnknownFileError) CCompilergen_preprocess_optionsgen_lib_options) write_file)newer)logc @seZdZdZdZiZdgZdddgZeeZdZ dZ d Z d Z Z d Zdd dZdddZdddZd ddZd!ddZd"ddZd#ddZdS)$ BCPPCompilerzConcrete class that implements an interface to the Borland C/C++ compiler, as defined by the CCompiler abstract class. Zbcppz.cz.ccz.cppz.cxxz.objz.libz.dllz%s%sz.exercCstj||||d|_d|_d|_d|_ddddg|_ddddg|_d d dd g|_d d dd g|_ g|_ d dd g|_ d dd d g|_ dS) Nz bcc32.exez ilink32.exeztlib.exez/tWMz/O2z/qz/g0z/Odz/Tpdz/Gnz/xz/r) r__init__cclinkerlibZpreprocess_optionscompile_optionscompile_options_debugldflags_sharedldflags_shared_debugZldflags_static ldflags_exeldflags_exe_debug)selfverboseZdry_runforcer$/usr/lib64/python3.6/bcppcompiler.pyr5s zBCPPCompiler.__init__Nc Cs|j||||||\}} }} } |p$g} | jd|rB| j|jn | j|jxD| D]:} y| | \}}Wntk rwVYnXtjj|}tjj| } |j tjj | |dkrqV|dkry|j dd| |gWqVt k r}zt |WYdd}~XqVXqV||jkrd}n||jkr,d}nd}d| }y,|j |jg| | ||g||gWqVt k r}zt |WYdd}~XqVXqVW| S) Nz-cz.resz.rcZbrcc32z-foz-Pz-o)Z_setup_compileappendextendrrKeyErrorospathnormpathmkpathdirnamespawnrr _c_extensions_cpp_extensionsr)rZsources output_dirmacros include_dirsdebug extra_preargsextra_postargsZdependsobjectspp_optsZbuildZ compile_optsobjsrcextmsgZ input_optZ output_optrrrcompileQsF        (zBCPPCompiler.compilec Cs|j||\}}|j||d}|j||r~|dg|}|r:y|j|jg|Wqtk rz}zt|WYdd}~XqXn tjd|dS)N)r*z/uzskipping %s (up-to-date)) _fix_object_argslibrary_filename _need_linkr'rrrr r-) rr0Zoutput_libnamer*r- target_langoutput_filenameZlib_argsr5rrrcreate_static_libs  zBCPPCompiler.create_static_libc Cs|j||\}}|j|||\}}}|r8tjdt||dk rNtjj||}|j||r|t j krd}| r~|j dd}q|j dd}n&d}| r|j dd}n|jdd}|dkrd}ntjj|\}}tjj|\}}tjj|d}tjj|d|}dg}x&|pgD]}|jd||fqW|jt||fd |ttjj|}|g}g}xF|D]>}tjjtjj|\}}|d kr|j|n |j|qfWx$|D]}|jd tjj|qW|jd |j||jd |g|jdx<|D]4}|j||| }|dkr(|j|n |j|qW|jd|jd|jd |g|jd |j|| r| |dd<| r|j| |jtjj|y|j|jg|Wn,tk r}zt|WYdd}~XnXn tjd|dS)Nz7I don't know what to do with 'runtime_library_dirs': %sZc0w32Zc0d32rrz%s.defZEXPORTSz %s=_%sz writing %sz.resz/L%sz/L.,z,,Zimport32Zcw32mtzskipping %s (up-to-date)) r7Z _fix_lib_argsr warnstrr"r#joinr9rZ EXECUTABLErrrrsplitsplitextr&rZexecuter mapr$normcaser find_library_filer%r'rrrr-) rZ target_descr0r;r*Z librariesZ library_dirsZruntime_library_dirsZexport_symbolsr-r.r/Z build_tempr:Z startup_objZld_argsZdef_fileheadtailmodnamer4Ztemp_dircontentsZsymZobjects2Z resourcesfilebaselrlibfiler5rrrlinks|                    zBCPPCompiler.linkc Csv|r"|d}|d|d||f}n |d|f}xB|D]6}x0|D](}tjj||j|}tjj|r>|Sq>Wq4WdSdS)NZ_dZ_bcpp)r"r#r@r8exists) rdirsrr-ZdlibZ try_namesdirnamerMrrrrE4s      zBCPPCompiler.find_library_filercCs|dkr d}g}x|D]}tjjtjj|\}}||jddgkrTtd||f|rdtjj|}|dkr|jtjj|||q|dkr|jtjj||dq|jtjj|||j qW|S)Nrz.rcz.resz"unknown file type '%s' (from '%s')) r"r#rBrDsrc_extensionsrbasenamerr@ obj_extension)rZsource_filenamesZ strip_dirr*Z obj_namesZsrc_namerKr4rrrobject_filenamesNs"    zBCPPCompiler.object_filenamesc Cs|jd||\}}}t||}dg|} |dk r>| jd||rN|| dd<|r\| j|| j||js~|dks~t||r|r|jtjj |y|j | Wn2t k r} zt | t | WYdd} ~ XnXdS)Nz cpp32.exez-or)Z_fix_compile_argsr rr rr r%r"r#r&r'rprintr) rsourceZ output_filer+r,r.r/_r1Zpp_argsr5rrr preprocessis$      zBCPPCompiler.preprocess)rrr)NNNrNNN)NrN) NNNNNrNNNN)r)rr)NNNNN)__name__ __module__ __qualname____doc__Z compiler_typeZ executablesr(r)rSrUZstatic_lib_extensionZshared_lib_extensionZstatic_lib_formatZshared_lib_formatZ exe_extensionrr6r<rNrErVrZrrrrrsJ   B  |  r)r^r"Zdistutils.errorsrrrrrrZdistutils.ccompilerrr r Zdistutils.file_utilr Zdistutils.dep_utilr Z distutilsr rrrrrs