Bug 1319223 - Handle ChromeManifestEntry objects in the tup backend. r=mshal draft
authorChris Manchester <cmanchester@mozilla.com>
Wed, 07 Jun 2017 14:35:38 -0700
changeset 590610 ee40f43a61560584ab03b63eae0f5c03d2c5c0e0
parent 590317 a49112c7a5765802096b3fc298069b9495436107
child 590611 ec85bd7bccb2f68492d71bf06172ea2a5407ffb4
push id62800
push userbmo:cmanchester@mozilla.com
push dateWed, 07 Jun 2017 23:32:56 +0000
reviewersmshal
bugs1319223
milestone55.0a1
Bug 1319223 - Handle ChromeManifestEntry objects in the tup backend. r=mshal The approach here is similar to the FasterMake backend, but rather than writing out manifest entries to a backend file to be written out during the build we write the manifests to their final location within the build backend. MozReview-Commit-ID: L7EPwxyFtWX
python/mozbuild/mozbuild/backend/tup.py
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -6,19 +6,21 @@ from __future__ import absolute_import, 
 
 import os
 
 import mozpack.path as mozpath
 from mozbuild.base import MozbuildObject
 from mozbuild.backend.base import PartialBackend, HybridBackend
 from mozbuild.backend.recursivemake import RecursiveMakeBackend
 from mozbuild.shellutil import quote as shell_quote
+from mozbuild.util import OrderedDefaultDict
 
 from .common import CommonBackend
 from ..frontend.data import (
+    ChromeManifestEntry,
     ContextDerived,
     Defines,
     FinalTargetFiles,
     FinalTargetPreprocessedFiles,
     GeneratedFile,
     HostDefines,
     JARManifest,
     ObjdirFiles,
@@ -119,16 +121,17 @@ class TupOnly(CommonBackend, PartialBack
     """Backend that generates Tupfiles for the tup build system.
     """
 
     def _init(self):
         CommonBackend._init(self)
 
         self._backend_files = {}
         self._cmd = MozbuildObject.from_environment()
+        self._manifest_entries = OrderedDefaultDict(set)
 
         # 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)
@@ -174,32 +177,47 @@ class TupOnly(CommonBackend, PartialBack
             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:
                 self._process_generated_file(backend_file, obj)
+        elif (isinstance(obj, ChromeManifestEntry) and
+              obj.install_target.startswith('dist/bin')):
+            top_level = mozpath.join(obj.install_target, 'chrome.manifest')
+            if obj.path != top_level:
+                entry = 'manifest %s' % mozpath.relpath(obj.path,
+                                                        obj.install_target)
+                self._manifest_entries[top_level].add(entry)
+            self._manifest_entries[obj.path].add(str(obj.entry))
         elif isinstance(obj, Defines):
             self._process_defines(backend_file, obj)
         elif isinstance(obj, HostDefines):
             self._process_defines(backend_file, obj, host=True)
         elif isinstance(obj, FinalTargetFiles):
             self._process_final_target_files(obj)
         elif isinstance(obj, FinalTargetPreprocessedFiles):
             self._process_final_target_pp_files(obj, backend_file)
         elif isinstance(obj, JARManifest):
             self._consume_jar_manifest(obj)
 
         return True
 
     def consume_finished(self):
         CommonBackend.consume_finished(self)
 
+        # The approach here is similar to fastermake.py, but we
+        # simply write out the resulting files here.
+        for target, entries in self._manifest_entries.iteritems():
+            with self._write_file(mozpath.join(self.environment.topobjdir,
+                                               target)) as fh:
+                fh.write(''.join('%s\n' % e for e in sorted(entries)))
+
         for objdir, backend_file in sorted(self._backend_files.items()):
             for obj in backend_file.delayed_generated_files:
                 self._process_generated_file(backend_file, obj)
             with self._write_file(fh=backend_file):
                 pass
 
         with self._write_file(mozpath.join(self.environment.topobjdir, 'Tuprules.tup')) as fh:
             acdefines = [name for name in self.environment.defines