ó ¡îRac@sdZddlmZddlZddlZddlZd„Zd„Zd„Zd„Z e dkr}ej e ƒƒndS( sŠUsing the JSON dumped by the dump-dependency-json generator, generate input suitable for graphviz to render a dependency graph of targets.iÿÿÿÿ(tprint_functionNcCs=|jdƒ\}}}|jdƒ\}}}|||fS(Nt#t:(t partition(ttargett_tsuffixtfilename((sf/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/graphviz.pyt ParseTargetscCs€tdƒ}tj|ƒ}|jƒi}|}xG|r{|jƒ}||krYq5n||||<|j||ƒq5W|S(spLoad the edges map from the dump file, and filter it to only show targets in |targets| and their depedendents.s dump.json(topentjsontloadtclosetpoptextend(Rttargetstfiletedgest target_edgestto_visittsrc((sf/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/graphviz.pyt LoadEdgess     c Csˆtjtƒ}x@|jƒD]2\}}t|ƒ\}}}||j|ƒqWtdƒtdƒtdƒxÅ|jƒD]·\}}t|ƒdkrÔ|d} t| ƒ\}}}td| ||fƒq}td|ƒtd|ƒx7|D]/} t| ƒ\}}}td | |fƒq÷Wtd ƒq}Wx?|jƒD]1\}} x"| D]}td ||fƒqXWqEWtd ƒd S(shPrint a graphviz graph to stdout. |edges| is a map of target to a list of other targets it depends on.s digraph D {s fontsize=8s node [fontsize=8]iis" "%s" [shape=box, label="%s\n%s"]s subgraph "cluster_%s" {s label = "%s"s "%s" [label="%s"]s }s "%s" -> "%s"t}N(t collectionst defaultdicttlisttitemsRtappendtprinttlen( RtfilesRtdstt build_filet target_namettoolsetRRRtdsts((sf/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/graphviz.pyt WriteGraph-s.       cCs~ttjƒdkrZttdtjƒtdtjƒtdtjddtjƒdStdtjdƒ}t|ƒdS(NiRsusage: %s target1 target2...iis dump.json(RtsystargvRt__doc__tstderrRR$(R((sf/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/graphviz.pytmainXs t__main__( R't __future__RRR R%RRR$R)t__name__texit(((sf/opt/alt/alt-nodejs8/root/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/gyp/tools/graphviz.pyt s      +