
    擖gS                     P    S r SSKJr   " S S5      r " S S5      r " S S5      rg)	z$Visual Studio project reader/writer.    Nc                   (    \ rS rSrSrSS jrS rSrg)Tool   zVisual Studio tool.Nc                 @    U=(       d    0 U l         XR                   S'   g)z_Initializes the tool.

Args:
  name: Tool name.
  attrs: Dict of tool attributes; may be None.
NameN_attrs)selfnameattrss      1/usr/lib/python3/dist-packages/gyp/MSVSProject.py__init__Tool.__init__   s     kr"F    c                     SU R                   /$ )zQCreates an element for the tool.

Returns:
  A new xml.dom.Element for the tool.
r   r   )r
   s    r   _GetSpecificationTool._GetSpecification   s     $$r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes__ r   r   r   r      s    #%r   r   c                   "    \ rS rSrSrSS jrSrg)Filter"   z1Visual Studio filter - that is, a virtual folder.Nc                 B    Xl         [        U=(       d    / 5      U l        g)z|Initializes the folder.

Args:
  name: Filter (folder) name.
  contents: List of filenames and/or Filter objects contained.
N)r   listcontents)r
   r   r!   s      r   r   Filter.__init__%   s     	X^,r   )r!   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   "   s
    ;-r   r   c                   T    \ rS rSrSrSS jrS rS rSS jrS r	S	 r
SS
 jrS rSrg)Writer3   z!Visual Studio XML project writer.Nc                     Xl         X l        X0l        X@l        U(       d  S/nS/U l        U H"  nU R                  R                  SSU0/5        M$     S/U l        S/U l        S/U l        0 U l	        g)	a  Initializes the project.

Args:
  project_path: Path to the project file.
  version: Format version to emit.
  name: Name of the project.
  guid: GUID to use for project, if not None.
  platforms: Array of string, the supported platforms.  If null, ['Win32']
Win32	PlatformsPlatformr   	ToolFilesConfigurationsFilesN)
project_pathversionr   guidplatform_sectionappendtool_files_sectionconfigurations_sectionfiles_section
files_dict)r
   r-   r.   r   r/   	platformsplatforms          r   r   Writer.__init__6   s     )		  	I "-!H!!((*vx6H)IJ "#.-'7&8#%Y r   c                 B    U R                   R                  SSU0/5        g)zYAdds a tool file to the project.

Args:
  path: Relative path from project to tool file.
ToolFileRelativePathN)r2   r1   )r
   paths     r   AddToolFileWriter.AddToolFileT   s"     	&&
^T4J'KLr   c                 4   U(       d  0 nU(       d  / nUR                  5       nX%S'   X/nU(       ag  U Ha  n[        U[        5      (       a!  UR                  UR	                  5       5        M9  UR                  [        U5      R	                  5       5        Mc     U$ )a  Returns the specification for a configuration.

Args:
  config_type: Type of configuration node.
  config_name: Configuration name.
  attrs: Dict of configuration attributes; may be None.
  tools: List of tools (strings or Tool objects); may be None.
Returns:
r   )copy
isinstancer   r1   r   )r
   config_typeconfig_namer   tools
node_attrsspecificationts           r   _GetSpecForConfigurationWriter._GetSpecForConfiguration\   s     EE ZZ\
(6$1 a&&!(()<)<)>?!((a)B)B)DE	 
 r   c                 `    U R                  SXU5      nU R                  R                  U5        g)zAdds a configuration to the project.

Args:
  name: Configuration name.
  attrs: Dict of configuration attributes; may be None.
  tools: List of tools (strings or Tool objects); may be None.
ConfigurationN)rH   r3   r1   )r
   r   r   rD   specs        r   	AddConfigWriter.AddConfigz   s,     ,,_d5Q##**40r   c                     U Hi  n[        U[        5      (       a,  SSUR                  0/nU R                  XCR                  5        OSSU0/nX@R
                  U'   UR                  U5        Mk     g)zAdds files and/or filters to the parent node.

Args:
  parent: Destination node
  files: A list of Filter objects and/or relative paths to files.

Will call itself recursively, if the files list contains Filter objects.
r   r   Filer;   N)rA   r   r   _AddFilesToNoder!   r5   r1   )r
   parentfilesfnodes        r   rQ   Writer._AddFilesToNode   sg     A!V$$ 6166"23$$T::6 34%)"MM$ r   c                 <    U R                  U R                  U5        g)a3  Adds files to the project.

Args:
  files: A list of Filter objects and/or relative paths to files.

This makes a copy of the file/filter tree at the time of this call.  If you
later add files to a Filter object which was passed into a previous call
to AddFiles(), it will not be reflected in this project.
N)rQ   r4   )r
   rS   s     r   AddFilesWriter.AddFiles   s     	T//7r   c                     U R                   R                  U5      nU(       d  [        SU-  5      eU R                  SX#U5      nUR	                  U5        g)a<  Adds a configuration to a file.

Args:
  path: Relative path to the file.
  config: Name of configuration to add.
  attrs: Dict of configuration attributes; may be None.
  tools: List of tools (strings or Tool objects); may be None.

Raises:
  ValueError: Relative path does not match any file added via AddFiles().
z(AddFileConfig: file "%s" not in project.FileConfigurationN)r5   get
ValueErrorrH   r1   )r
   r<   configr   rD   rR   rL   s          r   AddFileConfigWriter.AddFileConfig   sP     $$T*G$NOO ,,-@&QVWdr   c                 $   SSU R                   R                  5       U R                  U R                  U R                  SS.U R                  U R
                  U R                  S/U R                  S//n[        R                  " XR                  SS9  g	)
zWrites the project file.VisualStudioProjectz
Visual C++	Win32Proj)ProjectTypeVersionr   ProjectGUIDRootNamespaceKeyword
ReferencesGlobalszWindows-1252)encodingN)r.   ProjectVersionr   r/   r0   r2   r3   r4   easy_xmlWriteXmlIfChangedr-   )r
   contents     r   WriteIfChangedWriter.WriteIfChanged   s     "+<<668		#yy!%& !!##''NK
" 	""7,=,=Wr   )	r3   r5   r4   r/   r   r0   r-   r2   r.   )NN)r   r   r   r   r   r   r=   rH   rM   rQ   rX   r_   rp   r   r   r   r   r$   r$   3   s/    +<M<	1 $
8*Xr   r$   )r   gyp.easy_xmlrm   r   r   r$   r   r   r   <module>rs      s/   
 + 
% %,- -"[X [Xr   