ó
ÓnäZc           @   sŠ   d  Z  d d l Z d d l Z i d d 6d d 6d d 6d d	 6d
 d 6Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d S(   s8   Utility functions shared amongst the Windows generators.iÿÿÿÿNt   exet
   executablet   dllt   loadable_modulet   shared_libraryt   libt   static_libraryt   syst   windows_driverc          C   ss   t  j j t  j j t ƒ ƒ }  t  j j t  j j |  d d ƒ ƒ } t  j j | d d ƒ } t  j j | d ƒ } | S(   s/   Returns the path of the large_pdb_shim.cc file.s   ..t   datat   wins   large-pdb-shim.cc(   t   ost   patht   abspatht   dirnamet   __file__t   join(   t   this_dirt   src_dirt   win_data_dirt   large_pdb_shim_cc(    (    s0   /usr/lib/python2.7/dist-packages/gyp/MSVSUtil.pyt   _GetLargePdbShimCcPath   s
    $c         C   sD   i  } x7 | D]/ } | |  k r% q n  t  j |  | ƒ | | <q W| S(   s-  Performs a partial deep-copy on |in_dict|, only copying the keys in |keys|.

  Arguments:
    in_dict: The dictionary to copy.
    keys: The keys to be copied. If a key is in this list and doesn't exist in
        |in_dict| this is not an error.
  Returns:
    The partially deep-copied dictionary.
  (   t   copyt   deepcopy(   t   in_dictt   keyst   dt   key(    (    s0   /usr/lib/python2.7/dist-packages/gyp/MSVSUtil.pyt   _DeepCopySomeKeys   s    
c         C   s7   |  j  d d ƒ } d | d | f | d <d j | ƒ S(   sÃ   Add a suffix to the end of a target.

  Arguments:
    name: name of the target (foo#target)
    suffix: the suffix to be added
  Returns:
    Target name with suffix added (foo_suffix#target)
  t   #i   s   %s_%si    (   t   rsplitR   (   t   namet   suffixt   parts(    (    s0   /usr/lib/python2.7/dist-packages/gyp/MSVSUtil.pyt   _SuffixName0   s    	c         C   s   t  |  t | ƒ ƒ S(   s¹   Add a shard number to the end of a target.

  Arguments:
    name: name of the target (foo#target)
    number: shard number
  Returns:
    Target name with shard added (foo_1#target)
  (   R"   t   str(   R   t   number(    (    s0   /usr/lib/python2.7/dist-packages/gyp/MSVSUtil.pyt
   _ShardName>   s    	c         C   sc  i  } x= | D]5 } t  | | j d d ƒ ƒ } | r | | | <q q Wg  } x[ |  D]S } | | k r™ x> t | | ƒ D] } | j t | | ƒ ƒ qv WqS | j | ƒ qS Wi  } xí | D]å } | | k rŽxÐ t | | ƒ D]­ } t | | ƒ } t j | | ƒ | | <t | | d | ƒ | | d <| | j d g  ƒ }	 g  }
 x5 t | t |	 ƒ | | ƒ D] } |
 j |	 | ƒ q^W|
 | | d <qÚ Wq· | | | | <q· Wx¶ t | ƒ D]¨ } xŸ d D]— } t j | | j | g  ƒ ƒ } g  } x[ | D]S } | | k r2x> t | | ƒ D] } | j t | | ƒ ƒ qWqì| j | ƒ qìW| | | | <qºWq­W| | f S(   s  Shard some targets apart to work around the linkers limits.

  Arguments:
    target_list: List of target pairs: 'base/base.gyp:base'.
    target_dicts: Dict of target properties keyed on target pair.
  Returns:
    Tuple of the new sharded versions of the inputs.
  t
   msvs_shardi    t   target_namet   sourcest   dependenciest   dependencies_original(   R)   R*   (   t   intt   gett   ranget   appendR%   R   t   lent   sorted(   t   target_listt   target_dictst   targets_to_shardt   tt   shardst   new_target_listt   it   new_target_dictsR   R(   t   new_sourcest   post   deptypeR)   t   new_dependenciesR   (    (    s0   /usr/lib/python2.7/dist-packages/gyp/MSVSUtil.pyt   ShardTargetsJ   sH    
#c   	      C   s½   |  d | } | j  d i  ƒ } | j d i  ƒ } | j d ƒ } | rK | S|  j d i  ƒ } | j d d ƒ } | ry | S|  j d |  d ƒ } d	 | t |  d
 f } | d d | } | S(   s“  Returns the path to the PDB file that will be generated by a given
  configuration.

  The lookup proceeds as follows:
    - Look for an explicit path in the VCLinkerTool configuration block.
    - Look for an 'msvs_large_pdb_path' variable.
    - Use '<(PRODUCT_DIR)/<(product_name).(exe|dll).pdb' if 'product_name' is
      specified.
    - Use '<(PRODUCT_DIR)/<(target_name).(exe|dll).pdb'.

  Arguments:
    target_dict: The target dictionary to be searched.
    config_name: The name of the configuration of interest.
    vars: A dictionary of common GYP variables with generator-specific values.
  Returns:
    The path of the corresponding PDB file.
  t   configurationst   msvs_settingst   VCLinkerToolt   ProgramDatabaseFilet	   variablest   msvs_large_pdb_patht   product_nameR'   s	   %s.%s.pdbt   typet   PRODUCT_DIRt   /N(   t
   setdefaultR,   t   Nonet   TARGET_TYPE_EXT(	   t   target_dictt   config_namet   varst   configt   msvst   linkert   pdb_pathRB   t   pdb_base(    (    s0   /usr/lib/python2.7/dist-packages/gyp/MSVSUtil.pyt   _GetPdbPath   s    c         C   sÑ  g  } xC | D]; } | | } t  | j d d ƒ ƒ s; q n  | j | ƒ q Wt ƒ  } xo| D]g} | | } | j d ƒ } t | d d d g ƒ } d }	 | d |	 }
 t | |	 ƒ } t j j | ƒ } | d	 d
 |
 } | d
 | } t	 j
 | ƒ } |
 | d <d | d <| g | d <i | d 6| g d 6g | d <d } | d | } t | | ƒ } t	 j
 | ƒ } | | d <d | d <| g | d <| g | d <xÝ | j d ƒ j ƒ  D]Æ \ } } t | | | ƒ } x' d d d g D] } | j | d  ƒ qÚW| j d i  ƒ } | j d i  ƒ } d | d <| | d <| d | } | j d i  ƒ } | j d i  ƒ } d | d <| | d <q¬W|  j d | ƒ |  j d | ƒ | | | <| | | <| j d g  ƒ j | ƒ q\ W|  | f S(!   sï  Insert a shim target that forces the linker to use 4KB pagesize PDBs.

  This is a workaround for targets with PDBs greater than 1GB in size, the
  limit for the 1KB pagesize PDBs created by the linker by default.

  Arguments:
    target_list: List of target pairs: 'base/base.gyp:base'.
    target_dicts: Dict of target properties keyed on target pair.
    vars: A dictionary of common GYP variables with generator-specific values.
  Returns:
    Tuple of the shimmed version of the inputs.
  t   msvs_large_pdbi    R'   R>   t   default_configurationt   toolsett   large_pdb_copyt   _t   SHARED_INTERMEDIATE_DIRRG   t   noneRE   R(   t   destinationt   filest   copiest   large_pdb_shimR   R)   t   msvs_precompiled_headert   msvs_precompiled_sourcet   testR?   t   VCCLCompilerToolt   3t   DebugInformationFormatt   ProgramDataBaseFileNameR@   t   truet   GenerateDebugInformationRA   N(   R+   R,   R.   R   R   R"   R   R   t   basenameR   R   t	   iteritemsRS   t   popRI   RH   t   insert(   R1   R2   RM   t   targets_to_shimR4   RK   R   R'   t	   base_dictt   copy_suffixt   copy_target_namet   full_copy_target_namet   shim_cc_basenamet   shim_cc_dirt   shim_cc_patht	   copy_dictt   shim_suffixt   shim_target_namet   full_shim_target_namet	   shim_dictRL   RN   RQ   R   RO   t   compilerRP   (    (    s0   /usr/lib/python2.7/dist-packages/gyp/MSVSUtil.pyt   InsertLargePdbShims©   sh    
	




"




(   t   __doc__R   R   RJ   R   R   R"   R%   R=   RS   Rz   (    (    (    s0   /usr/lib/python2.7/dist-packages/gyp/MSVSUtil.pyt   <module>   s   
						7	(