From ad1cc7420ff87745ef6981a85e4e0122f8d8a9e3 Mon Sep 17 00:00:00 2001 From: Gabor Kelemen Date: Sun, 13 Feb 2022 15:27:41 +0100 Subject: find-unneeded-includes: check existence of files listed in yaml files It might happen that some files are removed/renamed warn about such files to adjust filter rules Change-Id: Ib8f1c586a67310cc8be04edfcc75f655da2dbfe0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129881 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- bin/find-unneeded-includes | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'bin/find-unneeded-includes') diff --git a/bin/find-unneeded-includes b/bin/find-unneeded-includes index bdff09bf23eb..8197e9bf6814 100755 --- a/bin/find-unneeded-includes +++ b/bin/find-unneeded-includes @@ -28,6 +28,7 @@ import sys import threading import yaml import argparse +import pathlib def ignoreRemoval(include, toAdd, absFileName, moduleRules): @@ -341,6 +342,20 @@ def main(argv): print ("File 'compile_commands.json' does not exist, please run:\nmake vim-ide-integration") sys.exit(-1) + # quickly sanity check whether files with exceptions in yaml still exists + # only check for the module of the very first filename passed + moduleName = sorted(list_of_files)[0].split("/")[0] + rulePath = os.path.join(moduleName, "IwyuFilter_" + moduleName + ".yaml") + moduleRules = {} + if os.path.exists(rulePath): + moduleRules = yaml.full_load(open(rulePath)) + if "excludelist" in moduleRules.keys(): + excludelistRules = moduleRules["excludelist"] + for pathname in excludelistRules.keys(): + file = pathlib.Path(pathname) + if not file.exists(): + print("WARNING: File listed in " + rulePath + " no longer exists: " + pathname) + tidy(compileCommands, paths=list_of_files, dontstop=vars(args)["continue"]) if __name__ == '__main__': -- cgit