
    擖g'                     R    S r SSKrSSKrSSSSSS.rS rS	 rS
 rS rS rS r	S r
g)z8Utility functions shared amongst the Windows generators.    Nexedlllibsys)
executableloadable_moduleshared_librarystatic_librarywindows_driverc                     [         R                  R                  [         R                  R                  [        5      5      n [         R                  R                  [         R                  R                  U SS5      5      n[         R                  R                  USS5      n[         R                  R                  US5      nU$ )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89Hggoobggll8T4@AG77<<7L\3FG    c                 ^    0 nU H$  nX0;  a  M
  [         R                  " X   5      X#'   M&     U$ )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#      s5     	Aw|,  Hr   c                 b    U R                  SS5      nUS    SU 3US'   SR                  U5      $ )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   s:     KKQE(1VH%E!H88E?r   c                 ,    [        U [        U5      5      $ )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     tS[))r   c           
         0 nU H-  n[        X   R                  SS5      5      nU(       d  M)  XBU'   M/     / nU  HI  nX2;   a0  [        X#   5       H  nUR                  [	        X65      5        M     M8  UR                  U5        MK     0 nU H  nX2;   a  [        X#   5       H  n[	        X65      n[
        R
                  " X   5      Xx'   [	        Xx   S   U5      Xx   S'   Xx   R                  S/ 5      n	/ n
[        U[        U	5      X#   5       H  nU
R                  X   5        M     XU   S'   M     M  X   Xs'   M     [        U5       H  nS H  n[
        R
                  " Xs   R                  U/ 5      5      n/ nU HI  nX;   a0  [        X/   5       H  nUR                  [	        X5      5        M     M8  UR                  U5        MK     XU   U'   M     M     XW4$ )zShard 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   s    \_((q9:6"(Q 
 O +./&&z!'78 0 ""1%   +./!!')-<?)C &8B$*=919 &}5 +044YC  CL2B2EFC&&w|4 G4?&y1 0 #//   $%@G99%5%8%<%<Wb%IJL!!("#3#67(//
10@A 8 %++A. " ,<Q( A & ..r   c                 d   U S   U   nUR                  S0 5      nUR                  S0 5      nUR                  S5      nU(       a  U$ U R                  S0 5      nUR                  SS5      nU(       a  U$ U R                  SU S	   5      nS
R                  U[        U S      5      nUS   S-   U-   nU$ )aw  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   z	{}.{}.pdbtypePRODUCT_DIR/)
setdefaultr8   formatTARGET_TYPE_EXT)	target_dictconfig_namevarsconfigmsvslinkerpdb_pathrO   pdb_bases	            r   _GetPdbPathr`      s    $ )*;7F_b1DXXnb)Fzz/0HR0I}}2D9H~{=/IJH!!(OK<O,PQHM"S(83HOr   c                 p   / nU H:  nX   n[        UR                  SS5      5      (       d  M)  UR                  U5        M<     [        5       nU GH  nX   nUR                  S5      n[	        U/ SQ5      nSn	US-   U	-   n
[        XI5      n[        R                  R                  U5      nUS   S-   U
-   nUS-   U-   n[        R                  " U5      nXS'   S	US
'   U/US'   X/S./US'   SnUS-   U-   n[        UU5      n[        R                  " U5      nUUS'   SUS
'   U/US'   U/US'   UR                  S5      R                  5        H  u  nn[        UUU5      nS H  nUR                  US5        M     UR                  S0 5      nUR                  S0 5      nSUS'   UUS'   US   U   nUR                  S0 5      nUR                  S0 5      nSUS'   UUS'   M     U R                  SU5        U R                  SU5        XU'   UUU'   UR                  S/ 5      R                  U5        GM     X4$ )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_DIRrT   nonerR   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`   poprU   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    O"o ;??#3Q788
 	q!  /0"o!oom4%O
	 '&,{: +A ;77++,=>45;>NN"S(+;;MM),	#3- "	& 12	)'2EF
	( '&,{: +A{ ;MM),	#3	- ,	& ,~	)%:$;	.! $-==1A#B#H#H#JK";TBH V

3% V $$_b9D '92>H14H-.2:H./ !!12;?F$$_b9D__^R8F17F-.,4F()) $K0 	134134.7*+.7*+ 	~r299:OPO R &&r   )__doc__r   r   rW   r   r#   r,   r0   rI   r`   r    r   r   <module>r      sN   
 ?  	
 $	*5/p$Nf'r   