mirror of
https://github.com/systemd/systemd.git
synced 2025-08-31 09:49:54 +03:00
check-includes: print path relative to project root
Instead of /home/zbyszek/src/systemd-work/build/../src/xdg-autostart-generator/xdg-autostart-service.h:11, print just src/xdg-autostart-generator/xdg-autostart-service.h:11. This is a bit annoying that this requires so much verbosity, but the output with the full names was too annoying.
This commit is contained in:
@ -3,9 +3,13 @@
|
|||||||
|
|
||||||
# pylint: disable=missing-docstring,invalid-name,unspecified-encoding,consider-using-with
|
# pylint: disable=missing-docstring,invalid-name,unspecified-encoding,consider-using-with
|
||||||
|
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
PROJECT_ROOT = pathlib.Path(os.getenv('PROJECT_SOURCE_ROOT', '.'))
|
||||||
|
|
||||||
def check_file(filename):
|
def check_file(filename):
|
||||||
seen = set()
|
seen = set()
|
||||||
good = True
|
good = True
|
||||||
@ -13,6 +17,10 @@ def check_file(filename):
|
|||||||
if m := re.match(r'^\s*#\s*include\s*[<"](\S*)[>"]', line):
|
if m := re.match(r'^\s*#\s*include\s*[<"](\S*)[>"]', line):
|
||||||
include = m.group(1)
|
include = m.group(1)
|
||||||
if include in seen:
|
if include in seen:
|
||||||
|
try:
|
||||||
|
filename = pathlib.Path(filename).resolve().relative_to(PROJECT_ROOT)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
print(f'{filename}:{n}: {line.strip()}')
|
print(f'{filename}:{n}: {line.strip()}')
|
||||||
good = False
|
good = False
|
||||||
seen.add(include)
|
seen.add(include)
|
||||||
|
Reference in New Issue
Block a user