Run clang-tidy builds on clang

As-is, clang-tidy uses the default compile-commands.json from the gcc
build.  Unfortunately, gcc implements different flags than clang these
days, and clang-tidy requires the clang flags.  Because of that, we need
to use a clang-specific compile-commands.json.

This commit adds a new build dir named tidy-build, and runs the cmake
configure task in it against the clang compilers.

Note, the hope is that this change allows something like this:
https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/36888

To succeed in CI.

Having this build run correctly will help me as a maintainer.  I'm
guessing that clang-tidy will correctly flag 50% of the common mistakes
people make in bmcweb.  I intend to get this running on entity-manager
and dbus-sensors repos as well.

Tested:
Ran ./openbmc-build-scripts/run-unit-test-docker.sh against this
patchset: https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/36888

... and observed clang-tidy run correctly.  clang-tidy did not pass
because of actual found issues (most of which are in review to be
fixed), but correctly ran clang-tidy, and identified a bunch of issues,
which is glorious.

Signed-off-by: Ed Tanous <ed@tanous.net>
Change-Id: I0f0754f2026e1cf2ae9ca7df868f9022d6585c32
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index 8583ae9..dbca46f 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -731,7 +731,18 @@
             return
 
         if os.path.isfile('.clang-tidy'):
-            check_call_cmd('run-clang-tidy-10.py', '-p', '.')
+            os.mkdir("tidy-build")
+            os.chdir("tidy-build")
+            try:
+                # clang-tidy needs to run on a clang-specific build
+                check_call_cmd('cmake', '-DCMAKE_C_COMPILER=clang',
+                               '-DCMAKE_CXX_COMPILER=clang++',
+                               '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '..')
+
+                check_call_cmd('run-clang-tidy-10.py', '-p', '.')
+            finally:
+                os.chdir("..")
+
         maybe_make_valgrind()
         maybe_make_coverage()
         run_cppcheck()