Use clang-include-cleaner from the llvm clangd package.

Also change the generation of compile_commands.json so that it
does not include reclient arguments.

Bug: webrtc:15874
Change-Id: I1bc2e7a8768a3467d31528d584f7e70d946a3301
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/347900
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42110}
diff --git a/tools_webrtc/iwyu/apply-include-cleaner b/tools_webrtc/iwyu/apply-include-cleaner
index 2ba11b7..a68f882 100755
--- a/tools_webrtc/iwyu/apply-include-cleaner
+++ b/tools_webrtc/iwyu/apply-include-cleaner
@@ -11,12 +11,31 @@
 # "tools/clang/scripts/generate_compdb.py -p path/to/out > compile_commands.json"
 # If "out/Default" exists, the script will attempt to generate it for you.
 #
-# To get include-cleaner:
-# - in google3: define an alias and/or point to it below
-# - in debian distros: sudo apt install clang-tools-17 (or later, and fix below)
-# Ignore errors of the type "this argument doesn't exist".
+# clang-include-cleaner is built as part of the "clangd" package in our
+# LLVM build.
+# Example .gclient file:
+# solutions = [
+#  {
+#    "name": "src",
+#    "url": "https://webrtc.googlesource.com/src.git",
+#    "deps_file": "DEPS",
+#    "managed": False,
+#    "custom_deps": {},
+#    "custom_vars" : {
+#      "checkout_clangd": True,
+#      "download_remoteexec_cfg" : True,
+#    }
+#  },
+# ]
 
-CLEANER=/usr/bin/clang-include-cleaner-17
+
+CLEANER=third_party/llvm-build/Release+Asserts/bin/clang-include-cleaner
+if [ ! -x $CLEANER ]; then
+  echo "clang-include-cleaner not found"
+  echo -n "Add '\"checkout_clangd\": True' to 'custom_vars' in your"
+  echo ".gclient file and run 'gclient sync'."
+  exit 1
+fi
 
 # Debug level, also controlled by the "-d" argument.
 # Set this to 1 to get more debug information.
@@ -63,7 +82,7 @@
   if [ -d "$WORKDIR" ]; then
     if [ ! -f "$WORKDIR/compile_commands.json" ]; then
       echo "Generating compile commands file"
-      gn gen --export-compile-commands $WORKDIR
+      tools/clang/scripts/generate_compdb.py -p $WORKDIR > $WORKDIR/compile_commands.json
     fi
     COMPILE_COMMANDS="$WORKDIR/compile_commands.json"
   else
@@ -78,7 +97,7 @@
 fi
 
 cd $WORKDIR
-$CLEANER $INCLUDE_ARGS $COMMAND ../../$FILE
+../../$CLEANER $INCLUDE_ARGS $COMMAND ../../$FILE
 
 echo "Finished. Check diff, compile, gn gen --check and git cl format"
 echo "before uploading."