diff --git a/tools_webrtc/iwyu/apply-include-cleaner b/tools_webrtc/iwyu/apply-include-cleaner index 2ba11b7c75..a68f882655 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 [[ -z "$COMPILE_COMMANDS" ]]; then 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 @@ if [ ! -f $FILE ]; then 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."