Bug 1469712 - Don't update mtime for backend file during --dry-run; r?Build draft
authorMike Shal <mshal@mozilla.com>
Tue, 19 Jun 2018 17:15:37 -0400
changeset 808532 fa4b9c6f483cf3dcfd9a418cde753873a4cf0664
parent 808416 257c191e7903523a1132e04460a0b2460d950809
push id113415
push userbmo:mshal@mozilla.com
push dateTue, 19 Jun 2018 22:04:24 +0000
reviewersBuild
bugs1469712
milestone62.0a1
Bug 1469712 - Don't update mtime for backend file during --dry-run; r?Build When we do a './mach build-backend --dry-run', no files in the objdir should be written or touched. Updating the mtime of the backend file during dry-run causes a future './mach build' to think that the backend is up-to-date when it is not, which causes an incorrect build. MozReview-Commit-ID: 2NA0rcSGrvL
python/mozbuild/mozbuild/backend/base.py
--- a/python/mozbuild/mozbuild/backend/base.py
+++ b/python/mozbuild/mozbuild/backend/base.py
@@ -169,19 +169,20 @@ class BuildBackend(LoggingMixin):
                 pass
 
         # Write out the list of backend files generated, if it changed.
         if self._deleted_count or self._created_count or \
                 not os.path.exists(list_file):
             with self._write_file(list_file) as fh:
                 fh.write('\n'.join(sorted(self._backend_output_files)))
         else:
-            # Always update its mtime.
-            with open(list_file, 'a'):
-                os.utime(list_file, None)
+            # Always update its mtime if we're not in dry-run mode.
+            if not self.dry_run:
+                with open(list_file, 'a'):
+                    os.utime(list_file, None)
 
         # Write out the list of input files for the backend
         with self._write_file('%s.in' % list_file) as fh:
             fh.write('\n'.join(sorted(
                 mozpath.normsep(f) for f in self.backend_input_files)))
 
     @abstractmethod
     def consume_object(self, obj):