Bug 1371871 - Do not generate or attempt to install unnecessary files in artifact builds in the Tup backend. draft
authorChris Manchester <cmanchester@mozilla.com>
Wed, 21 Jun 2017 16:20:18 -0700
changeset 598643 bd70e883329d5d5ccd49e753f4b6a4b9c5a27539
parent 598642 779f4c88788701df1a60ba2438b7130a992c891d
child 598644 cbce12ec8e2232811a0500a531d8a50ca6d08c4b
push id65269
push userbmo:cmanchester@mozilla.com
push dateWed, 21 Jun 2017 23:20:46 +0000
bugs1371871
milestone56.0a1
Bug 1371871 - Do not generate or attempt to install unnecessary files in artifact builds in the Tup backend. MozReview-Commit-ID: B2zyhKD4gVt
python/mozbuild/mozbuild/backend/tup.py
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -126,16 +126,24 @@ class TupOnly(CommonBackend, PartialBack
     """
 
     def _init(self):
         CommonBackend._init(self)
 
         self._backend_files = {}
         self._cmd = MozbuildObject.from_environment()
         self._manifest_entries = OrderedDefaultDict(set)
+        self._compile_env_gen_files = (
+            '*.c',
+            '*.cpp',
+            '*.h',
+            '*.inc',
+            '*.py',
+            '*.rs',
+        )
 
         # This is a 'group' dependency - All rules that list this as an output
         # will be built before any rules that list this as an input.
         self._installed_files = '$(MOZ_OBJ_ROOT)/<installed-files>'
 
     def _get_backend_file(self, relativedir):
         objdir = mozpath.join(self.environment.topobjdir, relativedir)
         srcdir = mozpath.join(self.environment.topsrcdir, relativedir)
@@ -169,19 +177,23 @@ class TupOnly(CommonBackend, PartialBack
         backend_file = self._get_backend_file_for(obj)
 
         if isinstance(obj, GeneratedFile):
             # These files are already generated by make before tup runs.
             skip_files = (
                 'buildid.h',
                 'source-repo.h',
             )
-            if any(f in skip_files for f in obj.outputs):
-                # Let the RecursiveMake backend handle these.
-                return False
+
+            if self.environment.is_artifact_build:
+                skip_files = skip_files + self._compile_env_gen_files
+
+            for f in obj.outputs:
+                if any(mozpath.match(f, p) for p in skip_files):
+                    return False
 
             if 'application.ini.h' in obj.outputs:
                 # application.ini.h is a special case since we need to process
                 # the FINAL_TARGET_PP_FILES for application.ini before running
                 # the GENERATED_FILES script, and tup doesn't handle the rules
                 # out of order.
                 backend_file.delayed_generated_files.append(obj)
             else:
@@ -339,16 +351,22 @@ class TupOnly(CommonBackend, PartialBack
                             finder = FileFinder(prefix)
                             for p, _ in finder.find(f.full_path[len(prefix):]):
                                 backend_file.symlink_rule(mozpath.join(prefix, p),
                                                           output=mozpath.join(f.target_basename, p),
                                                           output_group=self._installed_files)
                     else:
                         backend_file.symlink_rule(f.full_path, output=f.target_basename, output_group=self._installed_files)
                 else:
+                    if (self.environment.is_artifact_build and
+                        any(mozpath.match(f.target_basename, p) for p in self._compile_env_gen_files)):
+                        # If we have an artifact build we never would have generated this file,
+                        # so do not attempt to install it.
+                        continue
+
                     # We're not generating files in these directories yet, so
                     # don't attempt to install files generated from them.
                     if f.context.relobjdir not in ('layout/style/test',
                                                    'toolkit/library'):
                         output = mozpath.join('$(MOZ_OBJ_ROOT)', target, path,
                                               f.target_basename)
                         gen_backend_file = self._get_backend_file(f.context.relobjdir)
                         gen_backend_file.symlink_rule(f.full_path, output=output,