
_rY                 @   sX   d  d l  Z  d  d l Z d d l m Z d d l m Z m Z Gd d   d e  Z d S)    N   )EnvironmentException   )Compilerswift_buildtype_argsc                   s  e  Z d  Z   f d d   Z d d   Z d d   Z d d   Z d	 d
   Z d d   Z d d   Z	 d d   Z
 d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d   Z d d    Z d! d"   Z d# d$   Z d% d&   Z d' d(   Z d) d*   Z   S)+SwiftCompilerc                s;   d |  _  t   j | |  | |  _ d |  _ d |  _ d  S)NswiftllvmF)languagesuper__init__versionidis_cross)selfexelistr   )	__class__ V/mnt/raid6/a/bak/reczko/tools/protein/utils/meson-0.42.1/mesonbuild/compilers/swift.pyr      s
    			zSwiftCompiler.__init__c             C   s   |  j  d  d   S)N)r   )r   r   r   r   get_linker_exelist   s    z SwiftCompiler.get_linker_exelistc             C   s   d j  |  j  S)N )joinr   )r   r   r   r   name_string    s    zSwiftCompiler.name_stringc             C   s   d S)NTr   )r   r   r   r   needs_static_linker#   s    z!SwiftCompiler.needs_static_linkerc             C   s   d g S)Nz--fatal-warningsr   )r   r   r   r   get_werror_args&   s    zSwiftCompiler.get_werror_argsc             C   s   d g S)Nz-emit-dependenciesr   )r   	outtargetoutfiler   r   r   get_dependency_gen_args)   s    z%SwiftCompiler.get_dependency_gen_argsc             C   s"   t  j j |  d d |  j   S)Nr   .)ospathsplitextget_depfile_suffix)r   objfiler   r   r   depfile_for_object,   s    z SwiftCompiler.depfile_for_objectc             C   s   d S)Ndr   )r   r   r   r   r"   /   s    z SwiftCompiler.get_depfile_suffixc             C   s
   d | g S)Nz-or   )r   targetr   r   r   get_output_args2   s    zSwiftCompiler.get_output_argsc             C   s
   d | g S)Nz-or   )r   r&   r   r   r   get_linker_output_args5   s    z$SwiftCompiler.get_linker_output_argsc             C   s
   d | g S)Nz-import-objc-headerr   )r   Z
headernamer   r   r   get_header_import_args8   s    z$SwiftCompiler.get_header_import_argsc             C   s   g  S)Nr   )r   levelr   r   r   get_warn_args;   s    zSwiftCompiler.get_warn_argsc             C   s   t  | S)N)r   )r   	buildtyper   r   r   get_buildtype_args>   s    z SwiftCompiler.get_buildtype_argsc             C   s   g  S)Nr   )r   r,   r   r   r   get_buildtype_linker_argsA   s    z'SwiftCompiler.get_buildtype_linker_argsc             C   s   d g S)Nz-emit-executabler   )r   r   r   r   get_std_exe_link_argsD   s    z#SwiftCompiler.get_std_exe_link_argsc             C   s
   d | g S)Nz-module-namer   )r   modnamer   r   r   get_module_argsG   s    zSwiftCompiler.get_module_argsc             C   s   d g S)Nz-emit-moduler   )r   r   r   r   get_mod_gen_argsJ   s    zSwiftCompiler.get_mod_gen_argsc             G   s   g  S)Nr   )r   argsr   r   r   build_rpath_argsM   s    zSwiftCompiler.build_rpath_argsc             C   s   d | g S)Nz-Ir   )r   dirnamer   r   r   get_include_argsP   s    zSwiftCompiler.get_include_argsc             C   s   d g S)Nz-cr   )r   r   r   r   get_compile_only_argsS   s    z#SwiftCompiler.get_compile_only_argsc       	      C   s   d } t  j j | |  } t  j j | d  } t | d   } | j d  Wd  QX|  j | d d } t j |  j | d d | | g d	 | } | j	   | j
 d
 k r t d |  j     n  t j |  d
 k r t d |  j     n  d  S)Nzswifttest.swiftZ	swifttestwz'print("Swift compilation is working.")
linkTz-emit-executablez-ocwdr   z+Swift compiler %s can not compile programs.z:Executables created by Swift compiler %s are not runnable.)r   r    r   openwriteget_cross_extra_flags
subprocessPopenr   wait
returncoder   r   call)	r   work_direnvironmentsrcsource_nameoutput_nameofileextra_flagspcr   r   r   sanity_checkV   s    ,
zSwiftCompiler.sanity_check)__name__
__module____qualname__r   r   r   r   r   r   r$   r"   r'   r(   r)   r+   r-   r.   r/   r1   r2   r4   r6   r7   rK   r   r   )r   r   r      s*   r   )	r>   os.pathr   mesonlibr   	compilersr   r   r   r   r   r   r   <module>   s   