diff options
Diffstat (limited to 'tools/check-includes.py')
-rwxr-xr-x | tools/check-includes.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/check-includes.py b/tools/check-includes.py new file mode 100755 index 0000000000..27d11b9d0a --- /dev/null +++ b/tools/check-includes.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: LGPL-2.1-or-later + +# pylint: disable=missing-docstring,invalid-name,unspecified-encoding,consider-using-with + +import re +import sys + +def check_file(filename): + seen = set() + good = True + for n, line in enumerate(open(filename)): + if m := re.match(r'^\s*#\s*include\s*[<"](\S*)[>"]', line): + include = m.group(1) + if include in seen: + print(f'{filename}:{n}: {line.strip()}') + good = False + seen.add(include) + return good + +if __name__ == '__main__': + good = all(check_file(name) for name in sys.argv[1:]) + sys.exit(0 if good else 1) |