ó
óÏù]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&   /git_repos/ams-lv2/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&   /git_repos/ams-lv2/waflib/Configure.pyR   8   s    c         C   s   |  j  |  j S(   s   Getter for the env property(   R   R   (   R   (    (    s&   /git_repos/ams-lv2/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&   /git_repos/ams-lv2/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Ÿt 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   conft   fatal(   R   R#   R.   (    (    s&   /git_repos/ams-lv2/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 |  j2 j3 p©| j1 j4 d ƒ p©t t( j) d ƒ sÑ| j$ t j j	 t j- t( j5 ƒ ƒ n  |  j2 j6 pþ| j1 j4 d ƒ pþt t( j) d ƒ s&| j$ t j j	 t j% t( j5 ƒ ƒ n  |  j2 j7 pS| j1 j4 d ƒ pSt t( j) d ƒ s{| j$ t j j	 t j& t( j5 ƒ ƒ 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(8   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   R   RG   t   getR0   RI   RK   (   R   R'   RF   t   vert   paramsR   (    (    s&   /git_repos/ams-lv2/waflib/Configure.pyR_   ‚   sN    
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&   /git_repos/ams-lv2/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(   RN   R5   t   writeR   t
   HEXVERSIONR   R   R:   R`   R   R'   RO   R(   R   t   CACHE_SUFFIX(   R   t   nt   keyt   tmpenv(    (    s&   /git_repos/ams-lv2/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   RY   t   appendR   R   t	   load_toolt   ImportErrorR:   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&   /git_repos/ams-lv2/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&   /git_repos/ams-lv2/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$   R:   (   R   R”   t   xt   f(    (    s&   /git_repos/ams-lv2/waflib/Configure.pyR…     s    N(   t   __name__t
   __module__t   __doc__Rb   t   error_handlersR   R   R   R   R!   t   propertyR   R;   R_   R   R`   t   Truet   FalseRŽ   R�   R…   (    (    (    s&   /git_repos/ams-lv2/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&   /git_repos/ams-lv2/waflib/Configure.pyt   fun9  s    (   R—   t   setattrR   R   t   BuildContext(   R–   R¢   (    (   R–   s&   /git_repos/ams-lv2/waflib/Configure.pyR9   -  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   KeyErrorRO   R   R~   R   t   append_value(   R   t   vart   destt   dupt   flags(    (    s&   /git_repos/ams-lv2/waflib/Configure.pyt   add_os_flagsF  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   Rb   (    (    s&   /git_repos/ams-lv2/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   num2verR:   t   end_msg(   R   t   minit   maxiR   Rf   (    (    s&   /git_repos/ams-lv2/waflib/Configure.pyt   check_waf_versionr  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
   expanduserRO   t   existsR:   (   R   t   filenamet	   path_listRu   t   dt   p(    (    s&   /git_repos/ams-lv2/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	   R[   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~   RO   t   ret   subt   upperR¦   t   pathsepR´   R   t   find_binaryt   winregt   get_registry_app_patht   HKEY_CURRENT_USERt   HKEY_LOCAL_MACHINEt   lenR�   R[   RY   R:   R   t	   check_exe(   R   R¾   R   RÃ   R   t   retR[   R©   R¿   t   retmsgRÊ   (    (    s&   /git_repos/ams-lv2/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¼   RO   R   (	   R   t	   filenamesRÃ   t   pathsR–   t   extt   exe_nameR'   R•   (    (    s&   /git_repos/ams-lv2/waflib/Configure.pyRÏ   ì  s    
!c         O   s  g  | j  ƒ  D]$ \ } } | d k r t | ƒ ^ q } t j | ƒ } |  j j ƒ  t j t j ri d pl d d t j	 | ƒ } y t j
 | ƒ Wn t k
 r¥ n Xy t j | ƒ Wn" t k
 rÛ |  j d | ƒ n Xt t j d d ƒ } | d k rry" t j t j j | d ƒ ƒ }	 Wn t k
 r2qrX|	 d }
 t |
 t ƒ rk|
 j d	 ƒ rk|  j |
 ƒ n  |
 Sn  t j j | d
 ƒ } t j j | ƒ s©t j
 | ƒ n  | j d ƒ pÇ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) j* ƒ  }
 |  j |
 ƒ n Xt | d d ƒ }
 Wd | d k röt j ƒ  }	 |
 |	 d <|	 j+ t j j | d ƒ ƒ n t, j- | ƒ X|
 S(   sÆ  
	Create a temporary build context to execute a build. A reference to that build
	context is kept on self.test_bld for debugging purposes, and you should not rely
	on it too much (read the note on the cache below).
	The parameters given in the arguments to this function are passed as arguments for
	a single task generator created in the build. Only three parameters are obligatory:

	: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: code to write in the filename to compile
	:type code: string

	Though this function returns *0* by default, the build may set an 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.

	This function also provides a limited cache. To use it, provide the following option::

		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

	R   t   .R	   t   conf_check_s+   cannot use the configuration test folder %rt	   confcachei   t   cache_run_builds   Test does not buildt	   testbuildt   run_build_clst   buildR   R   i    t   *t	   build_funiÿÿÿÿs   Test does not build: %st   retvalN(.   t   itemsR°   R   R‘   R6   R(   R   R²   Rk   t   to_hext   makedirst   OSErrort   statR:   R$   R   R"   R   R    R'   RO   t   EnvironmentErrorR¯   t
   startswithR½   Re   R   t   create_contextt   test_bldR;   t   progress_bart   targetsRR   R   t   updateR   R   R9   t   compileR   t   WafErrorRƒ   R„   R`   t   shutilt   rmtree(   R   R¡   R   RÁ   t   vt   lstt   ht   dirt	   cachemodet   projRÖ   t   bdirt   cls_namet   bld(    (    s&   /git_repos/ams-lv2/waflib/Configure.pyt	   run_buildû  sb    7;"
!"
				
c         C   s   t  | t ƒ r | S| | ƒ S(   N(   R¯   R°   (   R   R[   RC   (    (    s&   /git_repos/ams-lv2/waflib/Configure.pyt   ret_msgX  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   validateR[   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   verboseR:   R  (   R   R¡   R   RÖ   (    (    s&   /git_repos/ams-lv2/waflib/Configure.pyt   test^  s*    
 (    R™   R   RË   R¥   Rõ   R2   RS   Rƒ   t   waflibR    R   R   R   R   R   R   RP   R�   t
   autoconfigRZ   R   R9   R   R­   R´   R»   RÂ   RØ   RÏ   R   R  R	  (    (    (    s&   /git_repos/ams-lv2/waflib/Configure.pyt   <module>   s(   T4ÿ 	V]