mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
meson: Implement duplicate includes check with clang-tidy
Instead of doing this with our own script, let's use clang-tidy instead.
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
---
|
---
|
||||||
Checks: '
|
Checks: '
|
||||||
-*,
|
-*,
|
||||||
misc-header-include-cycle
|
misc-header-include-cycle,
|
||||||
|
readability-duplicate-include
|
||||||
'
|
'
|
||||||
WarningsAsErrors: '*'
|
WarningsAsErrors: '*'
|
||||||
HeaderFileExtensions:
|
HeaderFileExtensions:
|
||||||
|
|||||||
10
meson.build
10
meson.build
@@ -2824,16 +2824,6 @@ if git.found()
|
|||||||
run_target(
|
run_target(
|
||||||
'ctags',
|
'ctags',
|
||||||
command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(meson.project_source_root())] + all_files)
|
command : [env, 'ctags', '--tag-relative=never', '-o', '@0@/tags'.format(meson.project_source_root())] + all_files)
|
||||||
|
|
||||||
############################################
|
|
||||||
|
|
||||||
if want_tests != 'false' and conf.get('BUILD_MODE_DEVELOPER') == 1
|
|
||||||
test('check-includes',
|
|
||||||
files('tools/check-includes.py'),
|
|
||||||
args: all_files,
|
|
||||||
env : ['PROJECT_SOURCE_ROOT=@0@'.format(meson.project_source_root())],
|
|
||||||
suite : 'headers')
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
||||||
|
|
||||||
# pylint: disable=consider-using-with
|
|
||||||
|
|
||||||
import os
|
|
||||||
import pathlib
|
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
PROJECT_ROOT = pathlib.Path(os.getenv('PROJECT_SOURCE_ROOT', '.'))
|
|
||||||
|
|
||||||
def check_file(filename):
|
|
||||||
seen = set()
|
|
||||||
good = True
|
|
||||||
for n, line in enumerate(open(filename)):
|
|
||||||
m = re.match(r'^\s*#\s*include\s*[<"](\S*)[>"]', line)
|
|
||||||
if m:
|
|
||||||
include = m.group(1)
|
|
||||||
if include in seen:
|
|
||||||
try:
|
|
||||||
filename = pathlib.Path(filename).resolve().relative_to(PROJECT_ROOT)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
print(f'{filename}:{n}: {line.strip()}')
|
|
||||||
good = False
|
|
||||||
seen.add(include)
|
|
||||||
return good
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
all_good = all(check_file(name) for name in sys.argv[1:])
|
|
||||||
sys.exit(0 if all_good else 1)
|
|
||||||
Reference in New Issue
Block a user