]> git.donarmstrong.com Git - lilypond.git/blob - scripts/auxiliar/find-superfluous-includes.py
Add '-dcrop' option to ps and svg backends
[lilypond.git] / scripts / auxiliar / find-superfluous-includes.py
1 #!/usr/bin/env python
2 import sys
3 import re
4 import os
5
6
7 full_paths = {}
8 incs = {}
9 inc_re = re.compile ('^#include "([^"]+)"')
10 def parse_file (fn):
11     lst = []
12
13     lc = 0
14     for l in open (fn).readlines():
15         lc += 1
16         m = inc_re.search (l)
17         if m:
18             lst.append ((lc, m.group (1)))
19
20     base = os.path.split (fn)[1]
21     full_paths[base] = fn
22     incs[base] = lst
23     
24
25 def has_include (f, name):
26     try:
27         return name in [b for (a,b) in incs[f]]
28     except KeyError:
29         return False
30
31 for a in sys.argv:
32     parse_file (a)
33
34 print '-*-compilation-*-'
35 for (f, lst) in incs.items ():
36     for (n, inc) in lst:
37         for (n2, inc2) in lst:
38             if has_include (inc2, inc):
39                 print "%s:%d: already have %s from %s" % (full_paths[f], n,
40                                                           inc, inc2)
41                 break
42
43         
44