ó
^B^c           @   s\  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m	 Z	 m
 Z
 m Z m Z m Z m Z m Z d Z e Z d Z d e j f d „  ƒ  YZ d „  Z e e e d	 „ ƒ Z e d
 „  ƒ Z e d d d „ ƒ Z e g  d „ ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z d S(   s$  
Configuration system

A :py:class:`waflib.Configure.ConfigurationContext` instance is created when ``waf configure`` is called, it is used to:

* create data dictionaries (ConfigSet instances)
* store the list of modules to import
* hold configuration routines such as ``find_program``, etc
iÿÿÿÿN(   t	   ConfigSett   Utilst   Optionst   Logst   Contextt   Buildt   Errorss
   config.logs}   # project %(app)s configured on %(now)s by
# waf %(wafver)s (abi %(abi)s, python %(pyver)x on %(systype)s)
# using %(args)s
#t   ConfigurationContextc           B   s›   e  Z d  Z d Z g  Z d „  Z d d „ Z d „  Z d „  Z	 e
 e e	 ƒ Z d „  Z d „  Z d „  Z d	 „  Z d d e e d
 „ Z d „  Z d „  Z RS(   s   configures the projectt	   configurec         K   sx   t  t |  ƒ j | �  t t j ƒ |  _ i  |  _ d  |  _ d  |  _	 g  |  _
 d |  _ g  |  _ g  |  _ |  j d ƒ d  S(   Ni    t    (   t   superR   t   __init__t   dictt   ost   environt   all_envst   Nonet   top_dirt   out_dirt   toolst   hasht   filest
   tool_cachet   setenv(   t   selft   kw(    (    s!   /wcdo/src/waf/waflib/Configure.pyR   '   s    							c         C   s`   | |  j  k s | rS | s7 t j ƒ  } |  j | ƒ n | j ƒ  } | |  j  | <n  | |  _ d S(   s–  
		Set a new config set for conf.env. If a config set of that name already exists,
		recall it without modification.

		The name is the filename prefix to save to ``c4che/NAME_cache.py``, and it
		is also used as *variants* by the build commands.
		Though related to variants, whatever kind of data may be stored in the config set::

			def configure(cfg):
				cfg.env.ONE = 1
				cfg.setenv('foo')
				cfg.env.ONE = 2

			def build(bld):
				2 == bld.env_of_name('foo').ONE

		:param name: name of the configuration set
		:type name: string
		:param env: ConfigSet to copy, or an empty ConfigSet is created
		:type env: :py:class:`waflib.ConfigSet.ConfigSet`
		N(   R   R    t   prepare_envt   derivet   variant(   R   t   namet   env(    (    s!   /wcdo/src/waf/waflib/Configure.pyR   8   s    c         C   s   |  j  |  j S(   s   Getter for the env property(   R   R   (   R   (    (    s!   /wcdo/src/waf/waflib/Configure.pyt   get_envW   s    c         C   s   | |  j  |  j <d S(   s   Setter for the env propertyN(   R   R   (   R   t   val(    (    s!   /wcdo/src/waf/waflib/Configure.pyt   set_envZ   s    c         C   s£  |  j  } | s t j j } n  | s? t t j t j d ƒ } n  | sW |  j	 j
 ƒ  } n  t j	 j
 | ƒ } t j	 j | ƒ r„ |  j pŠ |  j	 j | ƒ |  _ |  j s¨ t ‚ |  j } | sÆ t j j } n  | sç t t j t j d ƒ } n  | st j j d t j d ƒ j d d ƒ } n  t j	 j | ƒ } t j	 j | ƒ rE|  j pK|  j	 j | ƒ |  _ |  j j ƒ  t j	 j |  j j
 ƒ  ƒ sŸ|  j d |  j j
 ƒ  ƒ n  d S(   s>   
		Initialize the project directory and the build directory
		s   .lock-waf_%s_R	   s	   .lock-wafs'   Could not create the build directory %sN(   R   R   t   optionst   topt   getattrR   t   g_modulet   TOPR   t   patht   abspathR   t   isabst   roott   find_dirt   srcnodet   AssertionErrorR   t   outt   OUTt   lockfilet   replacet   syst   platformt   realpatht	   make_nodet   bldnodet   mkdirt   isdirt   fatal(   R   R#   R.   (    (    s!   /wcdo/src/waf/waflib/Configure.pyt	   init_dirs`   s,    	0	+0c         C   s‹  |  j  ƒ  |  j j t j ƒ |  _ |  j j ƒ  t j j	 |  j j
 ƒ  t ƒ } t j | d ƒ |  _ t t j d d ƒ } | r® t t j d d ƒ } | r® d | | f } q® n  i t j ƒ  d 6t j d 6t j d 6d	 j	 t j ƒ d
 6t j d 6t j d 6| d 6} |  j t | ƒ |  j d |  j j
 ƒ  ƒ |  j d |  j j
 ƒ  ƒ t |  j ƒ t |  j ƒ k rtt j d ƒ nF t |  j ƒ t |  j ƒ k rº|  j j  |  j ƒ rºt j d ƒ qºn  t! t" |  ƒ j# ƒ  |  j$ ƒ  |  j j
 ƒ  t _% |  j j
 ƒ  t _& t' j' ƒ  } t j | _ t( j) j* | _) |  j+ | _, t j- | _- t j% | _% t j& | _& |  j. | _. |  j/ | _/ t0 |  j1 ƒ | _1 t j2 | _2 |  j3 j4 pµ| j1 j5 d ƒ pµt t( j) d ƒ sÝ| j$ t j j	 t j- t( j6 ƒ ƒ n  |  j3 j7 p
| j1 j5 d ƒ p
t t( j) d ƒ s2| j$ t j j	 t j% t( j6 ƒ ƒ n  |  j3 j8 p_| j1 j5 d ƒ p_t t( j) d ƒ s‡| j$ t j j	 t j& t( j6 ƒ ƒ n  d S(   s3   
		See :py:func:`waflib.Context.Context.execute`
		t   cfgt   APPNAMER	   t   VERSIONs   %s (%s)t   nowt   pyvert   systypet    t   argst   wafvert   abit   apps   Setting top tos   Setting out tos   Setting top == outs5   Are you certain that you do not want to set top="." ?t   NO_LOCK_IN_RUNt   no_lock_in_runt   NO_LOCK_IN_TOPt   no_lock_in_topt   NO_LOCK_IN_OUTt   no_lock_in_outN(9   R:   R6   R5   R   t	   CACHE_DIRt   cachedirR7   R   R'   t   joinR(   t   WAF_CONFIG_LOGR   t   make_loggert   loggerR$   R   R%   t   timet   ctimeR2   t
   hexversionR3   t   argvt
   WAFVERSIONt   ABIt   to_logt   conf_templatet   msgR,   t   idt   warnt   is_child_ofR
   R   t   executet   storeR   R   R    R   R"   t   __dict__t   cmdt
   config_cmdt   run_dirR   R   R   R   t
   launch_dirR   RF   t   getR0   RH   RJ   (   R   R'   RE   t   vert   paramsR   (    (    s!   /wcdo/src/waf/waflib/Configure.pyR^   ‚   sP    
U
0%0%0c         C   sÈ   | j  s< t j j s t j r0 t j j | _  q< d | _  n  | j s{ t j j rc t j j | _ q{ t j d | ƒ | _ n  | j	 sÄ t j j
 r¢ t j j
 | _	 qÄ t j d t j ƒ  | ƒ | _	 n  d S(   s¥   
		Insert *PREFIX*, *BINDIR* and *LIBDIR* values into ``env``

		:type env: :py:class:`waflib.ConfigSet.ConfigSet`
		:param env: a ConfigSet, usually ``conf.env``
		t   /s   ${PREFIX}/bins   ${PREFIX}/lib%sN(   t   PREFIXR   R"   t   prefixR   t   is_win32t   BINDIRt   bindirt
   subst_varst   LIBDIRt   libdirt   lib64(   R   R   (    (    s!   /wcdo/src/waf/waflib/Configure.pyR   À   s    			c         C   s™   |  j  j d ƒ } | j d t j |  j f ƒ |  j sH |  j d ƒ n  xJ |  j D]? } |  j | } | j t	 j
 j |  j  j ƒ  | t j ƒ ƒ qR Wd S(   s+   Save the config results into the cache files   build.config.pys   version = 0x%x
tools = %r
s.   nothing to store in the configuration context!N(   RM   R5   t   writeR   t
   HEXVERSIONR   R   R9   R_   R   R'   RN   R(   R   t   CACHE_SUFFIX(   R   t   nt   keyt   tmpenv(    (    s!   /wcdo/src/waf/waflib/Configure.pyR_   ×   s    	c         C   sÐ  t  j | ƒ } | r' t  j | ƒ } n  x¢| D]š} | rŽ | t |  j ƒ | | f } | |  j k r{ |  j d | ƒ q. n  |  j j | ƒ n  d }	 y" t j	 | | d |  d | ƒ}	 Wn~ t
 k
 rô }
 |  j d | t |
 d t j ƒ |
 f ƒ nC t k
 r6}
 |  j d | | | f ƒ |  j t j ƒ  ƒ ‚  n X| d k	 rS|  j | ƒ nP t |	 d d ƒ } | r£t | ƒ t t  j ƒ k r“| |  ƒ q£|  j | ƒ n  |  j j i | d 6| d	 6| d
 6ƒ q. Wd S(   sƒ  
		Load Waf tools, which will be imported whenever a build is started.

		:param tool_list: waf tools to import
		:type tool_list: list of string
		:param tooldir: paths for the imports
		:type tooldir: list of string
		:param funs: functions to execute from the waf tools
		:type funs: list of string
		:param cache: whether to prevent the tool from running twice
		:type cache: bool
		s%   (tool %s is already loaded, skipping)t   ctxt   with_sys_paths)   Could not load the Waf tool %r from %r
%st   waf_sys_paths   imp %r (%r & %r)R   t   toolt   tooldirt   funsN(   R   t   to_listR[   R   R   RX   t   appendR   R   t	   load_toolt   ImportErrorR9   R$   R2   R'   t	   Exceptiont	   tracebackt
   format_exct
   eval_rulest   typet   readfR   (   R   t	   tool_listR|   R}   Ry   t   cacheR   R{   t   magt   modulet   et   func(    (    s!   /wcdo/src/waf/waflib/Configure.pyt   loadã   s6    ",c         C   sT   t  t |  ƒ j | ƒ t j |  j | j d ƒ f ƒ |  _ |  j j | j	 ƒ  ƒ d S(   s®   
		Records the path and a hash of the scripts visited, see :py:meth:`waflib.Context.Context.post_recurse`

		:param node: script
		:type node: :py:class:`waflib.Node.Node`
		t   rbN(
   R
   R   t   post_recurseR   t   h_listR   t   readR   R   R(   (   R   t   node(    (    s!   /wcdo/src/waf/waflib/Configure.pyR�     s    $c         C   sZ   t  j | ƒ |  _ xA |  j D]6 } t |  | ƒ } | sK |  j d | ƒ n  | ƒ  q Wd S(   s˜   
		Execute configuration tests provided as list of functions to run

		:param rules: list of configuration method names
		:type rules: list of string
		s!   No such configuration function %rN(   R   R~   t   rulesR$   R9   (   R   R”   t   xt   f(    (    s!   /wcdo/src/waf/waflib/Configure.pyR…      s    N(   t   __name__t
   __module__t   __doc__Ra   t   error_handlersR   R   R   R   R!   t   propertyR   R:   R^   R   R_   t   Truet   FalseRŽ   R�   R…   (    (    (    s!   /wcdo/src/waf/waflib/Configure.pyR      s   				"	>		2	c            sH   ‡  f d †  } ˆ  j  | _  t t ˆ  j  | ƒ t t j ˆ  j  | ƒ ˆ  S(   sh  
	Decorator: attach new configuration functions to :py:class:`waflib.Build.BuildContext` and
	:py:class:`waflib.Configure.ConfigurationContext`. The methods bound will accept a parameter
	named 'mandatory' to disable the configuration errors::

		def configure(conf):
			conf.find_program('abc', mandatory=False)

	:param f: method to bind
	:type f: function
	c             sJ   | j  d t ƒ } y ˆ  |  | Ž  SWn  t j k
 rE | rF ‚  qF n Xd  S(   Nt	   mandatory(   t   popRœ   R   t   ConfigurationError(   t   kR   Rž   (   R–   (    s!   /wcdo/src/waf/waflib/Configure.pyt   fun:  s    (   R—   t   setattrR   R   t   BuildContext(   R–   R¢   (    (   R–   s!   /wcdo/src/waf/waflib/Configure.pyt   conf.  s
    c         C   s‰   y t  j |  j | ƒ } Wn t k
 r. d SX| si d j | ƒ d j t j |  j | p\ | ƒ ƒ k r… |  j j | p{ | | ƒ n  d S(   s@  
	Import operating system environment values into ``conf.env`` dict::

		def configure(conf):
			conf.add_os_flags('CFLAGS')

	:param var: variable to use
	:type var: string
	:param dest: destination variable, by default the same as var
	:type dest: string
	:param dup: add the same set of flags again
	:type dup: bool
	NR	   (	   t   shlext   splitR   t   KeyErrorRN   R   R~   R   t   append_value(   R   t   vart   destt   dupt   flags(    (    s!   /wcdo/src/waf/waflib/Configure.pyt   add_os_flagsG  s    :c         C   s€   t  | t ƒ r| t j j | ƒ r( | g St j d k rD t j | ƒ Sy t j | d t ƒSWq| t	 k
 rx t j | ƒ SXn  | S(   s˜   
	Detect if a command is written in pseudo shell like ``ccache g++`` and return a list.

	:param cmd: command
	:type cmd: a string or a list of string
	Rh   t   posix(
   t
   isinstancet   strR   R'   t   isfilet   sepR¦   R§   R�   t	   TypeError(   R   Ra   (    (    s!   /wcdo/src/waf/waflib/Configure.pyt   cmd_to_list]  s    s   1.9.99s   2.1.0c         K   s³   |  j  d t | ƒ t | ƒ f | � t j } t j | ƒ | k rg |  j d t j | ƒ | f ƒ n  t j | ƒ | k  rŸ |  j d t j | ƒ | f ƒ n  |  j d | � d S(   s.  
	Raise a Configuration error if the Waf version does not strictly match the given bounds::

		conf.check_waf_version(mini='1.9.99', maxi='2.1.0')

	:type  mini: number, tuple or string
	:param mini: Minimum required version
	:type  maxi: number, tuple or string
	:param maxi: Maximum allowed version
	s!   Checking for waf version in %s-%ss,   waf version should be at least %r (%r found)s+   waf version should be at most %r (%r found)t   okN(   t	   start_msgR±   R   Rs   R   t   num2verR9   t   end_msg(   R   t   minit   maxiR   Rf   (    (    s!   /wcdo/src/waf/waflib/Configure.pyt   check_waf_versions  s    &	##c         C   s€   xh t  j | ƒ D]W } xN t  j | ƒ D]= } t j j t j j | | ƒ ƒ } t j j | ƒ r& | Sq& Wq W|  j d | ƒ d S(   sÕ   
	Find a file in a list of paths

	:param filename: name of the file to search for
	:param path_list: list of directories to search
	:return: the first matching filename; else a configuration exception is raised
	s   Could not find %rN(   R   R~   R   R'   t
   expanduserRN   t   existsR9   (   R   t   filenamet	   path_listRu   t   dt   p(    (    s!   /wcdo/src/waf/waflib/Configure.pyt	   find_file‡  s    	!c         K   s
  | j  d t j r d p d ƒ } | j  d t |  d t j ƒ ƒ } d } t j | ƒ } | j  d d j | ƒ ƒ } | j  d d ƒ } | s¬ t j	 d	 d
 | d j
 ƒ  ƒ } n  | j  d d ƒ } | rÖ t j | ƒ } n | j  d d ƒ j t j ƒ } | j  d ƒ r|  j | d ƒ } n× | j  | ƒ r>|  j | | ƒ } n² |  j | rd|  j |  j | ƒ } nŒ | s‹|  j | | j d ƒ | ƒ } n  | r¶t j r¶t j t j j | ƒ } n  | rát j rát j t j j | ƒ } n  |  j | ƒ } | rt | ƒ d k r| d }	 q$| }	 n t }	 |  j d | |	 | � | j  d ƒ sj|  j d | | | | f ƒ n  | s–|  j | j  d d ƒ p�d | ƒ n  | j  d ƒ }
 |
 d k rît j | d d | ƒsÞ|  j d | ƒ n  | |  j | <n |  j |
 | |  j | <| S(   s…  
	Search for a program on the operating system

	When var is used, you may set os.environ[var] to help find a specific program version, for example::

		$ CC='ccache gcc' waf configure

	:param path_list: paths to use for searching
	:type param_list: list of string
	:param var: store the result to conf.env[var] where var defaults to filename.upper() if not provided; the result is stored as a list of strings
	:type var: string
	:param value: obtain the program from the value passed exclusively
	:type value: list or string (list is preferred)
	:param exts: list of extensions for the binary (do not add an extension for portability)
	:type exts: list of string
	:param msg: name to display in the log, by default filename is used
	:type msg: string
	:param interpreter: interpreter for the program
	:type interpreter: ConfigSet variable key
	:raises: :py:class:`waflib.Errors.ConfigurationError`
	t   extss   .exe,.com,.bat,.cmds   ,.sh,.pl,.pyR   R	   RZ   s   , Rª   s   [-.]t   _i    RÀ   t   PATHt   valuet   ,i   s   Checking for program %rt   quiets%   find program=%r paths=%r var=%r -> %rt   errmsgs   Could not find the program %rt   interpreterR   s   Program %r is not executableN(   Re   R   Rk   R$   R   R   R~   RN   t   ret   subt   upperR§   t   pathsepRµ   R   t   find_binaryt   winregt   get_registry_app_patht   HKEY_CURRENT_USERt   HKEY_LOCAL_MACHINEt   lenR�   RZ   RX   R9   R   t	   check_exe(   R   R¿   R   RÄ   R   t   retRZ   Rª   RÀ   t   retmsgRË   (    (    s!   /wcdo/src/waf/waflib/Configure.pyt   find_program—  sT    !!"!	 &c   	      C   s£   xœ | D]” } x‹ | D]ƒ } | | } t  j j | ƒ rO t  j j | ƒ r— | Sq xE | D]= } t  j j t  j j | | ƒ ƒ } t  j j | ƒ rV | SqV Wq Wq Wd  S(   N(   R   R'   R)   R²   R½   RN   R   (	   R   t	   filenamesRÄ   t   pathsR–   t   extt   exe_nameR'   R•   (    (    s!   /wcdo/src/waf/waflib/Configure.pyRÐ   í  s    
!c         O   s€  g  } xw t  | j ƒ  ƒ D]c } | | } t | t j ƒ rA q q t | d ƒ ri | j t j | ƒ ƒ q | j t | ƒ ƒ q Wt j	 | ƒ } |  j
 j ƒ  t j t j r² d pµ d d t j | ƒ } | j d t t j d d ƒ ƒ } | rt j j | ƒ rt j | ƒ n  y t j | ƒ Wn t k
 r8n Xy t j | ƒ Wn" t k
 rn|  j d | ƒ n X| d k rðy" t j t j j | d ƒ ƒ }	 Wn t k
 r°qðX|	 d }
 t |
 t ƒ ré|
 j d	 ƒ ré|  j |
 ƒ n  |
 Sn  t j j | d
 ƒ } t j j | ƒ s't j | ƒ n  | j d ƒ pEt |  d d ƒ } t  j! | d | d | ƒ|  _" } | j# ƒ  d | _$ d | _% |  j& | _& | j' j( |  j' ƒ | d | _) | | _* |  | _+ | d | ƒ d }
 zX y | j, ƒ  Wn1 t- j. k
 rd t/ j0 ƒ  }
 |  j |
 ƒ n Xt | d d ƒ }
 Wd | rnt j ƒ  }	 |
 |	 d <|	 j1 t j j | d ƒ ƒ n t j | ƒ X|
 S(   sq  
	Create a temporary build context to execute a build. A temporary reference to that build
	context is kept on self.test_bld for debugging purposes.
	The arguments to this function are passed to a single task generator for that build.
	Only three parameters are mandatory:

	:param features: features to pass to a task generator created in the build
	:type features: list of string
	:param compile_filename: file to create for the compilation (default: *test.c*)
	:type compile_filename: string
	:param code: input file contents
	:type code: string

	Though this function returns *0* by default, the build may bind attribute named *retval* on the
	build context object to return a particular value. See :py:func:`waflib.Tools.c_config.test_exec_fun` for example.

	The temporary builds creates a temporary folder; the name of that folder is calculated
	by hashing input arguments to this function, with the exception of :py:class:`waflib.ConfigSet.ConfigSet`
	objects which are used for both reading and writing values.

	This function also features a cache which is disabled by default; that cache relies
	on the hash value calculated as indicated above::

		def options(opt):
			opt.add_option('--confcache', dest='confcache', default=0,
				action='count', help='Use a configuration cache')

	And execute the configuration with the following command-line::

		$ waf configure --confcache

	t   __call__t   .R	   t   conf_check_t	   confcaches+   cannot use the configuration test folder %ri   t   cache_run_builds   Test does not buildt	   testbuildt   run_build_clst   buildR   R   i    t   *R   t	   build_funiÿÿÿÿs   Test does not build: %st   retvalN(2   t   sortedt   keysR°   R    t   hasattrR   R   t   h_funR±   R‘   R6   R(   R   R³   Rk   t   to_hexRe   R$   R   R"   R   R'   R¾   t   shutilt   rmtreet   makedirst   OSErrort   statR9   RN   t   EnvironmentErrort
   startswithR   t   create_contextt   test_bldR:   t   progress_bart   targetsRQ   R   t   updateR   R   R¥   t   compileR   t   WafErrorRƒ   R„   R_   (   R   R¡   R   t   bufRv   t   vt   ht   dirt	   cachemodet   projR×   t   bdirt   cls_namet   bld(    (    s!   /wcdo/src/waf/waflib/Configure.pyt	   run_buildü  st    "
;!"
!"
				
c         C   s   t  | t ƒ r | S| | ƒ S(   N(   R°   R±   (   R   RZ   RB   (    (    s!   /wcdo/src/waf/waflib/Configure.pyt   ret_msgj  s    c         O   sF  d | k r" |  j  j ƒ  | d <n  | j d ƒ rB | d | ƒ n  |  j | d | � d  } y |  j | | Ž  } WnP |  j j k
 rÄ |  j | d d | � t	 j
 d k r´ ‚  qÏ |  j d ƒ n X| | d <| j d	 ƒ rñ | d	 | ƒ } n  | r"|  j | d d | � |  j d
 | ƒ n  |  j |  j | d | ƒ | � | S(   NR   t   validateRZ   RÊ   t   YELLOWi   s   The configuration failedt   successt
   post_checks   The configuration failed %rt   okmsg(   R   R   Re   R·   R   R  t   errorsR    R¹   R   t   verboseR9   R  (   R   R¡   R   R×   (    (    s!   /wcdo/src/waf/waflib/Configure.pyt   testp  s*    
 (    R™   R   RÌ   R¦   Rî   R2   RR   Rƒ   t   waflibR    R   R   R   R   R   R   RO   R�   t
   autoconfigRY   R   R¥   R   R®   Rµ   R¼   RÃ   RÙ   RÐ   R  R  R  (    (    (    s!   /wcdo/src/waf/waflib/Configure.pyt   <module>   s(   T4ÿ 	Vn