From 2ff25db72aa34a20308e82a271260b8719da0254 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Mon, 22 Mar 2021 11:43:51 +0000 Subject: [PATCH] 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 Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/master@{#33525} --- tools_webrtc/iwyu/apply-iwyu | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools_webrtc/iwyu/apply-iwyu b/tools_webrtc/iwyu/apply-iwyu index 691ca8ef7e..a26f46b933 100755 --- a/tools_webrtc/iwyu/apply-iwyu +++ b/tools_webrtc/iwyu/apply-iwyu @@ -33,11 +33,22 @@ else 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