o
    Äñb’³  ã                   @   s$  d Z ddlmZ ddlZddlZddlZddlZddlZddlZ	ddl
Z	zejZW n ey5   ejZY nw i dd“dd“dd“d	d
“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“dd“d d!“d"d#“Zd$Zd%Zd%Zd&d'd'd'd(d(d)œZd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ Zd:d;„ Zdmd<d=„Zd>d?„ Zd@dA„ ZdBdC„ Z dndDdE„Z!G dFdG„ dGe"ƒZ#e#dHddIƒe#dJdKdLƒe#dJdMdNƒe#dJdOdNƒe#dPdQdƒdRœZ$dSdT„ Z%dUdV„ Z&dWdX„ Z'dYdZ„ Z(d[d\„ Z)d]d^„ Z*d_d`„ Z+G dadb„ dbe"ƒZ,dcdd„ Z-dedf„ Z.dgdh„ Z/didj„ Z0dkdl„ Z1dS )oañ  cmake output module

This module is under development and should be considered experimental.

This module produces cmake (2.8.8+) input as its output. One CMakeLists.txt is
created for each configuration.

This module's original purpose was to support editing in IDEs like KDevelop
which use CMake for project management. It is also possible to use CMake to
generate projects for other IDEs such as eclipse cdt and code::blocks. QtCreator
will convert the CMakeLists.txt to a code::blocks cbp for the editor to read,
but build using CMake. As a result QtCreator editor is unaware of compiler
defines. The generated CMakeLists.txt can also be used to build on Linux. There
is currently no support for building on platforms other than Linux.

The generated CMakeLists.txt should properly compile all projects. However,
there is a mismatch between gyp and cmake with regard to linking. All attempts
are made to work around this, but CMake sometimes sees -Wl,--start-group as a
library and incorrectly repeats it. As a result the output of this generator
should not be relied on for building.

When using with kdevelop, use version 4.4+. Previous versions of kdevelop will
not be able to find the header file directories described in the generated
CMakeLists.txt file.
é    )Úprint_functionNZEXECUTABLE_PREFIXÚ ZEXECUTABLE_SUFFIXÚSTATIC_LIB_PREFIXÚlibÚSTATIC_LIB_SUFFIXz.aÚSHARED_LIB_PREFIXÚSHARED_LIB_SUFFIXz.soZSHARED_LIB_DIRú${builddir}/lib.${TOOLSET}ZLIB_DIRú${obj}.${TOOLSET}ZINTERMEDIATE_DIRz ${obj}.${TOOLSET}/${TARGET}/geniZSHARED_INTERMEDIATE_DIRz
${obj}/genÚPRODUCT_DIRú${builddir}ÚRULE_INPUT_PATHú${RULE_INPUT_PATH}ÚRULE_INPUT_DIRNAMEú${RULE_INPUT_DIRNAME}ÚRULE_INPUT_NAMEz${RULE_INPUT_NAME}ÚRULE_INPUT_ROOTz${RULE_INPUT_ROOT}ÚRULE_INPUT_EXTz${RULE_INPUT_EXT}ZCONFIGURATION_NAMEú${configuration})ú${CMAKE_CURRENT_LIST_DIR}r   z${obj}TÚccÚcxxÚs)z.cz.ccz.cppz.cxxz.sz.Sc                 C   s   |   |¡r| t|ƒd… S | S )z8Returns 'a' without 'prefix' if it starts with 'prefix'.N)Ú
startswithÚlen)ÚaÚprefix© r   ú5/usr/lib/python3/dist-packages/gyp/generator/cmake.pyÚRemovePrefixR   s   r   c                 C   s   |   dtj |¡¡ dS )zDCalculate additional variables for use in the build (called by gyp).ZOSN)Ú
setdefaultÚgypÚcommonÚ	GetFlavor)Zdefault_variablesÚparamsr   r   r   ÚCalculateVariablesW   s   r%   c                    s   t ‡ fdd„tD ƒƒS )z:Return true if the file is compilable (should be in OBJS).c                 3   s    | ]}ˆ   |¡V  qd S ©N©Úendswith)Ú.0Úe©Úfilenamer   r   Ú	<genexpr>^   s   € zCompilable.<locals>.<genexpr>)ÚanyÚCOMPILABLE_EXTENSIONSr+   r   r+   r   Ú
Compilable\   s   r0   c                 C   s
   |   d¡S )zAReturn true if the file is linkable (should be on the link line).z.or'   r+   r   r   r   ÚLinkablea   s   
r1   c              	      sJ   t j ˆ ¡rˆ S t‡ fdd„tD ƒƒrˆ S t j dt j t j | ˆ ¡¡¡S )a  Resolves rel_path against base_path and returns the result.

  If rel_path is an absolute path it is returned unchanged.
  Otherwise it is resolved against base_path and normalized.
  If the result is a relative path, it is forced to be relative to the
  CMakeLists.txt.
  c                    ó   g | ]}ˆ   |¡‘qS r   ©r   ©r)   Úvar©Úrel_pathr   r   Ú
<listcomp>p   ó    z0NormjoinPathForceCMakeSource.<locals>.<listcomp>r   )ÚosÚpathÚisabsr.   ÚFULL_PATH_VARSÚjoinÚnormpath©Ú	base_pathr7   r   r6   r   ÚNormjoinPathForceCMakeSourcef   s   ÿrB   c                 C   s.   |  d¡r|  d¡s|S tj tj | |¡¡S )zçResolves rel_path against base_path and returns the result.
  TODO: what is this really used for?
  If rel_path begins with '$' it is returned unchanged.
  Otherwise it is resolved against base_path if relative, then normalized.
  ú$r   )r   r:   r;   r?   r>   r@   r   r   r   ÚNormjoinPathw   s   rD   c                 C   s   |   dd¡  dd¡  dd¡S )a  Escapes the string 'a' for use inside a CMake string.

  This means escaping
  '' otherwise it may be seen as modifying the next character
  '"' otherwise it will end the string
  ';' otherwise the string becomes a list

  The following do not need to be escaped
  '#' when the lexer is in string state, this does not start a comment

  The following are yet unknown
  '$' generator variables (like ${obj}) must not be escaped,
      but text $ should be escaped
      what is wanted is to know which $ come from generator variables
  ú\z\\ú;z\;ú"z\")Úreplace©r   r   r   r   ÚCMakeStringEscape‚   s   rJ   c                 C   ób   |   d¡ |   |¡ |   d¡ |   |¡ |   d¡ |D ]}|   t|ƒ¡ |   |¡ q|   d¡ dS )z<Given a set of source file, sets the given property on them.úset_source_files_properties(ú PROPERTIES ú "ú")
N©ÚwriterJ   )ÚoutputZsource_nameÚproperty_nameÚvaluesÚsepÚvaluer   r   r   ÚSetFileProperty•   ó   




rW   c                 C   sb   |   d¡ t| |ƒ |   d¡ |   |¡ |   d¡ |D ]}|   t|ƒ¡ |   |¡ q|   d¡ dS )z=Given a set of source files, sets the given property on them.rL   rM   rN   rO   N)rQ   ÚWriteVariablerJ   )rR   ÚvariablerS   rT   rU   rV   r   r   r   ÚSetFilesProperty¢   rX   r[   c                 C   rK   )z(Given a target, sets the given property.zset_target_properties(rM   rN   rO   NrP   )rR   Útarget_namerS   rT   rU   rV   r   r   r   ÚSetTargetProperty¯   rX   r]   c                 C   s:   |   d¡ |   |¡ |   d¡ |   t|ƒ¡ |   d¡ dS )zSets a CMake variable.zset(rN   rO   NrP   )rR   Úvariable_namerV   r   r   r   ÚSetVariable¼   s
   


r_   c                 C   sr   |st | |dƒS t|ƒdkrt | ||d ƒS |  d¡ |  |¡ |  d¡ |  d dd„ |D ƒ¡¡ |  d	¡ d
S )z Sets a CMake variable to a list.r   é   r   zlist(APPEND z
  "z"
  "c                 S   s   g | ]}t |ƒ‘qS r   )rJ   )r)   rV   r   r   r   r8   Î   s    z#SetVariableList.<locals>.<listcomp>rO   N)r_   r   rQ   r>   )rR   r^   rT   r   r   r   ÚSetVariableListÅ   s   


ra   c                 C   s"   |   d¡ |   |¡ |   d¡ dS )zUnsets a CMake variable.zunset(ú)
N©rQ   )rR   r^   r   r   r   ÚUnsetVariableÒ   s   

rd   c                 C   s0   |r|   |¡ |   d¡ |   |¡ |   d¡ d S )Nú${ú}rc   )rR   r^   Zprependr   r   r   rY   Ù   s
   


rY   c                   @   ó   e Zd Zdd„ ZdS )ÚCMakeTargetTypec                 C   s   || _ || _|| _d S r&   )ÚcommandÚmodifierÚproperty_modifier)Úselfri   rj   rk   r   r   r   Ú__init__â   s   
zCMakeTargetType.__init__N©Ú__name__Ú
__module__Ú__qualname__rm   r   r   r   r   rh   á   ó    rh   Zadd_executableZRUNTIMEZadd_libraryZSTATICZARCHIVEZSHAREDZLIBRARYZMODULEZadd_custom_targetZSOURCES)Ú
executableÚstatic_libraryÚshared_libraryÚloadable_moduleÚnonec                 C   s   |   tddƒ¡S )zèConverts the given string 'a' to a valid CMake target name.

  All invalid characters are replaced by '_'.
  Invalid for cmake: ' ', '/', '(', ')', '"'
  Invalid for make: ':'
  Invalid for unknown reasons but cause failures: '.'
  z /():."Z_______)Ú	translateÚ
_maketransrI   r   r   r   ÚStringToCMakeTargetNameñ   s   rz   c                    s  |D ]}t |d ƒ}d| |f }|d }	|d }
t||
‡ fdd„|	D ƒƒ |d }‡ fdd„|D ƒ}|d	 }t|||ƒ td
d„ dd„ |D ƒD ƒƒ}t| dd¡ƒr[| t||ƒ¡ | d¡ t||ƒ | d¡ t	|ƒdkr„|D ]}| d¡ | |¡ | d¡ qr| d¡ | t
j |d ¡¡ | d¡ | d¡ t||
ƒ | d¡ | d¡ | ˆ ¡ | d¡ | d¡ d|v rÈ| |d ¡ n| |¡ | d¡ | d¡ | d¡ | d¡ | |¡ | d¡ t||ƒ | d¡ t||
ƒ | d¡ | |¡ qdS ) aÊ  Write CMake for the 'actions' in the target.

  Args:
    target_name: the name of the CMake target being generated.
    actions: the Gyp 'actions' dict for this target.
    extra_sources: [(<cmake_src>, <src>)] to append with generated source files.
    extra_deps: [<cmake_taget>] to append with generated targets.
    path_to_gyp: relative path from CMakeLists.txt being generated to
        the Gyp file in which the target being generated is defined.
  Úaction_namez%s__%sÚinputsÚ__inputc                    ó   g | ]}t ˆ |ƒ‘qS r   ©rB   ©r)   Údep©Úpath_to_gypr   r   r8     r9   z WriteActions.<locals>.<listcomp>Úoutputsc                    r~   r   r   )r)   Úoutr‚   r   r   r8     ó    ÿÚ__outputc                 s   ó    | ]}|r|V  qd S r&   r   ©r)   Údirr   r   r   r-     ó   € zWriteActions.<locals>.<genexpr>c                 s   ó    | ]	}t j |¡V  qd S r&   ©r:   r;   Údirname©r)   Úor   r   r   r-     ó   € Úprocess_outputs_as_sourcesFzadd_custom_command(OUTPUT Ú
r   ú-  COMMAND ${CMAKE_COMMAND} -E make_directory ú
  COMMAND Úactionú
  DEPENDS ú.  WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/ú
  COMMENT Úmessageú  VERBATIM
rb   úadd_custom_target(z
  DEPENDS z
  SOURCES ú
)
N)rz   ra   ÚsetÚintÚgetÚextendÚziprQ   rY   r   r!   r"   ÚEncodePOSIXShellListÚappend)r\   ÚactionsÚextra_sourcesÚ
extra_depsrƒ   rR   r–   r{   Zaction_target_namer|   Úinputs_namer„   Úcmake_outputsÚoutputs_nameÚdirsÚ	directoryr   r‚   r   ÚWriteActionsü   sd   
ÿ
ÿ
























Àr­   c                    s.   |  d¡rt‡ fdd„tD ƒƒr|S t| |ƒS )N)r   r   c                    r2   r   r3   r4   ©Úrule_sourcer   r   r8   M  r9   z4NormjoinRulePathForceCMakeSource.<locals>.<listcomp>)r   r.   r=   rB   )rA   r7   r¯   r   r®   r   Ú NormjoinRulePathForceCMakeSourceK  s   

r°   c              
      s  |D ]Â}t | d |d  ƒ}| dg ¡}|d }	t||	‡ fdd„|D ƒƒ |d }
g }t| dg ¡ƒD ]6\}}|d	 t|ƒ }tj |¡\}}tj |¡\}}t	|d
|ƒ t	|d|ƒ t	|d|ƒ t	|d|ƒ t	|d|ƒ t
dd„ dd„ |
D ƒD ƒƒ}g }t|
ƒD ];\}}|d	 t|ƒ }t	||tˆ ||ƒƒ t| dd¡ƒr¬| d| d |f¡ | d| d ¡ | d| d ¡ qƒ| d¡ |D ]}| d¡ | |¡ | d¡ qÆ|D ]}| d¡ | |¡ | d¡ qÚ| d¡ | tj |d ¡¡ | d¡ | d¡ t||	ƒ | d¡ | tˆ |ƒ¡ | d¡ | d¡ | ˆ ¡ | d¡ | d¡ d |v r>| |d  ¡ n| |¡ | d¡ | d!¡ | d"¡ t|d
ƒ t|dƒ t|dƒ t|dƒ t|dƒ q4| d#¡ | |¡ | d$¡ |D ]}| d¡ | |¡ | d¡ q}| d%¡ t||	ƒ | d¡ | dg ¡D ]}| d¡ | tˆ |ƒ¡ | d¡ q¥| d"¡ | |¡ qd&S )'aÈ  Write CMake for the 'rules' in the target.

  Args:
    target_name: the name of the CMake target being generated.
    actions: the Gyp 'actions' dict for this target.
    extra_sources: [(<cmake_src>, <src>)] to append with generated source files.
    extra_deps: [<cmake_taget>] to append with generated targets.
    path_to_gyp: relative path from CMakeLists.txt being generated to
        the Gyp file in which the target being generated is defined.
  Ú__Ú	rule_namer|   r}   c                    r~   r   r   r€   r‚   r   r   r8   d  r9   zWriteRules.<locals>.<listcomp>r„   Zrule_sourcesÚ_r   r   r   r   r   c                 s   rˆ   r&   r   r‰   r   r   r   r-   v  r‹   zWriteRules.<locals>.<genexpr>c                 s   rŒ   r&   r   r   r   r   r   r-   v  r‘   r’   Fre   rf   zadd_custom_command(OUTPUT
ú  r“   r”   r•   r–   r—   ú r˜   r™   rš   r›   rb   rœ   z	 DEPENDS
zSOURCES N)rz   r    ra   Ú	enumerateÚstrr:   r;   ÚsplitÚsplitextr_   rž   r°   rŸ   r¤   rQ   r!   r"   r£   rY   rD   rd   )r\   Úrulesr¦   r§   rƒ   rR   Zruler²   r|   r¨   r„   Zvar_outputsÚcountr¯   r{   Zrule_source_dirnameZrule_source_basenameZrule_source_rootZrule_source_extr«   Zthese_outputsZoutput_indexr…   Zoutput_namer¬   r   r‚   r   Ú
WriteRulesR  s    
ÿÿÿ

































r¼   c                 C   s  | d }t dd„ |D ƒƒ}|s%| d¡ | |¡ | d¡ | |¡ dS G dd„ dtƒ}|d	d
ƒ}|ddƒ}	|D ]L}
|
d }|
d }|D ]?}tj |¡}tj |¡d }tj ||¡}tj 	|¡rd|n|	}
|
j
 t||ƒ¡ |
j t||ƒ¡ |
j |¡ |
j |¡ qEq9||	fD ]%}
|
j
r¯|d |
j |
_t||
j|
j
ƒ |d |
j |
_t||
j|
jƒ qŠ| d¡ | d¡ ||	fD ]}
|
jrÊt||
jdƒ q¾| d¡ ||	fD ]*}
t|
j|
jƒD ] \}}| d|
j ¡ | |¡ | d¡ | |¡ | d¡ qÝqÔ| d¡ ||	fD ]}
|
jrt||
jdƒ q| d¡ | d¡ | |¡ | d¡ | d¡ | | ¡ | d¡ | d¡ | d¡ | d¡ | |¡ | d¡ ||	fD ]}
|
jrdt||
jdƒ qW| d¡ |jrvt||jdƒ | d¡ | |¡ dS )ax  Write CMake for the 'copies' in the target.

  Args:
    target_name: the name of the CMake target being generated.
    actions: the Gyp 'actions' dict for this target.
    extra_deps: [<cmake_taget>] to append with generated targets.
    path_to_gyp: relative path from CMakeLists.txt being generated to
        the Gyp file in which the target being generated is defined.
  Z__copiesc                 s   s    | ]}|d  V  qdS )ÚfilesNr   )r)   Úcopyr   r   r   r-   Ñ  r‹   zWriteCopies.<locals>.<genexpr>rœ   rb   Nc                   @   rg   )zWriteCopies.<locals>.Copyc                 S   s4   g | _ g | _g | _g | _|| _d | _d | _|| _d S r&   )Úcmake_inputsr©   Ú
gyp_inputsÚgyp_outputsÚextr¨   rª   ri   )rl   rÂ   ri   r   r   r   rm   Ú  s   
z"WriteCopies.<locals>.Copy.__init__Nrn   r   r   r   r   ÚCopyÙ  rr   rÃ   r   r¾   Z_dirsZcopy_directoryr½   Údestinationr`   r}   r‡   zadd_custom_command(
ZOUTPUTrµ   r“   zCOMMAND ${CMAKE_COMMAND} -E %s ZDEPENDSz,WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/zCOMMENT Copying for z	VERBATIM
z

  DEPENDSz

  SOURCESr   )r.   rQ   r¤   Úobjectr:   r;   r?   r¸   r>   Úbasenamer¿   rB   r©   rÀ   rÁ   rÂ   r¨   ra   rª   rY   r¢   ri   )r\   Úcopiesr§   rƒ   rR   Z	copy_nameZhave_copiesrÃ   Z	file_copyZdir_copyr¾   r½   rÄ   Úsrcr;   rÆ   Údstr   r   r   ÚWriteCopiesÄ  s   






ö€

€



ú
€











€

