[presubmit] Handle Windows path for header guard check

AffectedFile.LocalPath returns a path with backward slashes in Windows. Update the presubmit script to handle this case properly.

Bug: v8:13582
Change-Id: Iabc46ded5a8448e5d373679162108f94846c06e9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4099007
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Choongwoo Han <choongwoo.han@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#84819}
This commit is contained in:
Choongwoo Han 2022-12-12 14:59:19 -08:00 committed by V8 LUCI CQ
parent a40734b3cc
commit fd8a89af75

View File

@ -261,8 +261,9 @@ def _CheckHeadersHaveIncludeGuards(input_api, output_api):
files_to_check=(file_inclusion_pattern, ),
files_to_skip=files_to_skip)
leading_src_pattern = input_api.re.compile(r'^src/')
dash_dot_slash_pattern = input_api.re.compile(r'[-./]')
leading_src_pattern = input_api.re.compile(r'^src[\\\/]')
dash_dot_slash_pattern = input_api.re.compile(r'[-.\\\/]')
def PathToGuardMacro(path):
"""Guards should be of the form V8_PATH_TO_FILE_WITHOUT_SRC_H_."""
x = input_api.re.sub(leading_src_pattern, 'v8_', path)