Only run "gn check" on binary targets. We ran into a case where a copy step triggered a check failure because the source of a copy had a .h extension. But copy targets should not trigger header checking. This change excludes non-binary targets from checking altogether. Writing a test for this ended up being quite involved. The existing header checker tests all tie in at a lower layer to avoid complicated dependencies on real files. In the end, I decided the benefit of a test for this check is not worth the added complexity (and potential flakiness) of adding a new class of check tests that use actual files. Change-Id: I819db52d791cf3b4683fca584937f16ec4a14200 Reviewed-on: https://chromium-review.googlesource.com/899930 Commit-Queue: Brett Wilson <brettw@chromium.org> Reviewed-by: Scott Graham <scottmg@chromium.org> Reviewed-by: Dirk Pranke <dpranke@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#534416} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: b46dd8bef522b08b069db7d42506bc416b555f34
diff --git a/tools/gn/header_checker.cc b/tools/gn/header_checker.cc index ac8214b..c47e6f1 100644 --- a/tools/gn/header_checker.cc +++ b/tools/gn/header_checker.cc
@@ -126,8 +126,12 @@ bool force_check, std::vector<Err>* errors) { FileMap files_to_check; - for (auto* check : to_check) - AddTargetToFileMap(check, &files_to_check); + for (auto* check : to_check) { + // This function will get called with all target types, but check only + // applies to binary targets. + if (check->IsBinary()) + AddTargetToFileMap(check, &files_to_check); + } RunCheckOverFiles(files_to_check, force_check); if (errors_.empty())