Fix clang-tidy support in CI for meson builds
- As clang and gcc flags have diverged over the years, clang-tidy
requires clang flags to be present in compile-commands.json
which can be generated via a meson build with clang compiler.
- In the current state, the build directory is already created with
gcc, so for a repo with .clang-tidy file, we get a lot of errors
about unknown warning flags[clang-diagnostic-unknown-warning-option]
- This commit would change the compiler to clang++, and would create
another build directory for clang builds, and use that configuration
for clang-tidy.
- This would not harm later builds in the CI sequnce, as they are doing
a meson configure[in build directory] which would not change the
compiler.
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: I8de5a53229bef1dd9b774597d09d39e34e168cdb
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index b15d0c8..190b7a1 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -944,8 +944,10 @@
# Run clang-tidy only if the project has a configuration
if os.path.isfile('.clang-tidy'):
+ os.environ["CXX"] = "clang++"
+ check_call_cmd('meson', 'setup', 'build-clang')
check_call_cmd('run-clang-tidy.py', '-p',
- 'build')
+ 'build-clang')
# Run the basic clang static analyzer otherwise
else:
check_call_cmd('ninja', '-C', 'build',