ó
ÓnäZc           @   sò   d  Z  d d l Z d d l Z d d l Z y d d l Z e j Z Wn& e k
 rk d d l Z e j	 Z n Xe j
 ƒ  i d d 6d d 6Z d d „ Z d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s7   New implementation of Visual Studio project generation.iÿÿÿÿNs&   {8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}t   projects&   {2150E333-8FDC-42A3-9474-1A3956D46DE8}t   foldert   msvs_newc         C   sz   t  t | ƒ t |  ƒ ƒ j ƒ  j ƒ  } d | d  d | d d !d | d d !d | d d !d | d d !d } | S(	   s#  Returns a GUID for the specified target name.

  Args:
    name: Target name.
    seed: Seed for MD5 hash.
  Returns:
    A GUID-line string calculated from the name and seed.

  This generates something which looks like a GUID, but depends only on the
  name and seed.  This means the same name/seed will always generate the same
  GUID, so that projects and solutions which refer to each other can explicitly
  determine the GUID to refer to explicitly.  It also means that the GUID will
  not change when the project for a target is rebuilt.
  t   {i   t   -i   i   i   i    t   }(   t   _new_md5t   strt	   hexdigestt   upper(   t   namet   seedt   dt   guid(    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyt   MakeGuid%   s    (Nt   MSVSSolutionEntryc           B   s   e  Z d  „  Z RS(   c         C   s+   t  |  j |  j ƒ  f | j | j ƒ  f ƒ S(   N(   t   cmpR
   t   get_guid(   t   selft   other(    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyt   __cmp__?   s    (   t   __name__t
   __module__R   (    (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyR   >   s   t
   MSVSFolderc           B   s,   e  Z d  Z d d d d d „ Z d „  Z RS(   s.   Folder in a Visual Studio project or solution.c         C   sz   | r | |  _  n t j j | ƒ |  _  | |  _ | |  _ t t | pH g  ƒ ƒ |  _ t | p` g  ƒ |  _ t	 d |  _
 d S(   sÄ  Initializes the folder.

    Args:
      path: Full path to the folder.
      name: Name of the folder.
      entries: List of folder entries to nest inside this folder.  May contain
          Folder or Project objects.  May be None, if the folder is empty.
      guid: GUID to use for folder, if not None.
      items: List of solution items to include in the folder project.  May be
          None, if the folder does not directly contain items.
    R   N(   R
   t   ost   patht   basenameR   t   sortedt   listt   entriest   itemst   ENTRY_TYPE_GUIDSt   entry_type_guid(   R   R   R
   R   R   R   (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyt   __init__G   s    		c         C   s1   |  j  d  k r* t |  j d d ƒ|  _  n  |  j  S(   NR   t   msvs_folder(   R   t   NoneR   R   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyR   c   s    N(   R   R   t   __doc__R#   R!   R   (    (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyR   D   s   t   MSVSProjectc           B   sG   e  Z d  Z d d d d d d d d „ Z d „  Z d „  Z d „  Z RS(   s   Visual Studio project.c	   	      C   s¢   | |  _  | |  _ | |  _ | |  _ | pI t j  j t j  j | ƒ ƒ d |  _ t | p[ g  ƒ |  _	 t
 d |  _ | rƒ | |  _ n	 i  |  _ | |  _ d |  _ d S(   s¹  Initializes the project.

    Args:
      path: Absolute path to the project file.
      name: Name of project.  If None, the name will be the same as the base
          name of the project file.
      dependencies: List of other Project objects this project is dependent
          upon, if not None.
      guid: GUID to use for project, if not None.
      spec: Dictionary specifying how to build this project.
      build_file: Filename of the .gyp file that the vcproj file comes from.
      config_platform_overrides: optional dict of configuration platforms to
          used in place of the default for this target.
      fixpath_prefix: the path used to adjust the behavior of _fixpath
    i    R    N(   R   R   t   spect
   build_fileR   t   splitextR   R
   R   t   dependenciesR   R    t   config_platform_overridest   fixpath_prefixR#   t   msbuild_toolset(	   R   R   R
   R)   R   R&   R'   R*   R+   (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyR!   p   s    				+		c         C   s   t  | p g  ƒ |  _ d  S(   N(   R   R)   (   R   R)   (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyt   set_dependencies•   s    c         C   s+   |  j  d  k r$ t |  j ƒ |  _  n  |  j  S(   N(   R   R#   R   R
   (   R   (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyR   ˜   s    c         C   s   | |  _  d  S(   N(   R,   (   R   R,   (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyt   set_msbuild_toolset©   s    N(   R   R   R$   R#   R!   R-   R   R.   (    (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyR%   m   s   		#		t   MSVSSolutionc           B   s2   e  Z d  Z d d e d „ Z e j j d „ Z	 RS(   s   Visual Studio solution.c         C   s`   | |  _  | |  _ | |  _ t | p' g  ƒ |  _ | rC | |  _ n d d g |  _ |  j ƒ  d S(   s¹  Initializes the solution.

    Args:
      path: Path to solution file.
      version: Format version to emit.
      entries: List of entries in solution.  May contain Folder or Project
          objects.  May be None, if the folder is empty.
      variants: List of build variant strings.  If none, a default list will
          be used.
      websiteProperties: Flag to decide if the website properties section
          is generated.
    s   Debug|Win32s   Release|Win32N(   R   t   websitePropertiest   versionR   R   t   variantst   Write(   R   R   R1   R   R2   R0   (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyR!   ²   s    				c         C   s^  t  ƒ  } |  j } xW | rl | j d ƒ } | | k r= q n  | j | ƒ t | t ƒ r | | j 7} q q Wt | ƒ } | |  j ƒ } | j d |  j	 j
 ƒ  ƒ | j d |  j	 j ƒ  ƒ t j j |  j ƒ d } x_| D]W} t j j | j | ƒ } | j d d ƒ pd } | j d | j | j | | j ƒ  f ƒ |  j rT| j d ƒ n  t | t ƒ r·| j r·| j d	 ƒ x( | j D] }	 | j d
 |	 |	 f ƒ qƒW| j d ƒ q·n  t | t ƒ r&| j r&| j d ƒ x4 | j D]) }
 | j d
 |
 j ƒ  |
 j ƒ  f ƒ qæW| j d ƒ q&n  | j d ƒ qÜ W| j d ƒ | j d ƒ x( |  j D] } | j d
 | | f ƒ q[W| j d ƒ g  } i  } xF | D]> } t | t ƒ rœ| j | j ƒ  ƒ | j | | j ƒ  <qœqœW| j ƒ  | j d ƒ xl | D]d } x[ |  j D]P } | | j | | ƒ } | j d | | | f ƒ | j d | | | f ƒ qWqüW| j d ƒ | j d ƒ | j d ƒ | j d ƒ t g  | D] } t | t ƒ r¢| j ^ q¢ƒ rC| j d ƒ xZ | D]R } t | t ƒ søqÝn  x4 | j D]) } | j d
 | j ƒ  | j ƒ  f ƒ qWqÝW| j d ƒ n  | j d ƒ | j ƒ  d S(   sf   Writes the solution file to disk.

    Raises:
      IndexError: An entry appears multiple times.
    i    s:   Microsoft Visual Studio Solution File, Format Version %s
s   # %s
t   /s   \t   .s"   Project("%s") = "%s", "%s", "%s"
s–   	ProjectSection(WebsiteProperties) = preProject
		Debug.AspNetCompiler.Debug = "True"
		Release.AspNetCompiler.Debug = "False"
	EndProjectSection
s-   	ProjectSection(SolutionItems) = preProject
s   		%s = %s
s   	EndProjectSection
s4   	ProjectSection(ProjectDependencies) = postProject
s   EndProject
s   Global
s>   	GlobalSection(SolutionConfigurationPlatforms) = preSolution
s   	EndGlobalSection
s>   	GlobalSection(ProjectConfigurationPlatforms) = postSolution
s   		%s.%s.ActiveCfg = %s
s   		%s.%s.Build.0 = %s
s2   	GlobalSection(SolutionProperties) = preSolution
s   		HideSolutionNode = FALSE
s.   	GlobalSection(NestedProjects) = preSolution
s   EndGlobal
N(    t   setR   t   popt   addt
   isinstanceR   R   R   t   writeR1   t   SolutionVersiont   DescriptionR   t   splitt   gypt   commont   RelativePatht   replaceR    R
   R   R0   R   R%   R)   R2   t   appendR*   t   sortt   gett   anyt   close(   R   t   writert   all_entriest   entries_to_checkt   et   ft   sln_roott   relative_patht   folder_namet   iR   t   vt   config_guidst   config_guids_overridest   gt   nvt   subentry(    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyR3   Ø   s˜    	
						'
		1+N(
   R   R   R$   R#   t   TrueR!   R>   R?   t   WriteOnDiffR3   (    (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyR/   ¯   s   %(   R$   R   t   randomt
   gyp.commonR>   t   hashlibt   md5R   t   ImportErrort   newR   R   R   t   objectR   R   R%   R/   (    (    (    s/   /usr/lib/python2.7/dist-packages/gyp/MSVSNew.pyt   <module>   s$   

)B