Commit c2ee9c6a authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[iwyu] Avoid overwriting source file with same content

The generate-header-include-checks.py script generates the cc files to
check that headers can be included in isolation. It currently always
writes to all the cc files. This means that after "gclient runhooks",
all these files have to be recompiled.
This CL fixes this by not touching the file if it already contains the
expected content. This avoids hundreds of recompilations after running
the hook.

R=machenbach@chromium.org

Bug: v8:7965
Change-Id: I93a0abb936863f6c21ed22ba1b7d900b96725fa3
Reviewed-on: https://chromium-review.googlesource.com/1156514
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54858}
parent 92220026
......@@ -121,12 +121,19 @@ def get_cc_file_name(header):
def create_including_cc_files(header_files):
comment = 'check including this header in isolation'
for header in header_files:
cc_file_name = get_cc_file_name(header)
printv('Creating file {}'.format(os.path.relpath(cc_file_name, V8_DIR)))
rel_cc_file_name = os.path.relpath(cc_file_name, V8_DIR)
content = '#include "{}" // {}\n'.format(header, comment)
if os.path.exists(cc_file_name):
with open(cc_file_name) as cc_file:
if cc_file.read() == content:
printv('File {} is up to date'.format(rel_cc_file_name))
continue
printv('Creating file {}'.format(rel_cc_file_name))
with open(cc_file_name, 'w') as cc_file:
cc_file.write('#include "{}" // check including this header in '
'isolation\n'.format(header))
cc_file.write(content)
def generate_gni(header_files):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment