
nZc           @   s<  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	 Z	 d  d l
 m Z i  Z d Z d Z d Z d   Z d   Z i  g  d e e e e d	  Z d
   Z d   Z d   Z d   Z d   Z d e j f d     YZ d   Z d   Z d   Z e  d k r8e j! e    n  d S(   iN(   t   GypErrort   generalt	   variablest   includesc         G   s   d t  j k s |  t  j k r d	 } y- t j d d  } | rP | d d  } n  Wn n X| rn | | ;} n  d |  j   t j j | d  | d | d | f GHn  d  S(
   Nt   allt   unknowni    t   limiti   i   s   %s:%s:%d:%s %si   (   R   i    R   (   t   gypt   debugt	   tracebackt   extract_stackt   uppert   ost   patht   basename(   t   modet   messaget   argst   ctxt   f(    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   DebugOutput   s    c          C   sU   d }  t  j t  j    } g  } x- | D]% } | j |   r( | j |  q( q( W| S(   Ns   .gyp(   R   t   listdirt   getcwdt   endswitht   append(   t	   extensiont   filest   build_filest   file(    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   FindBuildFiles(   s    t   .c	         C   sN  | d k r i  } n  d | k r@ | j d d  \ } | d <n  t j |  } | | d <| j d d  | d <| j d  r t j j |  d }	 t j j |	  \ }
 }	 t j j |
  }
 |
 t	 j k r t	 j j
 d |
  q n
 d	 | }	 t |	 t   t   |	  } x- | j j   D] \ } } | j | |  qWt | d
 d  r`| j | |  n  t | d d  r| j |  n  i t | d g   d 6t | d g   d 6t | d g   d 6t | d t  d 6t | d t  d 6t | d t  d 6t | d d  d 6} t j j |  | | | | | | | | d | d 
 } | g | S(   s   
  Loads one or more specified build files.
  default_variables and includes will be copied before use.
  Returns the generator for the specified format and the
  data returned by loading the specified build files.
  t   -i   t   flavort	   GENERATORt    t   GENERATOR_FLAVORs   .pyi    s   gyp.generator.t   CalculateVariablest   CalculateGeneratorInputInfot+   generator_additional_non_configuration_keyst   non_configuration_keyst"   generator_additional_path_sectionst   path_sectionst!   generator_extra_sources_for_rulest   extra_sources_for_rulest$   generator_supports_multiple_toolsetst4   generator_wants_static_library_dependencies_adjustedt#   generator_wants_sorted_dependenciest   generator_filelist_pathst   parallelt   root_targetsN(   t   Nonet   splitt   copyt   getR   R   R   t   splitextt   abspatht   syst   insertt
   __import__t   globalst   localst   generator_default_variablest   itemst
   setdefaultt   getattrR$   R%   t   Falset   TrueR   t   inputt   Load(   R   t   formatt   default_variablesR   t   deptht   paramst   checkt   circular_checkt   duplicate_basename_checkt   generator_nameR   t	   generatort   keyt   valt   generator_input_infot   result(    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyRD   2   sF    		

c         C   s   i  } x |  D]{ } | j  d d  } t |  d k rz y t | d  } Wn t k
 rh | d } n X| | | d <q t | | d <q W| S(   s   
  Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary
  of the pairs.  If a string is simply NAME, then the value in the dictionary
  is set to True.  If VALUE can be converted to an integer, it is.
  t   =i   i   i    (   R3   t   lent   intt
   ValueErrorRB   (   t   name_value_listRQ   t   itemt   tokenst   token_value(    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   NameValueListToDict   s    c         C   s1   t  j j |  g   } | r- t j |  } n  | S(   N(   R   t   environR5   t   shlexR3   (   t   env_namet   flags(    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   ShlexEnv   s    c         C   s%   |  j  d  r d |  | f S|  | S(   Ns   --s   %s=%s(   t
   startswith(   t   optt   value(    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt	   FormatOpt   s    c         C   s   g  } | j  rm | rm xU t |  D]D } t |  | |   } | | k rY | j |  n  | j |  q" Wn  | r x- | D]" } | j t |  | |    qz Wn  | S(   s  Regenerate a list of command line flags, for an option of action='append'.

  The |env_name|, if given, is checked in the environment and used to generate
  an initial list of options, then the options that were specified on the
  command line (given in |values|) are appended.  This matches the handling of
  environment variables and command line flags where command line flags override
  the environment, while not requiring the environment to be set when the flags
  are used again.
  (   t   use_environmentR_   Rc   t   removeR   (   t   flagt   valuest	   predicateR]   t   optionsR^   t
   flag_valueRb   (    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   RegenerateAppendFlag   s    
#c            s    f d   } d   } d g } x  j  j   D]\ } } | d } t   |  } | d d k rl | po | } | d }	 | d }
 |	 d	 k r | j t | | | |
     q1 |	 d k r4| r | j t | | |    q  j r|
 rt	 j
 j |
  r| j t | | t	 j
 j |
     qq1 |	 d k r|	 d k rR| se|	 d k ru| ru| j |  q  j r|
 rt j d |	 | |
 f IJqq1 t j d |	 | f IJq1 W| S(   s}  Given a parsed options object, and taking the environment variables into
  account, returns a list of flags that should regenerate an equivalent options
  object (even in the absence of the environment variables.)

  Any path options will be normalized relative to depth.

  The format flag is not included, as it is assumed the calling generator will
  set that as appropriate.
  c            s,   t  j j |    j  }  |  s( t j j S|  S(   N(   R   t   commont   FixIfRelativePathRG   R   R   t   curdir(   R   (   Ri   (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   FixPath   s    
c         S   s   |  S(   N(    (   Rb   (    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   Noop   s    s   --ignore-environmentRa   t   typeR   t   actionR]   R   t   storet
   store_truet   store_falsesJ   Warning: environment regeneration unimplemented for %s flag %r env_name %rs9   Warning: regeneration unimplemented for action %r flag %rN(   Rs   N(   Rt   Ru   (   t   _regeneration_metadatat	   iteritemsR@   t   extendRk   R2   R   Rc   Rd   R   R[   R5   R8   t   stderr(   Ri   Ro   Rp   R^   t   namet   metadataRa   Rb   t   value_predicateRr   R]   (    (   Ri   s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   RegenerateFlags   s8    
		


!.

t   RegeneratableOptionParserc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   i  |  _  t j j |   d  S(   N(   t1   _RegeneratableOptionParser__regeneratable_optionst   optparset   OptionParsert   __init__(   t   self(    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyR      s    	c         O   s   | j  d d
  } d | k r | j  d t  r | d } | j d  } | d k rb d | d <n  i | j d  d 6| d 6| d 6| d d	 6|  j | <n  t j j |  | |  d
 S(   s  Add an option to the parser.

    This accepts the same arguments as OptionParser.add_option, plus the
    following:
      regenerate: can be set to False to prevent this option from being included
                  in regeneration.
      env_name: name of environment variable that additional values for this
                option come from.
      type: adds type='path', to tell the regenerator that the values of
            this option need to be made relative to options.depth
    R]   t   destt
   regenerateRq   R   t   stringRr   i    Ra   N(   t   popR2   RB   R5   R   R   R   t
   add_option(   R   R   t   kwR]   R   Rq   (    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyR      s    
c         G   s1   t  j j |  |  \ } } |  j | _ | | f S(   N(   R   R   t
   parse_argsR   Rv   (   R   R   Rg   (    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyR     s    (   t   __name__t
   __module__R   R   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyR~      s   		c   #      C   s	  t  j j t j d  } t   } d } | j | j d d   | j d d d d d	 d
 d | j d d d d d d
 d | j d d d d d d d d d  d
 d | j d d d d d d d d	 d g  d
 d | j d d d d d	 d d d d  d
 d! | j d" d d# d d$ d% d& d
 d' | j d( d) d d* d d	 d d+ d, t
 d
 d- | j d. d d/ d d	 d g  d d0 d d1 d
 d2 | j d3 d d4 d d d d  d d5 d% d& d d6 d
 d7 | j d8 d d9 d d: d t d, t
 d
 d; | j d< d= d d> d d	 d d? d% d& d
 d@ | j dA d dB d d: d t d, t
 d
 dC | j dD d dE d d: d t d, t
 d
 dF | j dG d d d t
 d
 dH | j dI dJ d dK d dL d
 dM | j dN d dO d d d d  d d5 d% d& d
 dP | j dQ dR d dS d d	 d dT d
 dU | j |   \ } } | } | j sd  } d  } | j rst  j j d d   } | rst  j j |  } qsn  | sdV g }	 t j dw k r|	 j dY  n  x` |	 D]U }
 t  j |
  } | d  k rt  j j | dZ  } t  j j |  sd  } qPqqWqn t  j j | j  } | r>t  j j |  r>d  } n  | j sg  } | j rnt  j j d+ g   } n  | rt j d[ |  } n  | r| | _ qt j d\ k rd] g | _ qt j dx k rd^ g | _ qd_ g | _ n  | j r | j r t  j j d6  } | r | | _ q n  | j | _ x | j D] } d` t j | <q7Wt t j k rt  t da  xt t! | j" j#    D]Z \ } } | d db k rqn  t$ | t%  rt  t dc | |  qt  t dd | |  qWn  | st&   } n  | st' | de | | f   n  | j( sx | D] } t  j j) t  j j* |   } | j t  j j+  } t, |  } xQ t- | d` df df  D]9 } | | dg k rt  j j+ j |  | _( Pn  | | =qW| j( r&Pq&q&W| j( st' dh   qn  | j. s| j( | _. n  i  } g  } | j r+| t/ d   7} n  | j0 rD| | j0 7} n  t1 |  } t t j k rrt  t di |  n  g  } | d  k rt  j j | dj  } t  j j |  rdk | GH| j |  qn  | j2 r| j3 | j2  n  g  } | j r| t/ d1  7} n  | j4 r| | j4 7} n  t1 |  } t t j j5   k rRt  t dl |  n  xAt6 | j  D]0} i
 | dm 6| dn 6| d/ 6t  j7   do 6| dp 6t j d dq 6| dr 6| j ds 6| j8 dS 6| j dt dL  dt 6} t9 | | | | | j( | | j: | j; | j< 	 \ } } } }  | j= | | |  |  | j> rb| | d du j5   }! x0 | j> D]% }" |" |! k rP	t' dv |"   qP	qP	W| j? |  | j> |  qbqbWd S(y   Ni    s(   usage: %s [options ...] [build_file ...]s   %ss   %progs   --buildR   t   configsRr   R   t   helps0   configuration for build after project generations   --checkRI   Rt   s   check format of gyp filess   --config-dirt
   config_dirRs   R]   t   GYP_CONFIG_DIRt   defaults7   The location for configuration files like include.gypi.s   -ds   --debugR   t   metavart	   DEBUGMODEs   turn on a debugging mode for debugging GYP.  Supported modes are "variables", "includes" and "general" or "all" for all of them.s   -Dt   definess   VAR=VALt   GYP_DEFINESs   sets variable VAR to value VALs   --depthRG   t   PATHRq   R   s1   set DEPTH gyp variable to a relative path to PATHs   -fs   --formatt   formatst   GYP_GENERATORSR   s   output formats to generates   -Gt   generator_flagss   FLAG=VALt   GYP_GENERATOR_FLAGSs   sets generator flag FLAG to VALs   --generator-outputt   generator_outputt   DIRt   GYP_GENERATOR_OUTPUTs$   puts generated build files under DIRs   --ignore-environmentRd   Ru   s.   do not read options from environment variabless   -Is	   --includeR   t   INCLUDEs)   files to include in all loaded .gyp filess   --no-circular-checkRJ   s4   don't check for circular relationships between filess   --no-duplicate-basename-checkRK   s#   don't check for duplicate basenamess   --no-parallels   Disable multiprocessings   -Ss   --suffixt   suffixR"   s    suffix to add to generated filess   --toplevel-dirt   toplevel_dirs/   directory to use as the root of the source trees   -Rs   --root-targetR1   t   TARGETs-   include only TARGET and its deep dependenciest   HOMEt   cygwint   win32t   USERPROFILEs   .gyps   [\s,]t   darwint   xcodet   msvst   makei   s   running with these options:t   _s
     %s: '%s's     %s: %ss   

