Bug 1319223 - Handle ChromeManifestEntry objects in the tup backend. r=mshal
authorChris Manchester <cmanchester@mozilla.com>
Wed, 07 Jun 2017 14:35:38 -0700
changeset 411189 f0fc4ee3e6552758fe7a1865fe3d3a8043d7ac12
parent 411188 f274f4c10a926af50621b79daf6f9c28fb5e8a8e
child 411190 0900434f24159cea6699b4f5db57b23425208686
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1319223
milestone55.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 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