
    擖g\/                     H    S r SSKrSSKrSSKrSSKrSSKrS rS r	S r
S rg)a  Xcode-ninja wrapper project file generator.

This updates the data structures passed to the Xcode gyp generator to build
with ninja instead. The Xcode project itself is transformed into a list of
executable targets, each with a build step to build with ninja, and a target
with every source and resource file.  This appears to sidestep some of the
major performance headaches experienced using complex projects and large number
of targets within Xcode.
    Nc                    [         R                  R                  U 5      u  p4US-   nUS   nUR                  (       a*  [         R                  R	                  UR                  U5      n [         R
                  " U5        SnX4 Hy  n	[         R                  R                  [         R                  R                  U	5      5      S   S-   n
[        R                  R                  R                  SU
-   5      n
USU
-  -  nM{     US	-  n[         R                  R	                  US
5      n [        U5       nUR                  5       nX:X  a
   SSS5        g SSS5        [        US5       nUR!                  U5        SSS5        g! [         a*  nUR                  [        R                  :w  a  e  SnAGN2SnAff = f! , (       d  f       Nl= f! [         a     N{f = f! , (       d  f       g= f)z7Create a workspace to wrap main and sources gyp paths. z.xcworkspaceoptionsNzC<?xml version="1.0" encoding="UTF-8"?>
<Workspace version = "1.0">
r   z
.xcodeprojzgroup:z$  <FileRef location = %s></FileRef>
z</Workspace>
zcontents.xcworkspacedataw)ospathsplitextgenerator_outputjoinmakedirsOSErrorerrnoEEXISTbasenamexmlsaxsaxutils	quoteattropenreadwrite)main_gypsources_gypparamsbuild_file_rootbuild_file_extworkspace_pathr   eoutput_stringgyp_namenameworkspace_file
input_fileinput_stringoutput_files                  1/usr/lib/python3/dist-packages/gyp/xcode_ninja.py_WriteWorkspacer&      s   (*(8(8(B%_$~5NYGg&>&>O
N#
 	U  +ww 0 0 :;A>Mww))(T/:@4GG , %%MWW\\.2LMN.!Z%??,L, "!, " 
nc	"k-( 
#	"/  77ell" # "!   
#	"sZ   (F &G	 1F8G	 G	 &G
F5F00F58
GG	 G	 	
GG
G'c           	      x   SnSnU(       ax  US   n[         R                  R                  UR                  [        R
                  R                  R                  U5      5      nUR                  S0 5      R                  SS5      nU R                  S5      nU R                  SU5      nU R                  S5      n0 nXXS'   XhS'   U(       a  XxS'   U R                  S	5      US	'   U R                  S
5      US
'   0 US'   0 n	U(       a  SU-  U	S'   SU ;   a`  U S    HW  n
U S   U
   R                  S0 5      nSU;   a  SU	S'   US   U	S'   S H  nX;   d  M
  X   X'   M     0 US   U
'   U	US   U
   S'   MY     U R                  SS5      US'   U R                  SS5      US'   U R                  SS5      US'   U R                  SS5      US'   U R                  SS5      US'   U S   US'   U(       aQ  SU-  / / SS[         R                  S   -  SSU	S   U/SU-  S./US '   US:  a  US    S   S!   R                  S"U45        U$ )#z,Create fake target for xcode-ninja wrapper. Nr   r   generator_flagsxcode_ninja_jobstarget_nameproduct_nameproduct_extensiontoolsetdefault_configurationconfigurationsz-%s/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)CONFIGURATION_BUILD_DIRxcode_settingsIPHONEOS_DEPLOYMENT_TARGETNOCODE_SIGNING_REQUIRED)BUNDLE_LOADER	TEST_HOST
mac_bundlemac_xctest_bundleios_app_extensionios_watchkit_extensionios_watchkit_apptypezCompile and copy %s via ninjaenvzPATH=%sPATHninjaz-C)action_nameinputsoutputsactionmessageactionsrC   z-j)r   r   r
   toplevel_dirgyp	generatorr?   ComputeOutputDirgetenvironextend)old_specr   ninja_topleveljobsr   r*   r+   r,   ninja_targetnew_xcode_settingsconfigold_xcode_settingskeys                r%   _TargetFromSpecrU   :   s    ND#  #--"5"5"F"Fv"N
 zz+R0445GK,,}-K<<<L %89L"-#/ ,=()&ll95L,4LL9P,QL()%'L!" ;nL 	45 8#/0F!)*:!;F!C!G!G "" ,/AA>B"#:;CU0D"#?@ 6,.@.E&+ 6 68L)*62 # )*62  1$ "*lA!>L(05H!(LL$%(05H!(LL$%-5\\:RTU-VL)*'/||4F'JL#$#F+L  ?L

6 22&'@A ;[H#
Y  !8#A&x077tE    c                 :   UR                  S5      nU b  [        R                  " X5      (       a  g[        UR                  SS5      5      S:w  d,  UR                  SS5      S:X  a6  UR                  SS5      S	:w  a   Ub  [        R                  " X5      (       d  g
gg
)ab  Limit targets for Xcode wrapper.

Xcode sometimes performs poorly with too many targets, so only include
proper executable targets, with filters to customize.
Arguments:
  target_extras: Regular expression to always add, matching any target.
  executable_target_pattern: Regular expression limiting executable targets.
  spec: Specifications for target.
r*   Tr8   r   r<    
executabler,   bundleF)rJ   researchint)target_extrasexecutable_target_patternspecr*   s       r%   IsValidTargetForWrapperra      s     ((=)K RYY}%J%J 488'+,1,HH("-9 %0996DDrV   c                 z   US   S   nUR                  5        H  u  pVXT:X  d  M  US   nM     UR                  S0 5      nUR                  SS5      n	U	c)  [        R                  R	                  U5      u  pU
S-   U-   n	/ n0 n0 n0 X'   / X   S'   / X   S	'   X$   R                  S
0 5      X   S
'   UR                  SS5      nUR                  SS5      nU  H  nUU   n[        UUU5      (       d  M  UR                  S5      nU	 SU S3nUR                  U5        [        UU5      UU'   UUR                  S5      S      S	    H6  nUS   U:X  d  M  0 nUS   US'   US   US'   X   S	   R                  U5        M8     M     Sn[        USSSSS.S5      nSSW/00US'   UR                  SS5      (       + n/ nUR                  5        GH  u  nn[        R                  R                  U5      nUR                  S/ 5      UR                  S/ 5      -   nU(       d4  UR                  UR                  S/ 5      UR                  S/ 5      -   5        UR                  S/ 5       HN  nUR                  UR                  S / 5      5        U(       a  M-  UR                  UR                  S!/ 5      5        MP     U V s/ s H  n U R                  S"5      (       a  M  U PM     nn [        R                  R                  U	5      n!UU V s/ s HA  n [        R                  R                  [        R                  R                  UU 5      U!5      PMC     sn -  nGM     [        [        U5      5      US'   [        R                  R                  [        R                  R                  U	5      US#-   5      n"U" SU S3n#UR                  U#5        UUU#'   0 nUS   US'   UUS'   SUS'   0 UU"'   / UU"   S	'   / UU"   S'   X$   R                  S
0 5      UU"   S
'   UU"   S	   R                  U5        [!        U	U"U5        XU4$ s  sn f s  sn f )$a  Initialize targets for the ninja wrapper.

This sets up the necessary variables in the targets to generate Xcode projects
that use ninja as an external builder.
Arguments:
  target_list: List of target pairs: 'base/base.gyp:base'.
  target_dicts: Dict of target properties keyed on target pair.
  data: Dict of flattened build files keyed on gyp path.
  params: Dict of global options for gyp.
build_filesr   _DEPTHr(   xcode_ninja_main_gypNz.ninjaincluded_filestargetsr1   %xcode_ninja_executable_target_patternxcode_ninja_target_patternr*   :z#targetr-   sources_for_indexingtargetDefault0rY   )r*   r-   r.   r7   r<   include_dirsr/   xcode_ninja_list_excluded_filesTsourcesmac_bundle_resourcessources_excludedmac_bundle_resources_excludedrE   rA   inputs_excluded$z.gyp)itemsrJ   r   r   r   ra   appendrU   splitdirnamerL   
startswithrelpathr
   sortedsetr&   )$target_listtarget_dictsdatar   orig_gypr   gyp_dictdepthr(   r   r   r   new_target_listnew_target_dictsnew_datar_   r^   old_qualified_targetr`   r*   new_target_name
old_targetnew_data_targetsources_target_namesources_targetskip_excluded_filesrq   rl   target_dictbasefilesrC   filerelative_pathr   fully_qualified_target_names$                                       r%   CreateWrapperr      s    m$Q'H"jjlX&E + jj!2B7O""#94@H,.GG,<,<X,F)"X-> OH H+-H'($&Hy!+/>+=+=>NPR+SH'(
 !0 3 3/! $''(DdKM +01"=2KTRR((=1K!)
!K=@O""?3 1@f0M_- ##7#=#=c#B1#EFyQ
m,;&(O5?5NOM21;I1FOI.&y188I R !,( 1$.%. 	
 		N )2NUG3L'MN#$ .11)4  G+113wwv&	2."B2
 
 #LL 2B7//"A2FG
 "ooi4FLLHb12&&VZZ(92>?	 5 #(D%$ts/C%D 1QV
QVBGGOOBGGLLt4mDQV
 	
1  48 !'s7| 4N9 '',,rwwx8:MPV:VWK%0M3F2Gw"O 674B01O%3M%BOM" %OH!)OIH[')H[)$.0H[*+.2n.@.@AQSU.VH[*+[)$++O< Hk62x88; E
s   7P3P3AP8)__doc__r   gyp.generator.ninjarG   r   r[   xml.sax.saxutilsr   r&   rU   ra   r    rV   r%   <module>r      s3   
   	 	 !)HL^:H9rV   