%s: error: no build_fileit   srcs   Could not automatically locate src directory.  This isa temporary Chromium feature that will be removed.  Use--depth as a workaround.s   cmdline_default_variables: %ss   include.gypis   Using overrides found in s   generator_flags: %sRi   R   t   cwdt   build_files_argt
   gyp_binaryt   home_dot_gypR0   t   target_archt   configurationss(   Invalid config specified via --build: %s(   R   R   (   R   R   (@   R   R   R   R8   t   argvR~   t	   set_usaget   replaceR   R2   RA   RB   R   R   Rd   R[   R5   t
   expandusert   platformR   t   getenvt   joint   existsR   t   reR3   R   t   no_parallelR0   R   R   t   DEBUG_GENERALR   t   sortedt   __dict__R>   t
   isinstancet
   basestringR   R    RG   R7   t   dirnamet   sepRS   t   xrangeR   R_   R   RZ   R   Rx   R   t   keyst   setR   R1   RD   RI   RJ   RK   t   GenerateOutputR   t   PerformBuild(#   R   t   my_namet   parsert   usageRi   R   R   t   homeR   t	   home_varst   home_vart   generate_formatst   g_oR   t   optionRb   t
   build_filet   build_file_dirt   build_file_dir_componentst   components_lent   indext   cmdline_default_variablesR   R   t   default_includet	   gen_flagsR   RE   RH   RM   t	   flat_listt   targetst   datat   valid_configst   conf(    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   gyp_main  sX   								"
										


		c         C   s=   y t  |   SWn( t k
 r8 } t j j d |  d SXd  S(   Ns   gyp: %s
i   (   R   R    R8   Ry   t   write(   R   t   e(    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   main  s
    c           C   s   t  t j d  S(   Ni   (   R   R8   R   (    (    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   script_main   s    t   __main__("   R4   t	   gyp.inputR   R   t   os.pathR   R   R\   R8   R	   t
   gyp.commonR    R   R   t   DEBUG_VARIABLESt   DEBUG_INCLUDESR   R   R2   RA   RB   RD   RZ   R_   Rc   Rk   R}   R   R~   R   R   R   R   t   exit(    (    (    s0   /usr/lib/python2.7/dist-packages/gyp/__init__.pyt   <module>   s:   		
Q					2)	 		