Enable orphan checks for all .h files.

Now that there aren't any orphans[1], this change makes it a bit
harder to get more of them by, for instance, unlisting them from
.gn files. The previous check only covered new .h files.

The check will not catch all changes that create orphans,
such as when a file is simply dropped from a gn file. It's hard
to implement this, I believe. It should cover the major cases,
such as when a header moves between dirs.

[1] Depends on https://webrtc-review.googlesource.com/c/src/+/38200.

Bug: None
Change-Id: I6b61ea119a9ca1df6ebf381c0f5f4d8897c18b96
Reviewed-on: https://webrtc-review.googlesource.com/38220
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21544}
This commit is contained in:
Patrik Höglund 2018-01-09 14:22:00 +01:00 committed by Commit Bot
parent 873e5658f1
commit 7e60de2c0e

View file

@ -750,13 +750,18 @@ def CheckOrphanHeaders(input_api, output_api):
# eval-ed and thus doesn't have __file__.
error_msg = """{} should be listed in {}."""
results = []
orphan_blacklist = [
os.path.join('tools_webrtc', 'ios', 'SDK'),
]
with _AddToPath(input_api.os_path.join(
input_api.PresubmitLocalPath(), 'tools_webrtc', 'presubmit_checks_lib')):
from check_orphan_headers import GetBuildGnPathFromFilePath
from check_orphan_headers import IsHeaderInBuildGn
for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
if f.LocalPath().endswith('.h') and f.Action() == 'A':
source_file_filter = lambda x: input_api.FilterSourceFile(
x, black_list=orphan_blacklist)
for f in input_api.AffectedSourceFiles(source_file_filter):
if f.LocalPath().endswith('.h'):
file_path = os.path.abspath(f.LocalPath())
root_dir = os.getcwd()
gn_file_path = GetBuildGnPathFromFilePath(file_path, os.path.exists,