Finish making clang-tidy (mostly) work (again) and run -fix (#2312)

This does some more work to the run_clang_tidy.py wrapper script, and runs an example pass.

"again" because it's really the proto fuzzer changes that broke it, it had been working before.

"mostly" because there's still an issue within the proto fuzzer that it can't find "port/protobuf.h", i.e. https://github.com/google/libprotobuf-mutator/tree/master/port, but I'm still hesitant to add an include path there.
This commit is contained in:
Jon Ross-Perkins
2022-10-18 15:48:17 -07:00
committed by GitHub
parent 561e45033e
commit 4d522c8e90
31 changed files with 176 additions and 141 deletions
+8 -10
View File
@@ -57,7 +57,7 @@ print("Building compilation database...")
# stand-alone files. This is a bit simpler than scraping the actual compile
# actions and allows us to directly index header-only libraries easily and
# pro-actively index the specific headers in the project.
source_files_query = subprocess.run(
source_files_query = subprocess.check_output(
[
bazel,
"query",
@@ -67,11 +67,9 @@ source_files_query = subprocess.run(
"--incompatible_display_source_file_location",
'filter(".*\\.(h|cpp|cc|c|cxx)$", kind("source file", deps(//...)))',
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
universal_newlines=True,
).stdout
)
source_files = [
Path(line.split(":")[0]) for line in source_files_query.splitlines()
]
@@ -98,7 +96,7 @@ print(
# Now collect the generated file labels.
# cc_proto_library generates files, but they aren't seen with "generated file".
generated_file_labels = subprocess.run(
generated_file_labels = subprocess.check_output(
[
bazel,
"query",
@@ -111,23 +109,21 @@ generated_file_labels = subprocess.run(
'kind("cc_proto_library", deps(//...))'
),
],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
universal_newlines=True,
).stdout.splitlines()
).splitlines()
print("Found %d generated files..." % (len(generated_file_labels),))
# Directly build these labels so that indexing can find them. Allow this to
# fail in case there are build errors in the client, and just warn the user
# that they may be missing generated files.
print("Building the generated files so that tools can find them...")
subprocess.run([bazel, "build", "--keep_going"] + generated_file_labels)
subprocess.check_call([bazel, "build", "--keep_going"] + generated_file_labels)
# Also build some specific targets that depend on external packages so those are
# fetched and linked into the Bazel execution root. We try to use cheap files
# where possible, but in some cases need to create a virtual include directory.
subprocess.run(
subprocess.check_call(
[
bazel,
"build",
@@ -137,6 +133,8 @@ subprocess.run(
"@com_google_googletest//:LICENSE",
"@com_googlesource_code_re2//:LICENSE",
"@com_github_google_benchmark//:benchmark",
"@com_google_libprotobuf_mutator//:LICENSE",
"@com_google_protobuf//:any_proto",
]
)