Bug 1425540 - Support --dry-run in the tup backend; r=chmanchester
authorMike Shal <mshal@mozilla.com>
Wed, 25 Apr 2018 21:18:39 -0400
changeset 471945 9a020203cc6fca59853fb4f3e92eff9590896cc3
parent 471944 5af5821aa84c8f73fdf1d1802b3eea717fc4c8a4
child 471946 e720e80865b2efc109a95d0607e338526a2f1030
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1425540, 1454771
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1425540 - Support --dry-run in the tup backend; r=chmanchester 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)',