rÊ   c                 C   s6   t j | ¡\}}}|}|r|dkr|d| 7 }t|ƒS )z2This is the name we would like the target to have.Útargetr³   ©r!   r"   ÚParseQualifiedTargetrz   )Úqualified_targetr³   Úgyp_target_nameÚgyp_target_toolsetÚcmake_target_base_namer   r   r   ÚCreateCMakeTargetBaseName0  s   
ÿrÒ   c                 C   s>   t j | ¡\}}}|d | }|r|dkr|d| 7 }t|ƒS )z#An unambiguous name for the target.ú:rË   r³   rÌ   )rÎ   Úgyp_filerÏ   rÐ   Zcmake_target_full_namer   r   r   ÚCreateCMakeTargetFullName:  s   
ÿrÕ   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )Ú
CMakeNameraÒ  Converts Gyp target names into CMake target names.

  CMake requires that target names be globally unique. One way to ensure
  this is to fully qualify the names of the targets. Unfortunatly, this
  ends up with all targets looking like "chrome_chrome_gyp_chrome" instead
  of just "chrome". If this generator were only interested in building, it
  would be possible to fully qualify all target names, then create
  unqualified target names which depend on all qualified targets which
  should have had that name. This is more or less what the 'make' generator
  does with aliases. However, one goal of this generator is to create CMake
  files for use with IDEs, and fully qualified names are not as user
  friendly.

  Since target name collision is rare, we do the above only when required.

  Toolset variants are always qualified from the base, as this is required for
  building. However, it also makes sense for an IDE, as it is possible for
  defines to be different.
  c                 C   sD   t ƒ | _t ƒ }|D ]}t|ƒ}||vr| |¡ q	| j |¡ q	d S r&   )rž   Ú"cmake_target_base_names_confictingrÒ   Úadd)rl   Útarget_listZcmake_target_base_names_seenrÎ   rÑ   r   r   r   rm   X  s   úzCMakeNamer.__init__c                 C   s   t |ƒ}|| jv rt|ƒS |S r&   )rÒ   r×   rÕ   )rl   rÎ   Ú	base_namer   r   r   ÚCreateCMakeTargetNamed  s   
z CMakeNamer.CreateCMakeTargetNameN)ro   rp   rq   Ú__doc__rm   rÛ   r   r   r   r   rÖ   D  s    rÖ   c
           Y   	      sì  |  dd¡}
