Commit 9e9a0e96 authored by Findit's avatar Findit

Revert "Grit: Avoid rebuilding all pak files when ID ranges do not change"

This reverts commit 7eefdcbf.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 738454 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtLzdlZWZkY2JmNjNjZDNjOGMzYmNhZTZkNmQ4OTQ2ODM4OWFmOGRiNWMM

Sample Failed Build: https://ci.chromium.org/b/8889318408391750976

Sample Failed Step: compile

Original change's description:
> Grit: Avoid rebuilding all pak files when ID ranges do not change
> 
> We are now generating ID ranges for .grd files as part of the build. The
> tool was already smart enough to leave padding for each range so that
> the ranges would not change for every single resource added / removed.
> However, since it was unconditinoally writing the resource_ids file,
> ninja was considering all grit targets as stale even when ID ranges did
> not change.
> 
> We now write the file only when it is changing so that ninja will not
> consider grit targets stale in the did-not-change case.
> 
> Bug: 979886
> Change-Id: Ib38620e1be097b31ec876be9b07172a7ff945c07
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2036528
> Auto-Submit: Andrew Grieve <agrieve@chromium.org>
> Reviewed-by: Samuel Huang <huangs@chromium.org>
> Commit-Queue: Andrew Grieve <agrieve@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#738454}


Change-Id: I5e0e2bc30ae2a10d5fafb74aef9575c6991573c9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 979886
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2038068
Cr-Commit-Position: refs/heads/master@{#738463}
parent 0d6bc5b7
......@@ -69,9 +69,7 @@ from __future__ import print_function
import collections
import getopt
import os
import shutil
import sys
import tempfile
from grit.tool import interface
from grit.tool.update_resource_ids import assigner, common, parser, reader
......@@ -108,21 +106,12 @@ def _MultiReplace(data, repl):
return ''.join(res)
def _WriteFileIfChanged(output, new_data):
if not output:
def _WriteFile(output, new_data):
if output:
with open(output, 'wt') as fh:
fh.write(new_data)
else:
sys.stdout.write(new_data)
return
# Avoid touching outputs if file contents has not changed so that ninja
# does not rebuild dependent when not necessary.
if os.path.exists(output) and _ReadData(output)[0] == new_data:
return
# Write to a temporary file to ensure atomic changes.
with tempfile.NamedTemporaryFile('wt', delete=False) as f:
f.write(new_data)
f.flush()
shutil.move(f.name, output)
class _Args:
......@@ -299,8 +288,8 @@ Other options:
header.append('# Edit %s instead.' % rel_input_dir)
header.append('#' * 80)
new_data = '\n'.join(header + ['']) + new_data
_WriteFileIfChanged(args.output, new_data)
_WriteFile(args.output, new_data)
if args.depfile:
deps_data = '{}: {}'.format(args.output, ' '.join(sorted(seen_files)))
_WriteFileIfChanged(args.depfile, deps_data)
_WriteFile(args.depfile, deps_data)
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