aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpg <pg@yandex-team.com>2023-09-09 22:05:36 +0300
committerpg <pg@yandex-team.com>2023-09-09 22:23:27 +0300
commit05670c5e81b5e77cced21d5e7d7a41d9f4e946a8 (patch)
tree637a55c579c966b337b5b1592af3c46d9b7a682d
parent525aa97d3b20b4fe8d1b56282eadf8a5c75becc5 (diff)
downloadydb-05670c5e81b5e77cced21d5e7d7a41d9f4e946a8.tar.gz
-rw-r--r--build/scripts/clang_tidy.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/build/scripts/clang_tidy.py b/build/scripts/clang_tidy.py
index c0c23b490a..05c3ac33ca 100644
--- a/build/scripts/clang_tidy.py
+++ b/build/scripts/clang_tidy.py
@@ -99,10 +99,46 @@ def filter_cmd(cmd):
skip = False
+def walk(p):
+ for a, b, c in os.walk(p):
+ for x in c:
+ yield os.path.join(a, x)
+
+
+def find_header(p, h):
+ for x in walk(p):
+ if x.endswith(h):
+ return os.path.dirname(x)
+
+ raise Exception('can not find inc dir')
+
+
+def fix_cmd(l, bin):
+ sp = '--sysroot='
+
+ for x in l:
+ if '-isystem' in x and '/share/include' in x:
+ # reparent compiler headers dir into clang-tidy install path
+ yield '-isystem' + find_header(os.path.dirname(os.path.dirname(bin)), 'stddef.h')
+ elif x.startswith(sp):
+ yield '-nostdinc'
+ sr = x[len(sp):]
+ yield '-isystem' + sr + '/usr/include'
+ yield '-isystem' + sr + '/usr/include/x86_64-linux-gnu'
+ elif x == '-nostdinc++':
+ if '.c.o' in str(l):
+ pass
+ else:
+ yield x
+ else:
+ yield x
+
+
def main():
args, clang_cmd = parse_args()
if '/wrapcc.py' in str(clang_cmd):
clang_cmd = list(filter_cmd(clang_cmd))
+ clang_cmd = list(fix_cmd(clang_cmd, args.clang_tidy_bin))
setup_script(args)
clang_tidy_bin = args.clang_tidy_bin
output_json = args.tidy_json