Skip writing gclient_args.gni if contents are unchanged to avoid causing rebuild

Running a gclient sync will touch the gclient_args.gni even if unchanged,
especially on Windows resulting in an unnecessarily large rebuild of
around 20k items. This skips writing the file if the contents are identical
to what we're about to write.

R=jojwang@google.com, sokcevic@chromium.org

Change-Id: Iccf3fc8eeeb114fdf29bf944a8204e47489bc0a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6157476
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Junji Watanabe <jwata@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
changes/76/6157476/4
Jaakko Manninen 4 months ago committed by LUCI CQ
parent af68505dfe
commit 1003acba8f

@ -1431,8 +1431,18 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
if self._use_relative_paths:
path_prefix = os.path.join(path_prefix, self.name)
with open(os.path.join(path_prefix, self._gn_args_file), 'wb') as f:
f.write('\n'.join(lines).encode('utf-8', 'replace'))
gn_args_path = os.path.join(path_prefix, self._gn_args_file)
new_content = '\n'.join(lines).encode('utf-8', 'replace')
if os.path.exists(gn_args_path):
with open(gn_args_path, 'rb') as f:
old_content = f.read()
if old_content == new_content:
return
with open(gn_args_path, 'wb') as f:
f.write(new_content)
@gclient_utils.lockedmethod
def _run_is_done(self, file_list):

Loading…
Cancel
Save