Bug 1425540 - Support --dry-run in the tup backend; r?Build draft
authorMike Shal <mshal@mozilla.com>
Wed, 25 Apr 2018 21:18:39 -0400
changeset 788498 b3291061fb56034bab1817b9a111653efa3104a2
parent 788438 0be8ef04ed899478df11701f8fe23b839bbbdabd
push id108003
push userbmo:mshal@mozilla.com
push dateThu, 26 Apr 2018 15:45:34 +0000
reviewersBuild
bugs1425540, 1454771
milestone61.0a1
Bug 1425540 - Support --dry-run in the tup backend; r?Build Now that bug 1454771 has simplified the TupBackend class, it is much easier to pass in the self.dry_run flag into BackendTupfile to avoid writing out Tupfiles when --dry-run is used. MozReview-Commit-ID: 4WDgXNyYuiQ
python/mozbuild/mozbuild/backend/tup.py
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -55,17 +55,17 @@ from ..frontend.context import (
     ObjDirPath,
 )
 
 
 class BackendTupfile(object):
     """Represents a generated Tupfile.
     """
 
-    def __init__(self, objdir, environment, topsrcdir, topobjdir):
+    def __init__(self, objdir, environment, topsrcdir, topobjdir, dry_run):
         self.topsrcdir = topsrcdir
         self.objdir = objdir
         self.relobjdir = mozpath.relpath(objdir, topobjdir)
         self.environment = environment
         self.name = mozpath.join(objdir, 'Tupfile')
         self.rules_included = False
         self.defines = []
         self.host_defines = []
@@ -77,17 +77,17 @@ class BackendTupfile(object):
         self.sources = defaultdict(list)
         self.host_sources = defaultdict(list)
         self.variables = {}
         self.static_lib = None
         self.shared_lib = None
         self.program = None
         self.exports = set()
 
-        self.fh = FileAvoidWrite(self.name, capture_diff=True)
+        self.fh = FileAvoidWrite(self.name, capture_diff=True, dry_run=dry_run)
         self.fh.write('# THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT.\n')
         self.fh.write('\n')
 
     def write(self, buf):
         self.fh.write(buf)
 
     def include_rules(self):
         if not self.rules_included:
@@ -257,17 +257,18 @@ class TupBackend(CommonBackend):
                                   ensure_exit_code=False,
                                   append_env=self._get_mozconfig_env(config))
 
     def _get_backend_file(self, relobjdir):
         objdir = mozpath.normpath(mozpath.join(self.environment.topobjdir, relobjdir))
         if objdir not in self._backend_files:
             self._backend_files[objdir] = \
                     BackendTupfile(objdir, self.environment,
-                                   self.environment.topsrcdir, self.environment.topobjdir)
+                                   self.environment.topsrcdir, self.environment.topobjdir,
+                                   self.dry_run)
         return self._backend_files[objdir]
 
     def _get_backend_file_for(self, obj):
         return self._get_backend_file(obj.relobjdir)
 
     def _py_action(self, action):
         cmd = [
             '$(PYTHON)',