IWYU: process a list of files

for easy integration with
  git diff-tree --no-commit-id --name-only -r HEAD
which gets the list of files in a commit

BUG=webrtc:42226242

Change-Id: I6e80d0f13e4f182d7c0c9c8ea971f6e48fbaae76
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/370461
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43589}
This commit is contained in:
Philipp Hancke 2024-12-09 10:35:40 -08:00 committed by WebRTC LUCI CQ
parent 0dec0897f1
commit 588dbe6fa7

View File

@ -55,8 +55,8 @@ error() {
WORKDIR=out/Default WORKDIR=out/Default
usage() { usage() {
echo "Usage: $0 [-r] file.cc" echo "Usage: $0 [-r] file.cc [file2.cc ...]"
echo "Runs the include-cleaner tool on a file" echo "Runs the include-cleaner tool on a list of files"
echo "Arguments:" echo "Arguments:"
echo " -n : Just print changes, don't do them" echo " -n : Just print changes, don't do them"
echo " -c : Just return non-zero exit code if there are changes, don't do them" echo " -c : Just return non-zero exit code if there are changes, don't do them"
@ -95,13 +95,18 @@ if [[ -z "$COMPILE_COMMANDS" ]]; then
fi fi
fi fi
FILE="$1" # To get a list of files in a commit: git diff-tree --no-commit-id --name-only -r HEAD
for FILE in "$@"
do
if [ -z $FILE ] || [ ! -f $FILE ]; then if [ -z $FILE ] || [ ! -f $FILE ]; then
usage usage
error "File $FILE is not found" error "File $FILE is not found"
fi fi
done
HAS_OUTPUT=false
for FILE in "$@"
do
# Run the command in $WORKDIR because of this reported issue: # Run the command in $WORKDIR because of this reported issue:
# https://github.com/llvm/llvm-project/issues/110843 # https://github.com/llvm/llvm-project/issues/110843
cd $WORKDIR cd $WORKDIR
@ -128,6 +133,9 @@ for INCLUDE in "gtest" "gmock"; do
done done
echo "${OUTPUT}" echo "${OUTPUT}"
HAS_OUTPUT=$HAS_OUTPUT || [[ ! -z $OUTPUT ]]
done
echo "Finished. Check diff, compile, gn gen --check and git cl format" echo "Finished. Check diff, compile, gn gen --check and git cl format"
echo "before uploading." echo "before uploading."