C :Uc@sddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZdd l mZd d d gZd dgZdddddddgZgaedZejdZ dZ!ddddd ddddd d!d"d#d$dd%d&d'd(d)d*d+gZ"ga#dd,dd d-dd.dd%d'd*g Z$e%a&e'a(e'd/Z)d0Z*d1Z+d2Z,d3Z-d4Z.d5Z/d6Z0d7Z1d8e2fd9YZ3d:e4fd;YZ5d<Z6ed=Z7id>d?6d@dA6dBdC6Z8dDZ9ejdEZ:dFZ;ejdGZ<ejdHZ=ejdIZ>iZ?dJZ@dKZAdLZBdMZCdNZDdOZEdPZFdQZGe'dRZHdSZIdTZJdUZKdVZLdWZMdXZNdYZOdZZPd[e4fd\YZQd]ZRd^ZSd_ZTd`ZUejdaZVdbZWe%eXdcZYddZZdeZ[dfZ\dgZ]dhZ^diZ_djZ`dkZadlZbdmZcdnZddoZedpZfdqZgdrZhdsZidS(ti(tConst(tDict(tDiscard(tList(tModule(tNode(tStmtN(tGypErrort executabletshared_librarytloadable_modulet dependenciestexport_dependent_settingst destinationtfilest include_dirstinputst librariestoutputstsourcess=+?!s_(dir|file|path)s?$cCs:x|dtkr |d }qW|tkp9tj|S(Ni(tis_path_section_charsett path_sectionstis_path_section_match_retsearch(tsection((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyt IsPathSection5stactionstconfigurationstcopiestdefault_configurationtdependencies_originalt postbuildst product_dirtproduct_extensiont product_nametproduct_prefixtrulestrun_aststandalone_static_librarytsuppress_wildcardt target_namettoolsetttoolsetsttypet variablestall_dependent_settingstdirect_dependent_settingst link_settingscCsg|dkrg}n||kr%|S|j|x.||jdgD]}t|||qIW|S(sReturn a list of all build files included into build_file_path. The returned list will contain build_file_path as well as all other files that it included, either directly or indirectly. Note that the list may contain files that were included into a conditional section that evaluated to false and was not merged into build_file_path's dict. aux_data is a dict containing a key for each build file or included build file. Those keys provide access to dicts whose "included" keys contain lists of all other files included by the build file. included should be left at its default None value by external callers. It is used for recursion. The returned list will not contain any duplicate entries. Each build file in the list will be relative to the current directory. tincludedN(tNonetappendtgettGetIncludedBuildFiles(tbuild_file_pathtaux_dataR0tincluded_build_file((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyR4ws    cCstj|}t|ts$t|j}|ddksFtt|dts_t|dj}t|dtst|dj}t |dkstt |dgS(sReturn the eval of a gyp file. The gyp file is restricted to dictionaries and lists only, and repeated keys are not allowed. Note that this is slower than eval() is. iiN( tcompilertparset isinstanceRtAssertionErrort getChildrenR1RRtlent CheckNode(t file_contentstasttc1tc2tc3((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyt CheckedEvals  c Cst|tr|j}i}xtdt|dD]}t||tsYt||jd}||krtd|dtt|dddj |dnt |}|j |t ||d|||Rt enumeratet TypeError( tnodetkeypathtctdicttntkeytkptchildrentindextchild((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyR>s2  =    c Cs||kr||Stjj|r;t|j}ntd|tjfd}y2|rut|}nt |idd6d}WnKt k r} || _ n-t k r} t jj| d|nXt|tstd|n|||(?P<(?:(?:!?@?)|\|)?)(?P[-a-zA-Z0-9_.]+)?\((?P\s*\[?)(?P.*?)(\]?)\))sy(?P(?P>(?:(?:!?@?)|\|)?)(?P[-a-zA-Z0-9_.]+)?\((?P\s*\[?)(?P.*?)(\]?)\))s|(?P(?P[\^](?:(?:!?@?)|\|)?)(?P[-a-zA-Z0-9_.]+)?\((?P\s*\[?)(?P.*?)(\]?)\))cCsdtjdkr`t|tkrHtjdd|dg|d}q`tjdd|}n|S(Ntwin32s^cat stype ii(RtplatformR+RJtretsub(tcmd((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytFixupPlatformCommands 'iiic. Csc|tkrt}d}nB|tkr6t}d}n'|tkrQt}d}n ts]tt|}t |rt |S||kr|St |j |}|s|S|}|j x|D]} | j} tjtjd| d| dk} | d} d| dk} | jd }| jd }t||\}}||}|||!}||d }|d }|||!}| rtj|}t||t||||}nt||||}|j}d | dko||k}| s | r;tjj|}|d kr;| r;d}q;n| r~t|t kr\|}n|jd }|d}tjj |rt!d|nt"stjj#||}nltjj |rt"d}tj$j%||}n|}t"d}tjj#|||}tj$j&|tj$j%||}tj$j'|}x#|d D]}|j(d|qVW|j)n}| rt*} | drt+|}t} nt|}!t,j-|!d}"|"dkrtjtjd||d }| dkrtj.}#|r tj/|nzvt0j|}$yt1|$d}%Wn-t2k ru}&t!d|$d|&fnXt|%j3|$d j4}Wdtj/|#X|dkstn| rt!d| |fnt5|}t6j7|d| dt6j8dt6j8dt6j8d|}'|'j9d \}(})|'j:dksJ|)rvt;j<j(|)t!d||'j=fn|(j4}|t,|!|t rxd|D]\}*|dd k rt>|*t rt>|*t  rt!d#|d$d%|*j?j@qqWtA||||nEt>|t rt>|t  rt!d#|d$d&|j?j@n|rt>|t r|}qOt0jt|}nLd }+t>|t r-tj$jB|}+n|}+|| t|+||}|}qWtjtjd'|t>|t r|rt>|dt rqg},x*|D]"}*|,jCt|*|||qW|,}nt||||}t>|t rDxbtDdtE|D]-}-t ||-rt ||-||-t^s Matches: %rt!R+tcommand_stringt|Rit@Rt is(| cannot handle absolute paths, got "%s"ttopleveltqualified_out_dirs%s tis_arrays(Executing command '%s' in directory '%s't pymod_do_mains,Error importing pymod_do_mainmodule (%s): %ss$Unknown command string '%s' in '%s'.tshelltstdoutRtstdintcwds%Call to '%s' returned exit status %d.s2Had cache value for command '%s' in directory '%s'iRsUndefined variable s in s Variable s- must expand to a string or list of strings; slist contains a sfound a sFound output %r, recursing.(RR(FRtearly_variable_ret PHASE_LATEtlate_variable_retPHASE_LATELATEtlatelate_variable_reRuR;RRtintRJtfinditertreverset groupdictRcRrtDEBUG_VARIABLESRtendRRRtProcessListFiltersInDicttExpandVariableststripRYRZRqR1R+tsplittisabsRtgenerator_filelist_pathsRIRdRtEnsureDirExistst WriteOnDiffRRRR_tcached_command_resultsR3R^tchdirtshlext __import__t ImportErrortDoMaintrstripRt subprocesstPopentPIPEt communicateRRRt returncodeR:RwRt#ProcessVariablesAndConditionsInListtEncodePOSIXShellListR2txrangeR=(.tinputtphaseR,t build_filet variable_retexpansion_symbolRtmatchestoutputt match_groupRt run_commandRt file_listt replace_startt replace_endtc_starttc_endt replacementtcontents_startt contents_endtcontentstprocessed_variablestexpand_to_listtbuild_file_dirt contents_listRZRtrel_build_file_dirRtftit use_shellt cache_keyt cached_valuetoldwdtparsed_contentst py_moduleRmtptp_stdouttp_stderrRtencoded_replacementt new_outputRU((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyRs@                                      #                 "       cCs|tkrd}n1|tkr*d}n|tkr:dStsFt||krVdS||}||=x|D]}t|tst|dnt|dkrt|dkrt|d|ddt t|n|dd!\}}d} t|dkr!|d} nt ||||} t| t  rpt| t  rpt d d tjjny>t| d d } t| idd 6|r|} n| } Wntk r} tdt | jd| j|| jf| j| j| j| j}|n<tk rK} tjj| d| |ft| nX| dkrnt| |||t|| ||qnqnWdS(NRttarget_conditionss must be a listiiRis must be length 2 or 3, not s7Variable expansion in this context permits str and int s only, found sR_RWs9%s while evaluating condition '%s' in %s at character %d.s%while evaluating condition '%s' in %s(RR RRuR;R:RJRR=RR1RRt ValueErrortexpandedRwRtcompileR_R`RttexttoffsetRatlinenot NameErrorRcRdReRRt(tthe_dictR.R,R/tconditions_keytconditions_listRt cond_exprt true_dictt false_dicttcond_expr_expandedtast_codet merge_dictRmt syntax_error((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytProcessConditionsInDictsZ         $,     #    cCs_xX|jD]J\}}t|tsFt|tsFt|tr ||d|sD               cCs5i}g|D]$}||kr |j||^q S(s=Removes duplicate elements from l, keeping the first element.(t setdefault(tltseenRm((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytUnifyscCs]xV|jD]H\}}x9tD]1}|j|g}|r t|||(R(R((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyt__repr__scCsg}t|j}x|r|j}|j|jxZ|jD]O}t}x*|jD]}|j|kr[t}Pq[q[W|rE|j|qEqEWqW|S(N( RRRR2RRR RuR(Rt flat_listtin_degree_zerosRMtnode_dependenttis_in_degree_zerotnode_dependent_dependency((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyt FlattenToLists  cCs|dkr|g}ng}x|jD]|}||kr|g}x+|D]#}|j|||krJPqJqJW|jt|q(|j|j|g|q(Wtt|S(sR Returns a list of cycles in the graph, where each cycle is its own list. N(R1RR2ttupleRot FindCyclesRJR(RRZtresultsRMtcycletpart((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyRs       !cCs^|dkrg}nxB|jD]7}|jdkr|j|kr|j|jqqW|S(s+Returns a list of just direct dependencies.N(R1R RR2(RR R((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytDirectDependenciess   cCs|dkrg}nd}x|t|kr||}||}d}xG|jdgD]3}||kr]|j||||d}q]q]W|d}qW|S(s^Given a list of direct dependencies, adds indirect dependencies that other dependencies have declared to export their settings. This method does not operate on self. Rather, it operates on the list of dependencies in the |dependencies| argument. For each dependency in that list, if any declares that it exports the settings of one of its own dependencies, those dependencies whose settings are "passed through" are added to the list. As new items are added to the list, they too will be processed, so it is possible to import settings through multiple levels of dependencies. This method is not terribly useful on its own, it depends on being "primed" with a list of direct dependencies such as one provided by DirectDependencies. DirectAndImportedDependencies is intended to be the public entry point. iiR N(R1R=R3R|(RRR RURtdependency_dictt add_indextimported_dependency((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyt_AddImportedDependenciess     cCs|j|}|j||S(sReturns a list of a target's direct dependencies and all indirect dependencies that a dependency has advertised settings should be exported through the dependency for. (RR(RRR ((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytDirectAndImportedDependencies.scCsk|dkrg}nxO|jD]D}|jdkr|j|kr|j|j|j|qqW|S(s>Returns a list of all of a target's dependencies, recursively.N(R1R RR2tDeepDependencies(RR R((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyR7s  cCs|d krg}n|jd kr(|Sd||jkrJtdnd||jkr{td||jdn||jd}|tk}|r| r|S|dkr||jjdt r|j|kr|j|jn|S| r |d kr |S| r*|d kr*| r*|S|j|kr|j|j|sV| rx*|jD]}|j|||t q`Wqn|S( sjReturns a list of dependency targets that are linked into this target. This function has a split personality, depending on the setting of |initial|. Outside callers should always leave |initial| at its default setting. When adding a target to the list of dependencies, this function will recurse into itself with |initial| set to False, to collect dependencies that are linked into the linkable target for which the list is being built. If |include_shared_libraries| is False, the resulting dependencies will not include shared_library targets that are linked into this target. R(s&Missing 'target_name' field in target.R+s!Missing 'type' field in target %stnonetdependencies_traverseRR R N(s executableR ( R1RRtlinkable_typesR3RR2R t_LinkDependenciesInternalRu(RRtinclude_shared_librariesR tinitialt target_typet is_linkableR((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyRDs>       cCs)||jjdt}|j||S(si Returns a list of dependency targets whose link_settings should be merged into this target. t(allow_sharedlib_linksettings_propagation(RR3RR(RRR((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytDependenciesForLinkSettingss cCs|j|tS(sP Returns a list of dependency targets that are linked into this target. (RR(RR((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytDependenciesToLinkAgainstsN(RRRRRRRRR1RRRRRRRRR(((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyRs   *  ) R c Cswi}x9|jD]+\}}||krt|||}t|j dkru|j j | | j j |ququW| j} t| t|krg} x0|jD]"}|| kr| j |qqWtjj|}g}xw| jD]i}g}x@|D]8}|jj|sjt|j |jt|qLW|j ddj|q9Wtjddj|ndS( NR s,while computing dependencies of .gyp file %ssDependancy '%s' not foundis Cycle: %ss -> s/Cycles in .gyp file dependency graph detected: s (titerkeysRcRdRpRRvR3RReR R2RR1t itervaluesR=RRYRZt commonprefixRRt startswithR;RIR(RRRR/Rtbuild_file_nodettarget_dependenciesRR}RmRRRt bad_filestfiletcommon_path_prefixtcyclesRtsimplified_pathsRM((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyt#VerifyNoGYPFileCircularDependenciessZ         c Csx|D]}||}tjj|}|dkrH||j}nT|dkrj||j|}n2|dkr||j|}ntd|xS|D]K}||} || krqntjj|} t|| ||| qWqWdS(NR-R.R/sCDoDependentSettings doesn't know how to determine dependencies for (RcRdRpRRRRRt( RRRRRRRR/R RRR}((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytDoDependentSettingss$          c Csx|D]}||}|d}|dkrd|kr?qn|jdg|d<||j|}d}x|t|kr||} || } | ddkr| jdt s| ddkr| |dkr||=qr|d}qrWt|dkr||d^]cCs||kstj|r|Stjjtjjtjjtjj |tjj ||j dd}|ddkr|d7}n|SdS(Ns\Ri( t exception_reRRYRZRpRIRcRdRRqR(tto_filetfro_fileRtret((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytMakePathRelatives c sdfd}d}tfd|D}x|D]} t} t| tskt| tr|rt||| } n| } t| t s| jd r!t} q!nit| tri} t | | ||n>t| t rg} t | | ||nt d| j j|rp| sA|| || r|j| | rm|j| qmqqAx#| r| |kr|j| qsW|j|| | r|j| n|d}qAWdS(NcSs|jS(N(t__hash__(tval((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytscs |r||kS||kS(N((txtsR(t is_hashable(s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytis_in_set_or_lists  ic3s!|]}|r|VqdS(N((t.0R(R(s*ext/snowcrash/tools/gyp/pylib/gyp/input.pys st-s/Attempt to merge list item of unsupported type i(RRuR:RRRRRRPRtRJt MergeListsRLRwRR2RtremoveR|( ttotfroRRtis_pathsR2Rt prepend_indexthashable_to_setRt singletontto_item((Rs*ext/snowcrash/tools/gyp/pylib/gyp/input.pyRs@        cCs;x4|jD]&\}}||krt}t|tsIt|tr{t||tplt||tst}qn|j||jkrt}n|rtd|jjd||jjd|qnt|tst|tr)t |}|rt |||||Target %s has an invalid target type '%s'. Must be one of %s.RR&is_Target %s has type %s but standalone_static_library flag is only valid for static_library type.N(s executablesloadable_modulesstatic_librarysshared_librarysnone(R3R1RRI(RRtVALID_TARGET_TYPESR((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytValidateTargetType[ s   c Cs|jdddkrdS|jdg}i}xi|D]a}tjj|\}}|dk}|sqq;ntjj|} |j| gj|q;Wd } xL|jD]>\} } t | dkr| d| dj | f7} qqW| rd|| dGHt dndS(NR+RR Rs.cs.ccs.cpps.cxxs.ms.mms.ss.SRis %s: %s Rs<static library %s has several files with the same basename: s4Some build systems, e.g. MSVC08, cannot handle that.s6Duplicate basenames in sources section, see list above(sstatic_librarysshared_library(s.cs.ccs.cpps.cxxs.ms.mms.ss.S( R3R1RYRZtsplitexttbasenameRR2RvR=RIR( RRR/Rt basenamestsourceRRtis_compiled_fileRRR((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytValidateSourcesInTargets s&  $cCsi}i}|jdg}x|D]}|d}||krZtd||fn|||<|d}|jdr|d}n||krtdd||||d|fn|||The 'run_as' in target %s from file %s should be a dictionary.R sEThe 'run_as' in target %s from file %s must have an 'action' section.sCThe 'action' for 'run_as' in target %s from file %s must be a list.tworking_directorysPThe 'working_directory' for 'run_as' in target %s in file %s should be a string.t environmentsNThe 'environment' for 'run_as' in target %s in file %s should be a dictionary.(R3R:RPRRJR(RRR/R(R%R R)R*((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytValidateRunAsInTarget s,c Cs|jd}|jdg}x|D]}|jd}|sVtd|n|jdd }|d krtd|n|jd}|r(|d r(td |q(q(Wd S( s0Validates the inputs to the actions in a target.R(Rt action_namesKAnonymous action in target %s. An action must have an 'action_name' field.Rs"Action in target %s has no inputs.R is%Empty action as command in target %s.N(R3RR1( RRR/R(RR R,Rtaction_command((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pytValidateActionsInTarget s   cCsx|jD]\}}t|trAt|}|||RnRfRxRRRRbRtobjectRRRRRRRR R RRRRR RRRcReRjRR*RnRyRRRRRRRRRRRRRRRtRRRRRRR(R+R.R0R1R:R?RRM(((s*ext/snowcrash/tools/gyp/pylib/gyp/input.pyts                     !   0 ( $ l 95 :        < V  o "  ' E    ( =  N H c  T    :    #