-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ccache in the clang-tidy CI. This allows us to skip clang-tidy checks on files that are not changed as reported by ccache.
- Loading branch information
1 parent
f1eb2b2
commit 35d96f4
Showing
2 changed files
with
85 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" | ||
A script processing ccache log file to make Make file for Clang-Tidy | ||
This generates a makefile for clang-tidying ccache-cache-missing files. This | ||
could be used to speed up clang-tidy in CIs. | ||
""" | ||
|
||
import argparse, re, sys | ||
|
||
def makeMakefileForClangTidy(argv): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--input", | ||
help="Ccache log file", | ||
default="ccache.log.txt") | ||
parser.add_argument("--identifier", | ||
help="Unique identifier for finding compilation line in the log file", | ||
default="WarpX/Source") | ||
# We assume Src/Base can be used as an identifier to distinguish amrex code | ||
# from cmake's temporary files like build/CMakeFiles/CMakeScratch/TryCompile-hw3x4m/test_mpi.cpp | ||
parser.add_argument("--output", | ||
help="Make file for clang-tidy", | ||
default="clang-tidy-ccache-misses.mak") | ||
args = parser.parse_args() | ||
|
||
fin = open(args.input, "r") | ||
fout = open(args.output, "w") | ||
|
||
fout.write("CLANG_TIDY ?= clang-tidy\n") | ||
fout.write("override CLANG_TIDY_ARGS += --extra-arg=-Wno-unknown-warning-option --extra-arg-before=--driver-mode=g++\n") | ||
fout.write("\n") | ||
|
||
fout.write(".SECONDEXPANSION:\n") | ||
fout.write("clang-tidy: $$(all_targets)\n") | ||
fout.write("\t@echo SUCCESS\n\n") | ||
|
||
exe_re = re.compile(r" Executing .*? (-.*{}.*) -c .* -o .* (\S*)".format(args.identifier)) | ||
|
||
count = 0 | ||
for line in fin.readlines(): | ||
ret_exe_re = exe_re.search(line) | ||
if (ret_exe_re): | ||
fout.write("target_{}: {}\n".format(count, ret_exe_re.group(2))) | ||
fout.write("\t$(CLANG_TIDY) $(CLANG_TIDY_ARGS) $< -- {}\n".format | ||
(ret_exe_re.group(1))) | ||
fout.write("\ttouch target_{}\n\n".format(count)) | ||
count = count + 1 | ||
|
||
fout.write("all_targets =") | ||
for i in range(count): | ||
fout.write(" target_{}".format(i)) | ||
fout.write("\n\n") | ||
|
||
fout.write("clean:\n\t$(RM) $(all_targets)\n\n") | ||
|
||
fout.close() | ||
fin.close() | ||
|
||
if __name__ == "__main__": | ||
makeMakefileForClangTidy(sys.argv) |