Commits

ZyX_I committed f4a4f8c

tools: Added dependency graph generation tools

Comments (0)

Files changed (4)

tools/depsgraph.zsh

+#!/bin/zsh
+emulate -L zsh
+: ${TESTDIR:=/tmp/frawor-depsgraph}
+./gentestdir.zsh $TESTDIR $1
+(( $# )) && shift
+typeset -x TESTDIR
+pushd $TESTDIR
+vim -u <(<<< 'set nocompatible rtp=$TESTDIR') -U NONE \
+    $@ \
+    -c 'source tools/depstodot.vim' \
+    -c 'call g:dtd.write("deps.dot")' \
+    -c 'qa!'
+popd
+mv $TESTDIR/deps.dot .
+dot -Tpng deps.dot -o deps.png

tools/depstodot.vim

+execute frawor#Setup('0.0', {})
+let s:deps={}
+let s:dtd={'ignoredeps': 1}
+function s:dtd.register(plugdict, fdict)
+    let s:deps[a:plugdict.id]=a:plugdict.dependencies
+    if a:plugdict.id is# 'plugin/frawor'
+        let s:deplen=a:plugdict.g.deplen
+        let s:dependents=a:plugdict.g.dependents
+    endif
+endfunction
+call s:_f.newfeature('depstodot', s:dtd)
+let g:dtd={}
+let s:colors=[
+            \'aliceblue',
+            \'antiquewhite4',
+            \'aquamarine4',
+            \'azure4',
+            \'bisque3',
+            \'blue1',
+            \'brown',
+            \'burlywood',
+            \'cadetblue',
+            \'chartreuse',
+            \'chocolate',
+            \'coral',
+            \'cornflowerblue',
+            \'cornsilk4',
+            \'cyan3',
+            \'darkgoldenrod3',
+            \'darkolivegreen1',
+            \'darkorange1',
+            \'darkorchid1',
+            \'darkseagreen',
+            \'darkslateblue',
+            \'darkslategray4',
+            \'deeppink1',
+            \'deepskyblue1',
+            \'dimgrey',
+            \'dodgerblue4',
+            \'firebrick4',
+            \'gold',
+            \'goldenrod',
+            \]
+function g:dtd.write(file)
+    let ranks=map(repeat([[]], max(values(s:deplen))+1), 'copy(v:val)')
+    call map(copy(s:deplen), 'add(ranks[v:val], v:key)')
+    let lines=['digraph G {']
+    let lines+=['    {']
+    let lines+=['        node [shape=plaintext]']
+    let lines+=['        '.join(range(1, len(ranks)-1), ' -> ').';']
+    let lines+=['    }']
+    let lines+=['    node [shape=box];']
+    let i=0
+    for nodes in ranks[1:]
+        let i+=1
+        let lines+=['    { node [fontcolor='.s:colors[i].']; rank = same; '.i.'; "'.join(nodes, '"; "').'"; }']
+    endfor
+    for [plid, dependencies] in items(s:deps)
+        for dplid in keys(dependencies)
+            let lines+=['    edge [color='.s:colors[s:deplen[plid]].'];']
+            let lines+=['    "'.plid.'" -> "'.dplid.'";']
+        endfor
+    endfor
+    let lines+=['}', '']
+    call writefile(lines, a:file, 'b')
+endfunction

tools/gentestdir.zsh

+#!/bin/zsh
+emulate -L zsh
+typeset -xr TESTDIR=$1
+shift
+test -d $TESTDIR || mkdir -p $TESTDIR
+local -r REV=${1:-.}
+(( $# )) && shift
+if [[ $REV == '.' ]] ; then
+    hg locate -0 | xargs -0 tar c -C $(hg root) | (cd $TESTDIR && tar x)
+else
+    hg archive -r $REV $TESTDIR
+fi

tools/profile.zsh

 #!/bin/zsh
-: ${TEMPDIR:=/tmp/frawor-profile}
-typeset -xr TEMPDIR
-test -d $TEMPDIR || mkdir -p $TEMPDIR
-local -r REV=${1:-.}
+: ${TESTDIR:=/tmp/frawor-profile}
+./gentestdir.zsh $TESTDIR $1
 (( $# )) && shift
-if [[ $REV == '.' ]] ; then
-    hg locate -0 | xargs -0 tar c -C $(hg root) | (cd $TEMPDIR && tar x)
-else
-    hg archive -r $REV $TEMPDIR
-fi
-pushd $TEMPDIR
-vim -u <(<<< 'set nocompatible rtp=$TEMPDIR') -U NONE \
+typeset -x TESTDIR
+pushd $TESTDIR
+vim -u <(<<< 'set nocompatible rtp=$TESTDIR') -U NONE \
     --startuptime starttime.dat \
     --cmd 'profile start profile.dat' \
     --cmd 'profile func *' \
     -c 'profile pause' \
     -c 'qa!'
 popd
-cp $TEMPDIR/profile.dat .
-cp $TEMPDIR/starttime.dat .
+cp $TESTDIR/profile.dat .
+cp $TESTDIR/starttime.dat .