summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGabor Kelemen <kelemen.gabor2@nisz.hu>2021-06-24 07:42:32 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-06-28 08:58:02 +0200
commit1421831429056ed770a67feeec12c843f80bb006 (patch)
treef41d0f0a69e3d471df8b71d45ed0dfb57a13cd15 /bin
parent0171a9e2f0dc9dd2dc85b23871a8f32418b9edf2 (diff)
find-unneeded-includes: introduce --dontstop switch
...to make it not stop after each error found. In case there are not many problems to be expected, it is faster to check a bunch of files and fix the problematic 5% than re-check over and over again the non-problematic ones after each error found. Change-Id: Iec5a2aa96ac557c0247ae2f06eb710daa75cc19b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117756 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/find-unneeded-includes23
1 files changed, 17 insertions, 6 deletions
diff --git a/bin/find-unneeded-includes b/bin/find-unneeded-includes
index 4f90ab55e9f5..fbda1007adfd 100755
--- a/bin/find-unneeded-includes
+++ b/bin/find-unneeded-includes
@@ -27,6 +27,7 @@ import subprocess
import sys
import threading
import yaml
+import argparse
def ignoreRemoval(include, toAdd, absFileName, moduleRules):
@@ -212,7 +213,7 @@ def processIWYUOutput(iwyuOutput, moduleRules, fileName):
return len(toRemove)
-def run_tool(task_queue, failed_files):
+def run_tool(task_queue, failed_files, dontstop):
while True:
invocation, moduleRules = task_queue.get()
if not len(failed_files):
@@ -223,7 +224,8 @@ def run_tool(task_queue, failed_files):
print("ERROR: A file is probably not self contained, check this commands output:\n" + invocation)
elif retcode > 0:
print("ERROR: The following command found unused includes:\n" + invocation)
- failed_files.append(invocation)
+ if not dontstop:
+ failed_files.append(invocation)
task_queue.task_done()
@@ -240,14 +242,15 @@ def isInUnoIncludeFile(path):
or path.startswith("include/uno/")
-def tidy(compileCommands, paths):
+def tidy(compileCommands, paths, dontstop):
return_code = 0
+
try:
max_task = multiprocessing.cpu_count()
task_queue = queue.Queue(max_task)
failed_files = []
for _ in range(max_task):
- t = threading.Thread(target=run_tool, args=(task_queue, failed_files))
+ t = threading.Thread(target=run_tool, args=(task_queue, failed_files, dontstop))
t.daemon = True
t.start()
@@ -300,8 +303,16 @@ def tidy(compileCommands, paths):
def main(argv):
+ parser = argparse.ArgumentParser(description='Check source files for unneeded includes.')
+ parser.add_argument('--dontstop', action='store_true',
+ help='Don\'t stop on errors. Useful for periodic re-check of large amount of files')
+ parser.add_argument('Files' , nargs='*',
+ help='The files to be checked')
+
+ args = parser.parse_args()
+
if not len(argv):
- print("usage: find-unneeded-includes [FILE]...")
+ parser.print_help()
return
try:
@@ -311,7 +322,7 @@ def main(argv):
print ("File 'compile_commands.json' does not exist, please run:\nmake vim-ide-integration")
sys.exit(-1)
- tidy(compileCommands, paths=argv)
+ tidy(compileCommands, paths=args.Files, dontstop=args.dontstop)
if __name__ == '__main__':
main(sys.argv[1:])