Explorar o código

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>
Jaakko Manninen hai 7 meses
pai
achega
1003acba8f
Modificáronse 1 ficheiros con 12 adicións e 2 borrados
  1. 12 2
      gclient.py

+ 12 - 2
gclient.py

@@ -1431,8 +1431,18 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
         if self._use_relative_paths:
         if self._use_relative_paths:
             path_prefix = os.path.join(path_prefix, self.name)
             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
     @gclient_utils.lockedmethod
     def _run_is_done(self, file_list):
     def _run_is_done(self, file_list):