Meta: Ignore local includes of .moc files

These are generated by Qt and added to the include path automatically by
CMake.
This commit is contained in:
Timothy Flynn 2023-06-20 13:50:18 -04:00 committed by Andreas Kling
parent f4446cdf8c
commit 0fd35b4dd8
Notes: sideshowbarker 2024-07-17 08:43:11 +09:00

View file

@ -51,12 +51,19 @@ BAD_INCLUDE_LIBC = re.compile("# *include <LibC/")
ANY_INCLUDE_PATTERN = re.compile('^ *# *include\\b.*[>"](?!\\)).*$', re.M)
SYSTEM_INCLUDE_PATTERN = re.compile("^ *# *include *<([^>]+)>(?: /[*/].*)?$")
LOCAL_INCLUDE_PATTERN = re.compile('^ *# *include *"([^>]+)"(?: /[*/].*)?$')
INCLUDE_CHECK_EXCLUDES = {
"Userland/Libraries/LibCodeComprehension/Cpp/Tests/",
"Userland/Libraries/LibCpp/Tests/parser/",
"Userland/Libraries/LibCpp/Tests/preprocessor/",
}
LOCAL_INCLUDE_SUFFIX_EXCLUDES = [
# Some Qt files are required to include their .moc files, which will be located in a deep
# subdirectory that we won't find from here.
'.moc',
]
def should_check_file(filename):
if not filename.endswith('.cpp') and not filename.endswith('.h'):
@ -126,8 +133,13 @@ def run():
if filename not in errors_include_weird_format:
errors_include_weird_format.append(filename)
continue
relative_filename = local_match.group(1)
referenced_file = file_directory.joinpath(relative_filename)
if referenced_file.suffix in LOCAL_INCLUDE_SUFFIX_EXCLUDES:
continue
if not referenced_file.exists():
print(f"In {filename}: Cannot find {referenced_file}")
if filename not in errors_include_missing_local: