File: deps.py

package info (click to toggle)
coq-ext-lib 0.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 808 kB
  • sloc: makefile: 44; python: 31; sh: 4; lisp: 3
file content (40 lines) | stat: -rwxr-xr-x 882 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
import os, sys

def get_name(n):
    n = n.strip()
    if n.startswith('./'):
        n = n[2:]
    if n.endswith('.vo'):
        n = n[:-3]
    return n

def get_ident(n):
    n = get_name(n)
    return n.replace('/','_')

def gather_deps(files):
    result = {}
    for f in files:
        name = f[:-4] # ends in ".v.d"

        l = open(f).readlines()
        (_, d) = l[0].split(':')
        deps = [ get_name(x) for x in d.split(' ')
                 if x.strip().endswith('.vo') ]

        result[name] = deps

    return result

def print_dot(deps):
    print 'digraph dependencies {'
    for k in deps.keys():
        print '\t%s [label="%s"] ;' % (get_ident(k), k)
        for d in deps[k]:
            print '\t%s -> %s ;' % (get_ident(k), get_ident(d))
    print '}'

if __name__ == '__main__':
    deps = gather_deps(sys.argv[1:])
    print_dot(deps)