bump product version to 7.2.5.1
[LibreOffice.git] / bin / find-headers-to-move-inside-modules.py
blob9ec0f623128dbc2556f830a032e2b9ca20e9f4c4
1 #!/usr/bin/python3
3 # Look for headers inside include/ that can be moved into their respective modules.
4 # Not 100% accurate
6 import subprocess
7 import sys
9 headerSet = set()
10 a = subprocess.Popen("git ls-files include/", stdout=subprocess.PIPE, shell=True)
11 with a.stdout as txt:
12 for line in txt:
13 header = line[8:].strip();
14 if b"README" in header: continue
15 if header == b"version.hrc": continue
16 # ignore URE headers
17 if header.startswith(b"IwyuFilter_include.yaml"): continue
18 if header.startswith(b"cppu/"): continue
19 if header.startswith(b"cppuhelper/"): continue
20 if header.startswith(b"osl/"): continue
21 if header.startswith(b"sal/"): continue
22 if header.startswith(b"salhelper/"): continue
23 if header.startswith(b"uno/"): continue
24 # these are direct copies of mozilla code
25 if header.startswith(b"onlineupdate/mozilla/"): continue
26 headerSet.add(header)
28 headerSetUnused = headerSet.copy()
29 headerSetOnlyInOwnModule = headerSet.copy()
30 a = subprocess.Popen("git grep '^#include <'", stdout=subprocess.PIPE, shell=True)
31 with a.stdout as txt:
32 for line in txt:
33 idx1 = line.find(b"#include <")
34 idx2 = line.find(b">", idx1 + 10)
35 include = line[idx1 + 10 : idx2]
36 headerSetUnused.discard(include)
38 idx1 = line.find(b"/")
39 includedFromModule = line[0 : idx1]
40 idx1 = include.find(b"/")
41 module = include[0 : idx1]
42 if module != includedFromModule:
43 headerSetOnlyInOwnModule.discard(include)
45 print("completely unused")
46 print("----------------------------")
47 for x in sorted(headerSetUnused):
48 print(x)
49 print("")
50 print("only used in own module")
51 print("----------------------------")
52 for x in sorted(headerSetOnlyInOwnModule):
53 print(x)