
    "Kb`%                     R    d Z ddlZddlZddddddZd Zd	 Zd
 Zd Zd Zd Z	d Z
y)z8Utility functions shared amongst the Windows generators.    Nexedlllibsys)
executableloadable_moduleshared_librarystatic_librarywindows_driverc                     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 )z/Returns the path of the large_pdb_shim.cc file.z..datawinzlarge-pdb-shim.cc)ospathabspathdirname__file__join)this_dirsrc_dirwin_data_dirlarge_pdb_shim_ccs       ./usr/lib/python3/dist-packages/gyp/MSVSUtil.py_GetLargePdbShimCcPathr      sv    WW__RWW__X67(GGOOBGGLL4>?'gvu5,ggll<1DE	    c                 X    i }|D ]"  }|| vrt        j                  | |         ||<   $ |S )a-  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.
  )copydeepcopy)in_dictkeysdkeys       r   _DeepCopySomeKeysr#      s@     	! )c
']]73<(AcF) 
(r   c                 b    | j                  dd      }|d   d||d<   dj                  |      S )zAdd 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)
  #   r   _)rsplitr   )namesuffixpartss      r   _SuffixNamer,   0   s4     ++c1
%a&)%(	%r   c                 ,    t        | t        |            S )zAdd 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,   str)r)   numbers     r   
_ShardNamer0   >   s     
T3v;	''r   c           
         i }|D ](  }t        ||   j                  dd            }|s$|||<   * g }| D ]F  }||v r/t        ||         D ]  }|j                  t	        ||              6|j                  |       H i }|D ]  }||v rt        ||         D ]  }t	        ||      }t        j
                  ||         ||<   t	        ||   d   |      ||   d<   ||   j                  dg       }	g }
t        |t        |	      ||         D ]  }|
j                  |	|           |
||   d<    ||   ||<    t        |      D ]  }dD ]  }t        j
                  ||   j                  |g             }g }|D ]F  }||v r/t        ||         D ]  }|j                  t	        ||              6|j                  |       H |||   |<     ||fS )a  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.
  
msvs_shardr   target_namesources)dependenciesdependencies_original)intgetrangeappendr0   r   lensorted)target_listtarget_dictstargets_to_shardtshardsnew_target_listinew_target_dictsr)   r4   new_sourcesposdeptyper5   new_dependenciesr!   s                   r   ShardTargetsrI   J   sW     #aa$$\156F"q#
 /  a%a() 1!z!Q/01 Q   ,a%a() 	8!!Q!%<?!;0:d#M2A17}-"4(,,Y;CL*:1*=> 	+C


WS\
*	+,7y)	8 )Oq, "# 
6a< 	6YY/266wCDl %!  )!,- 6a##Jq!$456 
!
!!
$% &6q'"	6
6 +	,,r   c                 <   | d   |   }|j                  di       }|j                  di       }|j                  d      }|r|S | j                  di       }|j                  dd      }|r|S | j                  d| d	         }|d
t        | d      d}|d   dz   |z   }|S )a  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.
  configurationsmsvs_settingsVCLinkerToolProgramDatabaseFile	variablesmsvs_large_pdb_pathNproduct_namer3   .typez.pdbPRODUCT_DIR/)
setdefaultr8   TARGET_TYPE_EXT)	target_dictconfig_namevarsconfigmsvslinkerpdb_pathrO   pdb_bases	            r   _GetPdbPathr`      s    $ '(5&			?B	/$88NB'&ZZ-.(Oook2.)]]0$7(O __^[-GH($ok&6I&JK(- 3&1(	/r   c                 ^   g }|D ]4  }||   }t        |j                  dd            s$|j                  |       6 t               }|D ]  }||   }|j                  d      }t	        |g d      }d}	|dz   |	z   }
t        ||	      }t        j                  j                  |      }|d   dz   |
z   }|dz   |z   }t        j                  |      }|
|d<   d	|d
<   |g|d<   ||gdg|d<   d}|dz   |z   }t        ||      }t        j                  |      }||d<   d|d
<   |g|d<   |g|d<   |j                  d      j                         D ]  \  }}t        |||      }dD ]  }|j                  |d        |j                  di       }|j                  di       }d|d<   ||d<   |d   |   }|j                  di       }|j                  di       }d|d<   ||d<    | j                  d|       | j                  d|       |||<   |||<   |j                  dg       j                  |        | |fS )a  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.
  msvs_large_pdbr   r3   )rK   default_configurationtoolsetlarge_pdb_copyr'   SHARED_INTERMEDIATE_DIRrU   nonerS   r4   )destinationfilescopieslarge_pdb_shimr
   r5   rK   )msvs_precompiled_headermsvs_precompiled_sourcetestNrL   VCCLCompilerTool3DebugInformationFormatProgramDataBaseFileNamerM   trueGenerateDebugInformationrN   )r7   r8   r:   r   r#   r,   r   r   basenamer   r   itemsr`   poprV   insert)r=   r>   rZ   targets_to_shimr@   rX   r   r3   	base_dictcopy_suffixcopy_target_namefull_copy_target_nameshim_cc_basenameshim_cc_dirshim_cc_path	copy_dictshim_suffixshim_target_namefull_shim_target_name	shim_dictrY   r[   r^   r"   r\   compilerr]   s                              r   InsertLargePdbShimsr      s    / 
aq/K {/34
 1
 -. GMaq/K//-0K!+
@BI #K"S(;6';7ww''(9:01C7:JJK$'77Li(I/ImIf.0Ii "$ Ih #K"S(;6';7i(I/Im(If)+Ii"7 9In  )}}-=>DDF /V[+t<h P #

3 3d !3R8h+.h'(,4h() +,[9f3d~r2f+1f'(&.f"#)/0 q/0q/0*3L&'*3L&' >2.556KLOGMR |	$$r   )__doc__r   r   rW   r   r#   r,   r0   rI   r`   r    r   r   <module>r      sN   
 ?  	
 $	(4-n%Pf%r   