|  dd¡s|	 d¡ |	 |¡ |	 d¡ tj |¡\}}}tj ||j¡}tj 	|¡}tj 
||j¡}tj ||¡}|‰ |  |i ¡}|  di ¡  |i ¡}d }|dkr_tj |¡}|  d	d
¡}|  dd¡}|  d¡}t  |¡}|d u rƒtd||f ƒ d S t|	d|ƒ t|	d|ƒ |  |¡}g }g }d|v r§t||d ||ˆ |	ƒ d|v r¶t||d ||ˆ |	ƒ d|v rÄt||d |ˆ |	ƒ |  dg ¡}g }g }g }g }g } |D ]D}!tj |!¡\}}"t  |"d ¡}#tˆ |!ƒ}$|#dkrõ| |$¡ qÖ|#dkrÿ| |$¡ qÖ|#dkr
| |$¡ qÖt|"ƒr| |$¡ qÖ|  |$¡ qÖ|D ]J}%|%\}!}&t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 |	 di¡ qO|	 d(¡ t.|	dƒ t.|	dƒ d S )jNZcircularTZ
standaloneFz
#r“   ÚconfigurationsÚmacr\   z<missing target name>Útypez<missing target type>Ztoolsetz/Target %s has unknown target type %s, skipping.ZTARGETZTOOLSETr¥   rº   rÇ   Zsourcesr   r   r   Z
__asm_srcsZ__c_srcsZ
__cxx_srcsZ__linkable_srcsZ__other_srcsrs   Z__dummy_srcsz(${obj}.${TOOLSET}/${TARGET}/genc/dummy.czif(NOT EXISTS "rO   z  file(WRITE "z" "")
zendif()
Úlibrary_dirszlink_directories(rµ   rb   ú(ZTRUEZFALSEZEXCLUDE_FROM_ALLrw   ZLINKER_LANGUAGEÚCrL   r   z% PROPERTIES HEADER_FILE_ONLY "TRUE")
z$ PROPERTIES EXTERNAL_OBJECT "TRUE")
Zproduct_dir)rs   rv   r   ru   r	   Zstandalone_static_libraryr
   Z_OUTPUT_DIRECTORYrt   r   r   )rv   ru   r   r   z,ERROR: What output file should be generated?rË   Úproduct_prefixÚproduct_nameZproduct_extensionÚ.ZPREFIXZ_OUTPUT_NAMEZSUFFIXZ	GENERATEDZinclude_dirsZ__include_dirsc                    r~   r   r   )r)   Zinclude©Zpath_from_cmakelists_to_gypr   r   r8   Œ  r†   zWriteTarget.<locals>.<listcomp>zset_property(TARGET z% APPEND PROPERTY INCLUDE_DIRECTORIES ÚdefinesZCOMPILE_DEFINITIONSrF   ÚcflagsÚcflags_cZ	cflags_ccZCOMPILE_FLAGSÚldflagsZ
LINK_FLAGSÚxcode_settingszXCODE_ATTRIBUTE_%sZdependencieszadd_dependencies(r´   )rs   rv   ru   c                 S   s   g | ]
}t |ƒd kr|‘qS )r   )r   )r)   r   r   r   r   r8     s    Z	librariesztarget_link_libraries(r`   z-Wl,--start-group
z-Wl,--end-group
z  "z
$(SDKROOT)z"
)/r    rQ   r!   r"   rÍ   ZRelativePathÚtoplevel_dirr:   r;   rŽ   ÚInvertRelativePathr>   Úxcode_emulationZXcodeSettingsÚ&cmake_target_type_from_gyp_target_typeÚprintr_   rÛ   r­   r¼   rÊ   r¹   r/   rD   r¤   r1   ra   rY   ri   rj   r]   Úgenerator_default_variablesrB   rk   r   rW   Z	GetCflagsZ
GetCflagsCZGetCflagsCCr¡   r[   ÚitemsÚ
isinstancer·   Zuniquerr   rd   )YÚnamerrÎ   Útarget_dictsÚ	build_dirÚconfig_to_useÚoptionsÚgenerator_flagsÚall_qualified_targetsÚflavorrR   Zcircular_libsrÔ   r³   Zrel_gyp_fileZrel_gyp_dirÚbuild_to_topZbuild_to_gypÚspecÚconfigrë   r\   Ztarget_typeZtarget_toolsetZcmake_target_typeZcmake_target_namer¦   r§   ZsrcsZ	s_sourcesZ	c_sourcesZcxx_sourcesZlinkable_sourcesZother_sourcesrÈ   rÂ   Zsrc_typeZsrc_norm_pathZextra_sourceZreal_sourceZs_sources_nameZc_sources_nameZcxx_sources_nameZlinkable_sources_nameZother_sources_nameZdummy_sources_nameZhas_sourcesrà   Zlibrary_dirZexclude_from_allZextra_target_nameZtarget_output_directoryrA   Zcmake_target_output_directoryZdefault_product_prefixZdefault_product_nameZdefault_product_extZstatic_library_prefixZshared_library_prefixrã   rä   Zproduct_extZcmake_target_output_basenameZcmake_target_outputZincludesZincludes_namerç   rè   ré   Z
cflags_cxxÚflagsrê   Zxcode_settingZxcode_valueZrawDepsZstatic_depsZshared_depsZ
other_depsZrawDepZdep_cmake_nameZdep_specZdep_target_typeZ	extra_depZdepsr   ZlinkableZlib_depZexternal_libsZwrite_groupr   r   ræ   r   ÚWriteTargetk  sÌ  




ÿ
ÿÿÿ






ÿþýüÿ
















ÿÿÿ










ÿÿþý
ÿ

ÿ

ÿ

þÿ

ÿÿ





ü












þ







ý







ý












r   c                 C   sä  |d }|d }t j |¡}tj |jpd¡}| dd¡}	tj tj 	||	|¡¡}
tj 	|j
|
¡}tj 	|d¡}t j |¡ t|dƒ}| d¡ | d	¡ t j | d
 ¡\}}}| d¡ | |¡ | d¡ t|d|ƒ d }d }d }||  dg ¡}t j |
|j
¡}|D ]%\}}|dkr”tj 	||¡}|dkrŸtj 	||¡}|dkrªtj 	||¡}q…t j ddg|¡}t j ddg|¡}t j ddg|¡}|rÎt|d|ƒ |rÖt|d|ƒ |rÞt|d|ƒ | d¡ |rët|d|ƒ t|ddƒ t|ddƒ | d¡ | d¡ | d ¡ | d¡ |d!kr| d"¡ | d¡ t| ƒ}tƒ }|d# D ]}t j | |tj |¡¡D ]}| |¡ q3q%| D ]+}|d!kr]t j |¡\}}}|| }t j || |¡ t||||
||||||ƒ
 q@| ¡  d S )$Nrø   rù   rå   Ú
output_dirr…   zCMakeLists.txtÚwz2cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
zcmake_policy(VERSION 2.8.8)
éÿÿÿÿzproject(rb   ZconfigurationÚmake_global_settingsZARZCCZCXXZ	AR_targetZ	CC_targetZ
CXX_targetZCMAKE_ARZCMAKE_C_COMPILERZCMAKE_CXX_COMPILERzenable_language(ASM)
ZCMAKE_ASM_COMPILERZbuilddirz${CMAKE_CURRENT_BINARY_DIR}Úobjz${builddir}/objr“   z(set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
z*set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
rÞ   z'set(CMAKE_NINJA_FORCE_RESPONSE_FILE 1)
Zbuild_files)r!   r"   r#   r:   r;   ÚrelpathÚgenerator_outputr    r?   r>   rì   ZEnsureDirExistsÚopenrQ   rÍ   r_   rí   ZGetEnvironFallbackrÖ   rž   Z
AllTargetsrØ   rî   ZMergeGlobalXcodeSettingsToSpecr   Úclose)rÙ   rõ   Údatar$   r÷   rø   rù   rû   Úgenerator_dirr  rö   Ztoplevel_buildZoutput_filerR   rÔ   Zproject_targetr³   Úarr   r   r  rü   ÚkeyrV   rô   rú   Z
build_filerÎ   rý   r   r   r   ÚGenerateOutputForConfig=  s”   þ





ÿ€








þý

ÿr  c           
      C   sž   |d }|d }t j |jpd¡}| dd¡}|D ]3}t j t j |||¡¡}g d¢}	td||	f ƒ tj	|	|d d	d
|g}	td||	f ƒ t 	|	¡ qd S )Nrø   rù   rå   r  r…   )Zcmakez-GZNinjazGenerating [%s]: %s)ÚcwdZninjaz-CzBuilding [%s]: %s)
r:   r;   r  r  r    r?   r>   rð   Ú
subprocessZ
check_call)
r
  rÝ   r$   rø   rù   r  r  Úconfig_namerö   Z	argumentsr   r   r   ÚPerformBuild°  s    þ
ôr  c                 C   s2   t   t jt j¡ | \}}}}}t|||||ƒ d S r&   )ÚsignalÚSIGINTÚSIG_IGNr  )ZarglistrÙ   rõ   r
  r$   r  r   r   r   ÚCallGenerateOutputForConfigÊ  s   r  c           
   
   C   sÊ   |  di ¡  dd ¡}|rt| ||||ƒ d S || d  d }|d rVz!t t|ƒ¡}g }|D ]}| | ||||f¡ | t|¡ q.W d S  tyU }	 z| 	¡  |	‚d }	~	ww |D ]
}t| ||||ƒ qXd S )Nrù   rþ   r   rÝ   Zparallel)
r    r  ÚmultiprocessingZPoolr   r¤   Úmapr  ÚKeyboardInterruptZ	terminate)
rÙ   rõ   r
  r$   Zuser_configZconfig_namesZpoolZarglistsr  r*   r   r   r   ÚGenerateOutputÓ  s4   ÿ
ÿý€þÿÿr  )r   r&   )2rÜ   Z
__future__r   r  r:   r  Ústringr  Z
gyp.commonr!   Zgyp.xcode_emulationÚ	maketransry   ÚAttributeErrorr·   rñ   r=   Z$generator_supports_multiple_toolsetsZ4generator_wants_static_library_dependencies_adjustedr/   r   r%   r0   r1   rB   rD   rJ   rW   r[   r]   r_   ra   rd   rY   rÅ   rh   rï   rz   r­   r°   r¼   rÊ   rÒ   rÕ   rÖ   r   r  r  r  r  r   r   r   r   Ú<module>   sÀ   

ÿÿþýüûúùø	÷
öõôóòñðïú

	





û	Orl

'   Us	