Imported Upstream version 1.34.0
[platform/upstream/grpc.git] / tools / distrib / run_clang_tidy.py
index 6e54a75..9af6c8f 100755 (executable)
@@ -24,17 +24,6 @@ sys.path.append(
                  'python_utils'))
 import jobset
 
-extra_args = [
-    '-x',
-    'c++',
-    '-std=c++11',
-]
-with open('.clang_complete') as f:
-    for line in f:
-        line = line.strip()
-        if line.startswith('-I'):
-            extra_args.append(line)
-
 clang_tidy = os.environ.get('CLANG_TIDY', 'clang-tidy')
 
 argp = argparse.ArgumentParser(description='Run clang-tidy against core')
@@ -48,19 +37,28 @@ argp.add_argument('-j',
 argp.set_defaults(fix=False)
 args = argp.parse_args()
 
+# Explicitly passing the .clang-tidy config by reading it.
+# This is required because source files in the compilation database are
+# in a different source tree so clang-tidy cannot find the right config file
+# by seeking their parent directories.
+with open(".clang-tidy") as f:
+    config = f.read()
 cmdline = [
     clang_tidy,
-] + ['--extra-arg-before=%s' % arg for arg in extra_args]
+    '--config=' + config,
+]
 
 if args.fix:
     cmdline.append('--fix')
 
 jobs = []
 for filename in args.files:
-    jobs.append(jobset.JobSpec(
-        cmdline + [filename],
-        shortname=filename,
-    ))  #verbose_success=True))
+    jobs.append(
+        jobset.JobSpec(
+            cmdline + [filename],
+            shortname=filename,
+            timeout_seconds=15 * 60,
+        ))
 
 num_fails, res_set = jobset.run(jobs, maxjobs=args.jobs)
 sys.exit(num_fails)