2021-05-20 05:45:01 -05:00
|
|
|
#!/usr/bin/python3
|
2020-02-02 04:51:23 -06:00
|
|
|
|
|
|
|
# Look for headers inside include/ that can be moved into their respective modules.
|
2020-07-06 05:26:28 -05:00
|
|
|
# Not 100% accurate
|
2020-02-02 04:51:23 -06:00
|
|
|
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
headerSet = set()
|
|
|
|
a = subprocess.Popen("git ls-files include/", stdout=subprocess.PIPE, shell=True)
|
|
|
|
with a.stdout as txt:
|
|
|
|
for line in txt:
|
2024-03-27 03:54:50 -05:00
|
|
|
header = line[8:].strip()
|
2021-05-20 05:45:01 -05:00
|
|
|
if b"README" in header: continue
|
|
|
|
if header == b"version.hrc": continue
|
2020-02-02 04:51:23 -06:00
|
|
|
# ignore URE headers
|
2021-05-20 05:45:01 -05:00
|
|
|
if header.startswith(b"IwyuFilter_include.yaml"): continue
|
|
|
|
if header.startswith(b"cppu/"): continue
|
|
|
|
if header.startswith(b"cppuhelper/"): continue
|
|
|
|
if header.startswith(b"osl/"): continue
|
|
|
|
if header.startswith(b"sal/"): continue
|
|
|
|
if header.startswith(b"salhelper/"): continue
|
|
|
|
if header.startswith(b"uno/"): continue
|
2020-02-02 04:51:23 -06:00
|
|
|
headerSet.add(header)
|
|
|
|
|
|
|
|
headerSetUnused = headerSet.copy()
|
|
|
|
headerSetOnlyInOwnModule = headerSet.copy()
|
|
|
|
a = subprocess.Popen("git grep '^#include <'", stdout=subprocess.PIPE, shell=True)
|
|
|
|
with a.stdout as txt:
|
|
|
|
for line in txt:
|
2021-05-20 05:45:01 -05:00
|
|
|
idx1 = line.find(b"#include <")
|
|
|
|
idx2 = line.find(b">", idx1 + 10)
|
2020-07-06 05:26:28 -05:00
|
|
|
include = line[idx1 + 10 : idx2]
|
2020-02-02 04:51:23 -06:00
|
|
|
headerSetUnused.discard(include)
|
|
|
|
#
|
2021-05-20 05:45:01 -05:00
|
|
|
idx1 = line.find(b"/")
|
2020-02-02 04:51:23 -06:00
|
|
|
includedFromModule = line[0 : idx1]
|
2021-05-20 05:45:01 -05:00
|
|
|
idx1 = include.find(b"/")
|
2020-02-02 04:51:23 -06:00
|
|
|
module = include[0 : idx1]
|
|
|
|
if module != includedFromModule:
|
|
|
|
headerSetOnlyInOwnModule.discard(include)
|
|
|
|
|
2021-05-20 05:45:01 -05:00
|
|
|
print("completely unused")
|
|
|
|
print("----------------------------")
|
2020-02-02 04:51:23 -06:00
|
|
|
for x in sorted(headerSetUnused):
|
2021-05-20 05:45:01 -05:00
|
|
|
print(x)
|
|
|
|
print("")
|
|
|
|
print("only used in own module")
|
|
|
|
print("----------------------------")
|
2020-02-02 04:51:23 -06:00
|
|
|
for x in sorted(headerSetOnlyInOwnModule):
|
2021-05-20 05:45:01 -05:00
|
|
|
print(x)
|