Ñò
 „Pc        	   @   s^  d  Z  d d k Z d d k Z d d k Z d d k l Z l Z l Z d d k Z d Z	 d Z
 d Z d Z d e i e i e f Z d	 Z d
 Z d Z d Z d Z d Z d a d Z d Z d a d Z d Z d d g Z e a d Z d Z  d Z! g  a" d „  Z# d e$ f d „  ƒ  YZ% e% d e& f h  ƒ Z' d e' f d „  ƒ  YZ( h  Z) d „  Z* e d „ Z+ d S(   s1   
Classes and functions required for waf commands
iÿÿÿÿN(   t   Utilst   Errorst   Logsi s   1.7.1t(   a7e69d6b81b04729804754c4d5214da063779a65ib   s   .wafpickle-%s-%d-%dt   APPNAMEt   VERSIONt   topt   outt   wscriptt    s   http://waf.googlecode.com/git/s   waflib/extrass   waflib/Toolsi   i    c         O   sK   x, t  D]$ } | i |  j o | | | Ž  Sq Wt | | Ž  } |  | _ | S(   st  
	Create a new :py:class:`waflib.Context.Context` instance corresponding to the given command.
	Used in particular by :py:func:`waflib.Scripting.run_command`

	:param cmd_name: command
	:type cmd_name: string
	:param k: arguments to give to the context class initializer
	:type k: list
	:param k: keyword arguments to give to the context class initializer
	:type k: dict
	(   t   classest   cmdt   Contextt   fun(   t   cmd_namet   kt   kwt   xt   ctx(    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   create_contextV   s     	t   store_contextc           B   s   e  Z d  Z d „  Z RS(   s³   
	Metaclass for storing the command classes into the list :py:const:`waflib.Context.classes`
	Context classes must provide an attribute 'cmd' representing the command to execute
	c         C   s¯   t  t |  ƒ i | | | ƒ |  i } | d j p | d j o d  Sy |  i Wn& t j
 o t i d | ƒ ‚ n Xt |  d d  ƒ p |  i |  _
 n t i d |  ƒ d  S(   NR   R   s.   Missing command for the context class %r (cmd)R   i    (   t   superR   t   __init__t   __name__R   t   AttributeErrorR   t   WafErrort   getattrt   NoneR   R
   t   insert(   t   clst   namet   basest   dict(    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyR   o   s    	(   R   t
   __module__t   __doc__R   (    (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyR   j   s   R   R   c           B   s¶   e  Z d  Z e Z h  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d e e d „ Z d „  Z d	 „  Z d d
 „ Z d „  Z d d „ Z d „  Z d d „ Z g  d „ Z RS(   sÁ  
	Default context for waf commands, and base class for new command contexts.

	Context objects are passed to top-level functions::

		def foo(ctx):
			print(ctx.__class__.__name__) # waflib.Context.Context

	Subclasses must define the attribute 'cmd':

	:param cmd: command to execute as in ``waf cmd``
	:type cmd: string
	:param fun: function name to execute when the command is called
	:type fun: string

	.. inheritance-diagram:: waflib.Context.Context waflib.Build.BuildContext waflib.Build.InstallContext waflib.Build.UninstallContext waflib.Build.StepContext waflib.Build.ListContext waflib.Configure.ConfigurationContext waflib.Scripting.Dist waflib.Scripting.DistCheck waflib.Build.CleanContext

	c         K   sá   y | d } Wn t  j
 o t } n Xd t i i f d „  ƒ  Y} | |  _ d |  i _ d |  i _ |  |  i _ |  i d d  ƒ |  _	 d  |  _
 |  i	 i | ƒ |  _ g  |  _ h |  d 6|  d 6|  d	 6|  d
 6|  _ d  |  _ d  S(   Nt   run_dirt
   node_classc           B   s   e  Z RS(    (   R   R!   (    (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyR$   ª   s   s   waflib.Nodet   Nod3R	   R   t   conft   bldt   opt(   t   KeyErrorR#   t   waflibt   NodeR$   R!   R   R   R   t   roott
   cur_scriptt   find_dirt   patht
   stack_patht	   exec_dictt   logger(   t   selfR   t   rdR$   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyR   ¢   s    			%c         C   s
   t  |  ƒ S(   s‰   
		Return a hash value for storing context objects in dicts or sets. The value is not persistent.

		:return: hash value
		:rtype: int
		(   t   id(   R3   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   __hash__¹   s    c   	      O   s„   t  i | ƒ } t  i | i d d ƒ ƒ } xS | D]K } t | | ƒ } t | | i d |  i ƒ d ƒ } | o | |  ƒ q1 q1 Wd S(   s   
		Load a Waf tool as a module, and try calling the function named :py:const:`waflib.Context.Context.fun` from it.
		A ``tooldir`` value may be provided as a list of module paths.

		:type tool_list: list of string or space-separated string
		:param tool_list: list of Waf tools to use
		t   tooldirR	   R   N(   R    t   to_listt   gett	   load_toolR   R   R   (	   R3   t	   tool_listR   R   t   toolsR/   t   tt   moduleR   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   loadÂ   s     !c         C   s#   |  i  t i i t i ƒ g ƒ d S(   s>   
		Execute the command. Redefine this method in subclasses.
		N(   t   recurset   osR/   t   dirnamet   g_modulet	   root_path(   R3   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   executeÓ   s    c         C   s,   |  i  i |  i ƒ | |  _ | i |  _ d S(   s  
		Method executed immediately before a folder is read by :py:meth:`waflib.Context.Context.recurse`. The node given is set
		as an attribute ``self.cur_script``, and as the current path ``self.path``

		:param node: script
		:type node: :py:class:`waflib.Node.Node`
		N(   R0   t   appendR-   t   parentR/   (   R3   t   node(    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   pre_recurseÚ   s    	c         C   s3   |  i  i ƒ  |  _ |  i o |  i i |  _ n d S(   s·   
		Restore ``self.cur_script`` and ``self.path`` right after :py:meth:`waflib.Context.Context.recurse` terminates.

		:param node: script
		:type node: :py:class:`waflib.Node.Node`
		N(   R0   t   popR-   RG   R/   (   R3   RH   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   post_recurseç   s    
c         B   se  y |  i  } Wn  e j
 o h  } |  _  n Xx.e i | ƒ D]} e i i | ƒ p" e i i |  i i ƒ  | ƒ } n e i i | e	 ƒ } | d | p |  i
 } |  i i | ƒ }	 |	 ow | p |	 | j ob e | |	 <|  i |	 ƒ z6 |	 i d ƒ }
 e |
 |	 i ƒ  d ƒ |  i f d UWd |  i |	 ƒ Xq@ |	 p|  i i | ƒ }	 |	 | p |  i
 f } |	 o¿ | p | | j oª e | | <|  i |	 ƒ z~ e |	 i ƒ  ƒ } e | | p |  i
 d ƒ } | p; | p w@ n e i d | p |  i
 |	 i ƒ  f ƒ ‚ n | |  ƒ Wd |  i |	 ƒ Xq]|	 p% | p q@ n e i d | ƒ ‚ q]q@ q@ Wd S(   s²  
		Run user code from the supplied list of directories.
		The directories can be either absolute, or relative to the directory
		of the wscript file. The methods :py:meth:`waflib.Context.Context.pre_recurse` and :py:meth:`waflib.Context.Context.post_recurse`
		are called immediately before and after a script has been executed.

		:param dirs: List of directories to visit
		:type dirs: list of string or space-separated string
		:param name: Name of function to invoke from the wscript
		:type  name: string
		:param mandatory: whether sub wscript files are required to exist
		:type  mandatory: bool
		:param once: read the script file once for a particular context
		:type once: bool
		t   _t   rUt   execNs   No function %s defined in %ss   No wscript file in directory %s(   t   recurse_cacheR   R    R8   RA   R/   t   isabst   joint   abspatht   WSCRIPT_FILER   R,   t	   find_nodet   TrueRI   t   readt   compileR1   RK   t   load_moduleR   R   R   R   (   R3   t   dirsR   t	   mandatoryt   oncet   cachet   dt   WSCRIPTt   WSCRIPT_FUNRH   t   function_codet   tupt   wscript_modulet   user_function(    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyR@   ò   sJ     "
'
-c   	      K   s  t  i } t | t ƒ | d <t i d | ƒ t i d | ƒ |  i o |  i i | ƒ n d | j o | i | d <n d | j o | i | d <n yo | d p | d o1 | i	 | |  } | i
 ƒ  \ } } | i } n% d \ } } | i	 | |  i ƒ  } Wn4 t j
 o( } t i d t | ƒ d | ƒ‚ n X| of t | t ƒ p  | i t i i p d ƒ } n |  i o |  i i d	 | ƒ q«t i i | ƒ n | of t | t ƒ p  | i t i i p d ƒ } n |  i o |  i i d
 | ƒ qt i i | ƒ n | S(   sü  
		Execute a command and return the exit status. If the context has the attribute 'log',
		capture and log the process stderr/stdout for logging purposes::

			def run(tsk):
				ret = tsk.generator.bld.exec_command('touch foo.txt')
				return ret

		This method captures the standard/error outputs (Issue 1101), but it does not return the values
		unlike :py:meth:`waflib.Context.Context.cmd_and_log`

		:param cmd: command argument for subprocess.Popen
		:param kw: keyword arguments for subprocess.Popen
		t   shells
   runner: %rs   runner_env: kw=%st   stdoutt   stderrs   Execution failure: %st   exs	   iso8859-1s   out: %ss   err: %sN(   NN(   R    t
   subprocesst
   isinstancet   strR   t   debugR2   t   infot   PIPEt   Popent   communicatet
   returncodeR   t   waitt	   ExceptionR   R   t   decodet   sysRe   t   encodingt   writet   errorRf   (	   R3   R   R   Rh   t   pR   t   errt   rett   e(    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   exec_command.  s@    	
$ 
 
c   
      K   sW  t  i } t | t ƒ | d <t i d | ƒ d | j o | d } | d =n d } d | j o | d } | d =n t } | i | d <| d <| d j o |  i	 | ƒ n y( | i
 | |  } | i ƒ  \ } } Wn4 t j
 o( }	 t i d t |	 ƒ d |	 ƒ‚ n Xt | t ƒ p  | i t i i p d	 ƒ } n t | t ƒ p  | i t i i p d	 ƒ } n | o/ | t j o" | t j o |  i	 d
 | ƒ n | o/ | t j o" | t j o |  i	 d | ƒ n | i oD t i d | | i f ƒ }	 | i |	 _ | |	 _ | |	 _ |	 ‚ n | t j o | | f S| t j o | S| S(   sˆ  
		Execute a command and return stdout if the execution is successful.
		An exception is thrown when the exit status is non-0. In that case, both stderr and stdout
		will be bound to the WafError object::

			def configure(conf):
				out = conf.cmd_and_log(['echo', 'hello'], output=waflib.Context.STDOUT, quiet=waflib.Context.BOTH)
				(out, err) = conf.cmd_and_log(['echo', 'hello'], output=waflib.Context.BOTH)
				try:
					conf.cmd_and_log(['which', 'someapp'], output=waflib.Context.BOTH)
				except Exception as e:
					print(e.stdout, e.stderr)

		:param cmd: args for subprocess.Popen
		:param kw: keyword arguments for subprocess.Popen
		Rd   s
   runner: %rt   quiett   outputRe   Rf   s   Execution failure: %sRg   s	   iso8859-1s   out: %ss   err: %ss   Command %r returned %rN(   R    Rh   Ri   Rj   R   Rk   R   t   STDOUTRm   t   to_logRn   Ro   Rr   R   R   Rs   Rt   Re   Ru   t   BOTHt   STDERRRp   Rf   (
   R3   R   R   Rh   R}   t   to_retRx   R   Ry   R{   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   cmd_and_logf  sL    	

$  !!
		
c         C   s„   |  i  o' |  i  i d |  i i ƒ  | f ƒ n y! d | |  i  i d i f } Wn t j
 o n X|  i i | d | ƒ‚ d S(   s  
		Raise a configuration error to interrupt the execution immediately::

			def configure(conf):
				conf.fatal('a requirement is missing')

		:param msg: message to display
		:type msg: string
		:param ex: optional exception object
		:type ex: exception
		s   from %s: %ss   %s
(complete log in %s)i    Rg   N(	   R2   Rl   R/   RR   t   handlerst   baseFilenameRr   t   errorst   ConfigurationError(   R3   t   msgRg   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   fatal§  s    
'!c         C   sQ   | p d S|  i  o |  i  i | ƒ n$ t i i t | ƒ ƒ t i i ƒ  d S(   s)  
		Log some information to the logger (if present), or to stderr. If the message is empty,
		it is not printed::

			def build(bld):
				bld.to_log('starting the build')

		When in doubt, override this method, or provide a logger on the context class.

		:param msg: message
		:type msg: string
		N(   R2   Rl   Rt   Rf   Rv   Rj   t   flush(   R3   R‰   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyR€   »  s    
c         C   sI   |  i  | ƒ t | t ƒ p | o d p d } n |  i | | ƒ d S(   s  
		Print a configuration message of the form ``msg: result``.
		The second part of the message will be in colors. The output
		can be disabled easly by setting ``in_msg`` to a positive value::

			def configure(conf):
				self.in_msg = 1
				conf.msg('Checking for library foo', 'ok')
				# no output

		:param msg: message to display to the user
		:type msg: string
		:param result: result to display
		:type result: string or boolean
		:param color: color to use, see :py:const:`waflib.Logs.colors_lst`
		:type color: string
		t   GREENt   YELLOWN(   t	   start_msgRi   Rj   t   end_msg(   R3   R‰   t   resultt   color(    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyR‰   Ñ  s    c         C   sò   y" |  i  o |  i  d 7_  d SWn t j
 o d |  _  n X|  i  d 7_  y t |  i t | ƒ ƒ |  _ Wn+ t j
 o t d t | ƒ ƒ |  _ n Xx( |  i d | f D] } |  i | ƒ q± Wt i d d | i |  i ƒ d d	 ƒd S(
   sd   
		Print the beginning of a 'Checking for xxx' message. See :py:meth:`waflib.Context.Context.msg`
		i   Ni    i(   t   -t   NORMALs   %s :t   sepR	   (	   t   in_msgR   t   maxt	   line_justt   lenR€   R   t   pprintt   ljust(   R3   R‰   R   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyRŽ   ê  s    
	 c         C   sŒ   |  i  d 8_  |  i  o d Sd } | t j o
 d } n* | t j o d } d } n t | ƒ } |  i | ƒ t i | p | | ƒ d S(   sT   Print the end of a 'Checking for' message. See :py:meth:`waflib.Context.Context.msg`i   NRŒ   t   oks	   not foundR   (   R•   RU   t   FalseRj   R€   R   R™   (   R3   R   R‘   t   defcolorR‰   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyR   þ  s    


c         C   sf   |  i  i t ƒ i d ƒ i | ƒ } x; | D]3 } | i | j o t | i i d d ƒ ƒ q+ q+ Wd  S(   Ns   waflib/extrass   .pyR	   (   R,   RT   t   waf_dirt   ant_globR   R:   t   replace(   R3   t   vart   bant   lstR   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   load_special_tools  s
    $ N(   R   R!   R"   R   R‡   R<   R   R6   R?   RE   RI   RK   R   RU   R@   R|   R„   RŠ   R€   R‰   RŽ   R   R¤   (    (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyR   „   s$   							<	8	A		c      
   B   sÙ   y e  |  SWn e j
 o n Xe i e ƒ } y e i |  d d ƒ} Wn, e e f j
 o e	 i
 d |  ƒ ‚ n Xe i i |  ƒ } e i i d | ƒ e | |  d ƒ | i f d Ue i i | ƒ | e  |  <| S(   s†   
	Load a source file as a python module.

	:param path: file path
	:type path: string
	:return: Loaded Python module
	:rtype: module
	t   mRM   s   Could not read the file %ri    RN   N(   t   cache_modulesR)   t   impt
   new_moduleRS   R    t   readft   IOErrort   OSErrorR   R   RA   R/   RB   Rt   R   RW   t   __dict__t   remove(   R/   R>   t   codet
   module_dir(    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyRX     s    	
c      
   C   s‰  |  d j o
 d }  n* |  d j o
 d }  n |  i  d d ƒ }  | o| t | t ƒ p t ‚ | t i t _ z, t |  ƒ t i |  } | t i	 |  <| SWd x | D] } t i i
 | ƒ q¤ WXnÃ y* t i t i i t d d	 |  d
 ƒ ƒ Wnc t j
 oW y* t i t i i t d d |  d
 ƒ ƒ Wn t j
 o |  } q]Xd |  } n Xd |  } t | ƒ t i | } | t i	 |  <| Sd S(   sö   
	Import a Waf tool (python module), and store it in the dict :py:const:`waflib.Context.Context.tools`

	:type  tool: string
	:param tool: Name of the tool
	:type  tooldir: list
	:param tooldir: List of directories to search for the tool module
	t   javat   javawt   compiler_cct
   compiler_cs   ++t   xxNR*   t   extrass   .pyt   Toolss   waflib.Tools.%ss   waflib.extras.%s(   R    Ri   t   listt   AssertionErrorRt   R/   t
   __import__t   modulesR   R<   R­   RA   t   statRQ   Rž   R«   (   t   toolR7   Rz   R]   (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyR:   <  s:    	


 **

(,   R"   RA   R§   Rt   R*   R    R   R   t   waflib.Nodet
   HEXVERSIONt
   WAFVERSIONt   WAFREVISIONt   ABIt   platformt
   hexversiont   DBFILER   R   t   TOPt   OUTRS   t
   launch_dirR#   t   top_dirt   out_dirRž   t
   local_repot   remote_repot   remote_locsR   RC   R   R‚   R   R
   R   t   typeR   t   objectR   R   R¦   RX   R:   (    (    (    s;   /home/data/ftp/pub/unpacked/waf.tmpconfig/waflib/Context.pyt   <module>   sD   $	ÿ •	