
    eCi                         d dl Z d dlZd dlZd dlZddlmZ ddlmZ  eej	        
                    dd                    Zd Zd Zd	 Zd
 ZdS )    N   )sharedWINDOWS
EMCC_DEBUG0c                     ddgt           sdgz  fdfd| D             } d}| D ]}d|v rd|z  }||d	z   z  }|S )
z<Create response file contents based on list of arguments.
  \"'c                 D    D ]}|                      |d|z             } | S )Nr
   )replace)argcharescape_charss     7/b/s/w/ir/x/w/install/emscripten/tools/response_file.pyescapez-create_response_file_contents.<locals>.escape   s0     + +KKdTk**ccJ    c                 &    g | ]} |          S  r   ).0ar   s     r   
<listcomp>z1create_response_file_contents.<locals>.<listcomp>   s!    	"	"	"&&))	"	"	"r     z"%s"
r   )argscontentsr   r   r   s      @@r   create_response_file_contentsr      s     ,	 TFL    
 
#	"	"	"T	"	"	"$(   c
czzSLcd
HH	/r   c                 p   t          |           }t          j        dd|d          \  }}t          j        |dd          5 }|                    |           ddd           n# 1 swxY w Y   t          rt          j        d	| d
|            t          j
                                        |           |S )ziRoutes the given cmdline param list in args into a new response file and
  returns the filename to it.
  emscripten_z
.rsp.utf-8T)prefixsuffixdirtextwzutf-8encodingNzCreating response file z with following contents: )r   tempfilemkstemposfdopenwriteDEBUGloggingwarningr   get_temp_filesnote)r   	directoryr   response_fdresponse_filenamefs         r   create_response_filer7   *   s   
 +400(#+#3=Q]clsw#x#x#x + 	ycG444 GGH                gOe.?ee[ceefff 	0111	s   A$$A(+A(c                    |                      d          r| dd         }n"|                      d          r| dd         }nd}|rt          j                            |          s| gS t          j                            |                              d          }|d                                         }t          |          dk    r|                     d          s|d	v r|}nd
}	 t          ||          5 }|	                                }ddd           n# 1 swxY w Y   nt# t          t          f$ r` t          rt          j        d| d| d           t          |          5 }|	                                }ddd           n# 1 swxY w Y   Y nw xY wt          j        |          }t          rt          j        d| d|            t!          |          S )a  Reads a response file, and returns the list of cmdline params found in the
  file.

  The encoding that the response filename should be read with can be specified
  as a suffix to the file, e.g. "foo.rsp.utf-8" or "foo.rsp.cp1252". If not
  specified, first UTF-8 and then Python locale.getpreferredencoding() are
  attempted.

  The parameter `arg` is the command line argument to be expanded.@r   Nz-Wl,@   .)utfcpiso>   latin-1asciiz	utf-8-sigr'   zfailed to parse response file z with guessed encoding "z$". Trying default system encoding...zread response file z: )
startswithr+   pathexistsbasenamesplitlowerlenopenread
ValueErrorLookupErrorr.   r/   r0   shlexsubstitute_response_files)r   r5   
componentsencoding_suffixguessed_encodingr6   r   s          r   expand_response_filerR   @   s    	^^C ABB
~~g ABB 
 "'..1B"C"C 5L w 12288==*rN((**/__qo889MNNRaeyRyRy&
 #		*:	;	;	; qVVXXd              
k	"    Zo  Y7H  Y  Ybr  Y  Y  Y  Z  Z  Z		 	  AVVXXd              	 
T		$
 GOE*;EEtEEFFF 
#4	(	((s[   %D# 6DD# DD# DD# #AF%F:FF
	
FF
	FFc                 8    g }| D ]}|t          |          z  }|S )z@Substitute any response files found in args with their contents.)rR   )r   new_argsr   s      r   rN   rN   v   s0    ( * *c$S)))HH	/r   )r/   r+   rM   r)   r   r   utilsr   intenvirongetr.   r   r7   rR   rN   r   r   r   <module>rY      s     				              BJNN<--..  2  ,3) 3) 3)l    r   