Skip to content

Commit 2eefe03

Browse files
build: Add ./ns3 run "clang-tidy -fix" to check clang-tidy warnings and apply automatic fixes
1 parent 5c486e3 commit 2eefe03

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

ns3

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,6 +2070,27 @@ def main():
20702070
elif ".py" in target_to_run and os.path.exists(target_to_run):
20712071
# We let python scripts pass to be able to run ./utils/python-unit-tests.py
20722072
pass
2073+
elif "clang-tidy" in target_to_run:
2074+
clang_tidy_versions = [
2075+
"run-clang-tidy",
2076+
*[f"run-clang-tidy-{x}" for x in range(15, 21)],
2077+
]
2078+
clang_tidy_versions = list(map(lambda x: shutil.which(x), clang_tidy_versions))
2079+
clang_tidy_versions = list(filter(lambda x: x, clang_tidy_versions))
2080+
if not clang_tidy_versions:
2081+
raise Exception(
2082+
"Clang-tidy not found; please install version 15.0.0 or greater, or modify the PATH environment variable"
2083+
)
2084+
target_to_run = clang_tidy_versions[-1]
2085+
target_args = [
2086+
"-p",
2087+
current_cmake_cache_folder,
2088+
"-quiet",
2089+
"-format",
2090+
"-warnings-as-errors=*",
2091+
] + target_args
2092+
run_only = True
2093+
build_and_run = False
20732094
else:
20742095
raise Exception("Couldn't find the specified program: %s" % target_to_run)
20752096

0 commit comments

Comments
 (0)