
_rY                 @   s^   d  d l  Z  d  d l Z d d l m Z m Z d d l m Z m Z Gd d   d e  Z	 d S)    N   )EnvironmentException
Popen_safe   )Compilerrust_buildtype_argsc                   sv   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
   S)RustCompilerc                s)   d |  _  t   j | |  d |  _ d  S)Nrustrustc)languagesuper__init__id)selfexelistversion)	__class__ U/mnt/raid6/a/bak/reczko/tools/protein/utils/meson-0.42.1/mesonbuild/compilers/rust.pyr      s    	zRustCompiler.__init__c             C   s   d S)NFr   )r   r   r   r   needs_static_linker   s    z RustCompiler.needs_static_linkerc             C   s   d j  |  j  S)N )joinr   )r   r   r   r   name_string   s    zRustCompiler.name_stringc             C   s   t  j j | d  } t  j j | d  } t | d   } | j d  Wd  QXt j |  j d | | g d | } | j   | j	 d k r t
 d |  j     n  t j |  d k r t
 d	 |  j     n  d  S)
Nz	sanity.rsZrusttestwzfn main() {
}
z-ocwdr   z*Rust compiler %s can not compile programs.z9Executables created by Rust compiler %s are not runnable.)ospathr   openwrite
subprocessPopenr   wait
returncoder   r   call)r   work_direnvironmentsource_nameoutput_nameofilepcr   r   r   sanity_check!   s    %
zRustCompiler.sanity_checkc             C   s
   d | g S)Nz
--dep-infor   )r   outfiler   r   r   get_dependency_gen_args/   s    z$RustCompiler.get_dependency_gen_argsc             C   s   t  | S)N)r   )r   	buildtyper   r   r   get_buildtype_args2   s    zRustCompiler.get_buildtype_argsc             C   s   |  j  | | | | |  S)N)build_unix_rpath_args)r   	build_dirfrom_dirrpath_pathsbuild_rpathinstall_rpathr   r   r   build_rpath_args5   s    zRustCompiler.build_rpath_argsc             C   s9   |  j  d d g } t |  \ } } } | j d  d S)Nz--printZsysroot
r   )r   r   split)r   cmdpstdostder   r   r   get_sysroot8   s    zRustCompiler.get_sysroot)__name__
__module____qualname__r   r   r   r*   r,   r.   r5   r<   r   r   )r   r   r      s   r   )
r   os.pathr   mesonlibr   r   	compilersr   r   r   r   r   r   r   <module>   s   