Update apply-iwyu tool to report compile errors
Note: apply-iwyu on a lone .h file *will* fail due to c++/c confusion.
Bug: none
Change-Id: I3dda0df28cd4ec85ecb895efed1b04c3d70343bb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212680
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33525}
diff --git a/tools_webrtc/iwyu/apply-iwyu b/tools_webrtc/iwyu/apply-iwyu
index 691ca8e..a26f46b 100755
--- a/tools_webrtc/iwyu/apply-iwyu
+++ b/tools_webrtc/iwyu/apply-iwyu
@@ -33,11 +33,22 @@
FILE_H=""
fi
+# IWYU has a confusing set of exit codes. Discard it.
iwyu -Xiwyu --no_fwd_decls -D__X86_64__ -DWEBRTC_POSIX -I . \
-I third_party/abseil-cpp \
-I third_party/googletest/src/googlemock/include \
-I third_party/googletest/src/googletest/include \
- $FILE_CC |& fix_include || echo "Some files modified"
+ $FILE_CC >& /tmp/includefixes$$ || echo "IWYU done, code $?"
+
+if grep 'fatal error' /tmp/includefixes$$; then
+ echo "iwyu run failed"
+ cat /tmp/includefixes$$
+ rm /tmp/includefixes$$
+ exit 1
+else
+ fix_include < /tmp/includefixes$$ || echo "Some files modified"
+ rm /tmp/includefixes$$
+fi
if [ $REMOVE_CC_INCLUDES == "yes" ]; then
if [ -n "$FILE_H" ]; then