diff options
author | Klaus T. Aehlig <aehlig@linta.de> | 2025-06-13 16:31:32 +0200 |
---|---|---|
committer | Klaus T. Aehlig <aehlig@linta.de> | 2025-06-16 17:23:33 +0200 |
commit | febe0937cf4394bc0f908e13fd0b6ab63b2c29c2 (patch) | |
tree | 55eed881e2efe188299fb741d09e14f2bab13397 | |
parent | a78bd0abe451cde450bbc1eb56c1450b350dc255 (diff) | |
download | justbuild-febe0937cf4394bc0f908e13fd0b6ab63b2c29c2.tar.gz |
clang-tidy: use bundled header files
A typical compiler implicitly adds some search directories for system headers; those
might not be obvious for the bootstrapped clang-tidy. Therefore, use the bundled
headers of the clang toolchain. This has the additional advantage, that everyone
uses the same system headers for linting.
-rwxr-xr-x | lint/run_clang_tidy.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lint/run_clang_tidy.py b/lint/run_clang_tidy.py index 3fb8a595..7f48e007 100755 --- a/lint/run_clang_tidy.py +++ b/lint/run_clang_tidy.py @@ -19,6 +19,7 @@ import shutil import subprocess import sys +CXX_LIB_VERSION = "13.3.0" def dump_meta(src, cmd): OUT = os.environ.get("OUT") @@ -31,7 +32,24 @@ def run_lint(src, cmd): dump_meta(src, cmd) config = os.environ.get("CONFIG") shutil.copyfile(os.path.join(config, ".clang-tidy"), ".clang-tidy") - extra = ["-Wno-unused-command-line-argument"] + extra = [ "-Wno-unused-command-line-argument"] + + # add include paths from the bundled toolchain + baseincludepath = os.path.join( + config, "toolchain", "include", "c++", CXX_LIB_VERSION + ) + # We're using the native toolchain, so arch-specific headers are + # only available for one arch. Hence we can try all supported candidates + # and add the ones found + for arch in ["x86_64", "arm"]: + idir = os.path.join(baseincludepath, + "%s-pc-linux-gnu" % (arch,)) + if os.path.exists(idir): + extra += ["-isystem", idir] + extra += [ + "-isystem", baseincludepath, + ] + if src.endswith(".tpp"): extra += ["-x", "c++"] db = [{ |