ó
óÏù]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 m Z m Z m	 Z	 m
 Z
 e j ƒ  Z g  Z g  Z e j j d d e j ƒ Z d e j f d „  ƒ  YZ d e	 j	 f d	 „  ƒ  YZ d S(
   s“   
Support for waf command-line options

Provides default and command-line options, as well the command
that reads the ``options`` wscript function.
iÿÿÿÿN(   t   Logst   Utilst   Contextt   Errorst   WAFLOCKs   .lock-waf_%s_buildt
   opt_parserc           B   s8   e  Z d  Z e d „ Z d „  Z d d „ Z d „  Z RS(   s    
	Command-line options parser.
	c      
   C   sZ   t  j j |  d d d t d d t j t j f ƒt j ƒ  |  j	 _
 | |  _ | |  _ d  S(   Nt   conflict_handlert   resolvet   add_help_optiont   versions   waf %s (%s)(   t   optparset   OptionParsert   __init__t   FalseR   t
   WAFVERSIONt   WAFREVISIONR    t   get_term_colst	   formattert   widtht   ctxt   allow_unknown(   t   selfR   R   (    (    s$   /git_repos/ams-lv2/waflib/Options.pyR   -   s
    	c         C   s   xx | rz y t  j j |  | | | ƒ Wq t  j t  j f k
 rv } |  j r` | j | j ƒ qw |  j t	 | ƒ ƒ q Xq Wd S(   sY   
		Custom _process_args to allow unknown options according to the allow_unknown status
		N(
   R
   R   t   _process_argst   BadOptionErrort   AmbiguousOptionErrorR   t   appendt   opt_strt   errort   str(   R   t   largst   rargst   valuest   e(    (    s$   /git_repos/ams-lv2/waflib/Options.pyR   4   s    		c         C   s   |  j  | ƒ S(   N(   t
   print_help(   R   t   file(    (    s$   /git_repos/ams-lv2/waflib/Options.pyt   print_usageA   s    c   	      C   st  i  } x^ t  j D]S } | j s | j d k s | j j d ƒ rG q n  | j pS d } | | | j <q Wt  j rï x| t  j j j ƒ  D]e \ } } | d
 k r¡ qƒ n  t | ƒ t t  j	 ƒ k rƒ | j rè | j d ƒ rè | j | | <qè qƒ qƒ Wn  d } x# | D] } t
 | t | ƒ ƒ } qü Wg  | j ƒ  D]% \ } } d | j | ƒ | f ^ q(} | j ƒ  d j | ƒ } d	 | S(   sE   
		Builds the message to print on ``waf --help``

		:rtype: string
		t   optionst   _t    t   initt   shutdowni    s     %s: %ss   
sF   waf [commands] [options]

Main commands (example: ./waf build -j4)
%s
(   R$   R'   R(   (   R   t   classest   cmdt
   startswitht   __doc__t   g_modulet   __dict__t   itemst   typet   create_contextt   maxt   lent   ljustt   sortt   join(	   R   t   cmds_strt   clst   st   kt   vt   justt   lstt   ret(    (    s$   /git_repos/ams-lv2/waflib/Options.pyt	   get_usageD   s(    +	8
N(	   t   __name__t
   __module__R,   R   R   R   t   NoneR#   R?   (    (    (    s$   /git_repos/ams-lv2/waflib/Options.pyR   )   s
   	t   OptionsContextc           B   sŒ   e  Z d  Z d Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d d „ Z d d e d „ Z d	 „  Z d
 „  Z d d „ Z d „  Z RS(   s¯   
	Collects custom options from wscript files and parses the command line.
	Sets the global :py:const:`waflib.Options.commands` and :py:const:`waflib.Options.options` values.
	R$   c   	      K   sÌ  t  t |  ƒ j | �  t |  ƒ |  _ i  |  _ |  j ƒ  } |  j } t j	 j
 d d ƒ r^ d pa d } t j	 j
 d d ƒ d k rˆ d } n$ t j	 j
 d d ƒ d k r¬ d	 } n  | d
 d d d d | d d d d d dh ƒ| d d d d d | d d d d | ƒ| d d d d d d d d d d ƒ| d  d! d d" d d d d d d# ƒ| d$ d d% d d d d d d& ƒ| d' d d( d d d d) d t j ƒ| d* d d+ d d d d) d t j ƒ| d, d- d d. d d d d) d d/ ƒ|  j d0 ƒ } | |  j d1 <| j d2 d3 d d d d d d4 d d5 ƒ| j d6 d7 d d d d d d8 d d9 ƒ| j d: d d) d d d t j d d; ƒ| j d< d d) d d d t j d d= ƒ| j d> d d) d d d t j d d? ƒt t j d@ t j	 j
 dA ƒ ƒ } | s(t j ƒ  dB k rt j ƒ  } | d j ƒ  | dC } q(dD } n  | j dE d dF d | d dG | ƒ| j dH d dI d dI ƒ| j dJ d dK d dK ƒ|  j dL ƒ } | |  j dM <| j dN dO d dP d d d d d dQ ƒ| j dR d dS d d d d d dT ƒ|  j dU ƒ } | |  j dV <| j dW d dX d d d d d dY ƒt j	 j
 dZ d ƒ } |  j d[ ƒ } | |  j d\ <| j d] d d^ | d | d d_ ƒ| j d` da d db d t d d) d dc ƒ| j dd de df d dg d d  d d ƒd  S(i   Nt   NOCOLORR&   t   not   autot   CLICOLORt   0t   CLICOLOR_FORCEt   1t   yess   -cs   --colort   destt   colorst   defaultt   actiont   storet   helps3   whether to use colors (yes/no/auto) [default: auto]t   choicess   -js   --jobst   jobsR0   t   ints   amount of parallel jobs (%r)s   -ks   --keept   keepi    t   counts+   continue despite errors (-kk to try harder)s   -vs	   --verboset   verboses+   verbosity level -v -vv or -vvv [default: 0]s   --zonest   zoness,   debugging zones (task_gen, deps, tasks, etc)s	   --profilet   profilet
   store_trues   --pdbt   pdbs   -hs   --helpt   whelps   show this help message and exits   Configuration optionss   configure optionss   -os   --outs   build dir for the projectt   outs   -ts   --tops   src dir for the projectt   tops   --no-lock-in-runt   no_lock_in_runs   --no-lock-in-outt   no_lock_in_outs   --no-lock-in-topt   no_lock_in_topt   default_prefixt   PREFIXt   win32i   s   /usr/local/s   --prefixt   prefixs!   installation prefix [default: %r]s   --bindirt   bindirs   --libdirt   libdirs   Build and installation optionss   build and install optionss   -ps
   --progresst   progress_bars!   -p: progress bar; -pp: ide outputs	   --targetst   targetss'   task generators, e.g. "target1,target2"s   Step optionss   step optionss   --filest   filess:   files to process, by regexp, e.g. "*/main.c,*/test/main.o"t   DESTDIRs'   Installation and uninstallation optionss   install/uninstall optionss	   --destdirs   installation root [default: %r]t   destdirs   -fs   --forcet   forces   force file installations   --distcheck-argst   metavart   ARGSs   arguments to pass to distcheck(   RK   RE   RF   (   t   superRC   R   R   t   parsert   option_groupsRS   t
   add_optiont   ost   environt   getR
   t   SUPPRESS_HELPt   add_option_groupt   getattrR   R-   R   t   unversioned_sys_platformt   tempfilet
   gettempdirt   upperR   RB   (	   R   t   kwRS   t   pt   colort   grRb   t   dt   default_destdir(    (    s$   /git_repos/ams-lv2/waflib/Options.pyR   r   s^    		!		+)%%"%%%(((((!	#(%%#(c         C   sX  t  t j j d d ƒ ƒ } | d k  r*d t j k rT t  t j j d d ƒ ƒ } q*t t d ƒ r´ d t j k rŠ t  t j d ƒ ƒ } q´ d t j k r´ t  t j d ƒ ƒ } q´ n  | r*t j d k r*y" |  j d
 d d g d d ƒ} Wn t	 j
 k
 rq'Xt j d | ƒ r't  | ƒ } q'q*n  | d k  r?d } n | d k rTd } n  | S(   s
  
		Finds the optimal amount of cpu cores to use for parallel jobs.
		At runtime the options can be obtained from :py:const:`waflib.Options.options` ::

			from waflib.Options import options
			njobs = options.jobs

		:return: the amount of cpu cores
		:rtype: int
		t   JOBSi    i   t   NUMBER_OF_PROCESSORSt   sysconf_namest   SC_NPROCESSORS_ONLNt   SC_NPROCESSORS_CONFt   ntt   javat   sysctls   -ns   hw.ncput   quiets   ^[0-9]+$i   (   R‰   RŠ   (   RT   Rt   Ru   Rv   t   hasattrR†   t   sysconft   namet   cmd_and_logR   t   WafErrort   ret   match(   R   RV   t   tmp(    (    s$   /git_repos/ams-lv2/waflib/Options.pyRS   ±   s*    "		c         O   s   |  j  j | | Ž  S(   sÍ   
		Wraps ``optparse.add_option``::

			def options(ctx):
				ctx.add_option('-u', '--use', dest='use', default=False,
					action='store_true', help='a boolean option')

		:rtype: optparse option object
		(   Rq   Rs   (   R   R:   R~   (    (    s$   /git_repos/ams-lv2/waflib/Options.pyRs   Ö   s    
c         O   sS   y |  j  | d } Wn& t k
 r= |  j j | | Ž  } n X| |  j  | d <| S(   sè   
		Wraps ``optparse.add_option_group``::

			def options(ctx):
				gr = ctx.add_option_group('some options')
				gr.add_option('-u', '--use', dest='use', default=False, action='store_true')

		:rtype: optparse option group object
		i    (   Rr   t   KeyErrorRq   Rx   (   R   R:   R~   R�   (    (    s$   /git_repos/ams-lv2/waflib/Options.pyRx   â   s    
c         C   sR   y |  j  | SWn< t k
 rM x' |  j j  D] } | j | k r, | Sq, Wd SXd S(   s  
		Wraps ``optparse.get_option_group``::

			def options(ctx):
				gr = ctx.get_option_group('configure options')
				gr.add_option('-o', '--out', action='store', default='',
					help='build dir for the project', dest='out')

		:rtype: optparse option group object
		N(   Rr   R•   Rq   t   titleRB   (   R   R   t   group(    (    s$   /git_repos/ams-lv2/waflib/Options.pyt   get_option_groupó   s    c         C   sa   | s t  j } n  t j j | ƒ } t j j | | ƒ } t j j | ƒ } t j j | ƒ } | S(   N(   R   t
   launch_dirRt   t   patht
   expanduserR6   t   normpatht   abspath(   R   Rš   t   cwdR   (    (    s$   /git_repos/ams-lv2/waflib/Options.pyt   sanitize_path  s    c         C   sà   | |  j  _ |  j  j d | ƒ \ } } g  } g  } xF | D]> } d | k r\ | j | ƒ q: | d k r: | j | ƒ q: q: WxT d j ƒ  D]F }	 t | |	 d ƒ r‰ |  j t | |	 ƒ | ƒ }
 t | |	 |
 ƒ q‰ q‰ W| | | f S(   s   
		Just parse the arguments
		t   argst   =R$   s$   top out destdir prefix bindir libdirN(	   Rq   R   t
   parse_argsR   t   splitRy   RB   RŸ   t   setattr(   R   t   _argsRž   R   R$   t   leftover_argst   envvarst   commandst   argR�   Rš   (    (    s$   /git_repos/ams-lv2/waflib/Options.pyt   parse_cmd_args  s    c         C   s‚   t  j j ƒ  t 2t 2t  j j | j ƒ t j | ƒ t j | ƒ x9 t D]1 } | j d d ƒ \ } } | t j	 | j
 ƒ  <qI Wd  S(   NR¡   i   (   R$   R.   t   clearR¨   R§   t   updatet   extendR£   Rt   Ru   t   strip(   R   t   arg_optionst   arg_commandst   arg_envvarst   varR�   t   value(    (    s$   /git_repos/ams-lv2/waflib/Options.pyt   init_module_vars$  s    c         C   sÐ   | j  t _  | j  d k r+ |  j d ƒ n  i d d 6d d 6d d 6| j } t j | ƒ | j r� | j j d ƒ t _ t j  s® d t _  q® n t j  d k r® d	 g t _ n  t j  d k rÌ d
 g t _ n  d  S(   Ni   t   errchecki   RK   RF   i    RE   t   ,t   runnert   *(   RW   R    t   loadRM   t   enable_colorsRX   R£   (   R   R$   R¨   R§   RM   (    (    s$   /git_repos/ams-lv2/waflib/Options.pyt	   init_logs1  s    "		c         C   s?   |  j  ƒ  \ } } } |  j | | | ƒ |  j | | | ƒ d S(   s  
		Parses arguments from a list which is not necessarily the command-line.
		Initializes the module variables options, commands and envvars
		If help is requested, prints it and exit the application

		:param _args: arguments
		:type _args: list of strings
		N(   Rª   R»   R´   (   R   R¥   R$   R¨   R§   (    (    s$   /git_repos/ams-lv2/waflib/Options.pyR¢   B  s    	c         C   s1   t  t |  ƒ j ƒ  |  j ƒ  t j t j ƒ d S(   s3   
		See :py:func:`waflib.Context.Context.execute`
		N(   Rp   RC   t   executeR¢   R   t   alloc_process_poolR$   RS   (   R   (    (    s$   /git_repos/ams-lv2/waflib/Options.pyR¼   O  s    
N(   R@   RA   R,   R*   t   funR   RS   Rs   Rx   R˜   RB   RŸ   R   Rª   R´   R»   R¢   R¼   (    (    (    s$   /git_repos/ams-lv2/waflib/Options.pyRC   j   s   	?	%						(   R,   Rt   R{   R
   t   sysR’   t   waflibR    R   R   R   t   ValuesR$   R¨   R§   Ru   Rv   t   platformt   lockfileR   R   RC   (    (    (    s$   /git_repos/ams-lv2/waflib/Options.pyt   <module>   s   <"A