2019-05-14 16:20:40 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2019-06-07 13:52:33 +00:00
|
|
|
import os, re
|
|
|
|
|
|
|
|
regex = re.compile('(#include [<|"](?:.*)[>|"])')
|
2019-05-14 16:20:40 +00:00
|
|
|
|
|
|
|
cppfiles = []
|
|
|
|
for root, dirs, files in os.walk(os.curdir):
|
|
|
|
for f in files:
|
|
|
|
if f.endswith(('.cpp', '.cc', '.hpp', '.h')):
|
|
|
|
cppfiles.append('%s/%s' % (root, f))
|
|
|
|
|
|
|
|
for cpp in cppfiles:
|
|
|
|
cpp = os.path.realpath(cpp)
|
|
|
|
cppbase = os.path.basename(cpp)
|
|
|
|
with open(cpp, 'r') as f:
|
|
|
|
cppcontent = f.read()
|
|
|
|
includes = []
|
2019-06-07 13:52:33 +00:00
|
|
|
for match in regex.findall(cppcontent):
|
2019-05-14 16:20:40 +00:00
|
|
|
if match in includes:
|
|
|
|
print('multiple inclusions of: %s, in %s' % (match, cpp))
|
|
|
|
continue
|
|
|
|
includes.append(match)
|