Bug 1235021 - Move FasterMakeBackend._consume_jar_manifest to CommonBackend. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 24 Dec 2015 18:02:01 +0900
changeset 277925 70708efd7d3b39eb7160ada26bddaab60bc62557
parent 277924 3d25c8199fec736ccbdb13f15865ecad2232bd6f
child 277926 5bea8f924bdd34aebef8f73c9c71a4009272ec6d
push id69650
push usermh@glandium.org
push dateWed, 30 Dec 2015 22:08:21 +0000
treeherdermozilla-inbound@70708efd7d3b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1235021
milestone46.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 1235021 - Move FasterMakeBackend._consume_jar_manifest to CommonBackend. r=gps And do some import cleanup at the same time.
python/mozbuild/mozbuild/backend/common.py
python/mozbuild/mozbuild/backend/fastermake.py
--- a/python/mozbuild/mozbuild/backend/common.py
+++ b/python/mozbuild/mozbuild/backend/common.py
@@ -7,38 +7,48 @@ from __future__ import absolute_import, 
 import itertools
 import json
 import os
 import re
 
 import mozpack.path as mozpath
 import mozwebidlcodegen
 
-from .base import BuildBackend
+from mozbuild.backend.base import BuildBackend
 
-from ..frontend.data import (
+from mozbuild.frontend.context import (
+    Context,
+    Path,
+    RenamedSourcePath,
+    VARIABLES,
+)
+from mozbuild.frontend.data import (
+    ChromeManifestEntry,
     ConfigFileSubstitution,
     ExampleWebIDLInterface,
     IPDLFile,
+    FinalTargetPreprocessedFiles,
+    FinalTargetFiles,
     GeneratedEventWebIDLFile,
     GeneratedWebIDLFile,
     PreprocessedTestWebIDLFile,
     PreprocessedWebIDLFile,
     TestManifest,
     TestWebIDLFile,
     UnifiedSources,
     XPIDLFile,
     WebIDLFile,
 )
+from mozbuild.jar import JarManifestParser
+from mozbuild.preprocessor import Preprocessor
+from mozpack.chrome.manifest import parse_manifest_line
 
 from collections import defaultdict
 
-from ..util import (
-    group_unified_files,
-)
+from mozbuild.util import group_unified_files
 
 class XPIDLManager(object):
     """Helps manage XPCOM IDLs in the context of the build system."""
     def __init__(self, config):
         self.config = config
         self.topsrcdir = config.topsrcdir
         self.topobjdir = config.topobjdir
 
@@ -362,8 +372,98 @@ class CommonBackend(BuildBackend):
             f.write('\n'.join(includeTemplate % { "cppfile": s } for
                               s in source_filenames))
 
     def _write_unified_files(self, unified_source_mapping, output_directory,
                              poison_windows_h=False):
         for unified_file, source_filenames in unified_source_mapping:
             self._write_unified_file(unified_file, source_filenames,
                                      output_directory, poison_windows_h)
+
+    def _consume_jar_manifest(self, obj):
+        # Ideally, this would all be handled somehow in the emitter, but
+        # this would require all the magic surrounding l10n and addons in
+        # the recursive make backend to die, which is not going to happen
+        # any time soon enough.
+        # Notably missing:
+        # - DEFINES from config/config.mk
+        # - L10n support
+        # - The equivalent of -e when USE_EXTENSION_MANIFEST is set in
+        #   moz.build, but it doesn't matter in dist/bin.
+        pp = Preprocessor()
+        if obj.defines:
+            pp.context.update(obj.defines.defines)
+        pp.context.update(self.environment.defines)
+        pp.context.update(
+            AB_CD='en-US',
+            BUILD_FASTER=1,
+        )
+        pp.out = JarManifestParser()
+        pp.do_include(obj.path.full_path)
+        self.backend_input_files |= pp.includes
+
+        for jarinfo in pp.out:
+            jar_context = Context(
+                allowed_variables=VARIABLES, config=obj._context.config)
+            jar_context.push_source(obj._context.main_path)
+            jar_context.push_source(obj.path.full_path)
+
+            install_target = obj.install_target
+            if jarinfo.base:
+                install_target = mozpath.normpath(
+                    mozpath.join(install_target, jarinfo.base))
+            jar_context['FINAL_TARGET'] = install_target
+            if obj.defines:
+                jar_context['DEFINES'] = obj.defines.defines
+            files = jar_context['FINAL_TARGET_FILES']
+            files_pp = jar_context['FINAL_TARGET_PP_FILES']
+
+            for e in jarinfo.entries:
+                if e.is_locale:
+                    if jarinfo.relativesrcdir:
+                        src = '/%s' % jarinfo.relativesrcdir
+                    else:
+                        src = ''
+                    src = mozpath.join(src, 'en-US', e.source)
+                else:
+                    src = e.source
+
+                src = Path(jar_context, src)
+
+                if '*' not in e.source and not os.path.exists(src.full_path):
+                    if e.is_locale:
+                        raise Exception(
+                            '%s: Cannot find %s' % (obj.path, e.source))
+                    if e.source.startswith('/'):
+                        src = Path(jar_context, '!' + e.source)
+                    else:
+                        # This actually gets awkward if the jar.mn is not
+                        # in the same directory as the moz.build declaring
+                        # it, but it's how it works in the recursive make,
+                        # not that anything relies on that, but it's simpler.
+                        src = Path(obj._context, '!' + e.source)
+
+                output_basename = mozpath.basename(e.output)
+                if output_basename != src.target_basename:
+                    src = RenamedSourcePath(jar_context,
+                                            (src, output_basename))
+                path = mozpath.dirname(mozpath.join(jarinfo.name, e.output))
+
+                if e.preprocess:
+                    if '*' in e.source:
+                        raise Exception('%s: Wildcards are not supported with '
+                                        'preprocessing' % obj.path)
+                    files_pp[path] += [src]
+                else:
+                    files[path] += [src]
+
+            if files:
+                self.consume_object(FinalTargetFiles(jar_context, files))
+            if files_pp:
+                self.consume_object(
+                    FinalTargetPreprocessedFiles(jar_context, files_pp))
+
+            for m in jarinfo.chrome_manifests:
+                entry = parse_manifest_line(
+                    mozpath.dirname(jarinfo.name),
+                    m.replace('%', mozpath.basename(jarinfo.name) + '/'))
+                self.consume_object(ChromeManifestEntry(
+                    jar_context, '%s.manifest' % jarinfo.name, entry))
--- a/python/mozbuild/mozbuild/backend/fastermake.py
+++ b/python/mozbuild/mozbuild/backend/fastermake.py
@@ -1,42 +1,29 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, unicode_literals, print_function
 
 from mozbuild.backend.common import CommonBackend
 from mozbuild.frontend.context import (
-    Context,
     ObjDirPath,
-    Path,
-    RenamedSourcePath,
-    VARIABLES,
 )
 from mozbuild.frontend.data import (
     ChromeManifestEntry,
-    ContextDerived,
-    Defines,
     FinalTargetPreprocessedFiles,
     FinalTargetFiles,
     JARManifest,
     XPIDLFile,
 )
-from mozbuild.jar import JarManifestParser
 from mozbuild.makeutil import Makefile
-from mozbuild.preprocessor import Preprocessor
 from mozbuild.util import OrderedDefaultDict
-from mozpack.chrome.manifest import parse_manifest_line
 from mozpack.manifests import InstallManifest
 import mozpack.path as mozpath
-from collections import OrderedDict
-from itertools import chain
-import os
-import sys
 
 
 class FasterMakeBackend(CommonBackend):
     def _init(self):
         super(FasterMakeBackend, self)._init()
 
         self._manifest_entries = OrderedDefaultDict(set)
 
@@ -114,106 +101,16 @@ class FasterMakeBackend(CommonBackend):
 
         elif isinstance(obj, XPIDLFile):
             self._has_xpidl = True
 
         # We currently ignore a lot of object types, so just acknowledge
         # everything.
         return True
 
-    def _consume_jar_manifest(self, obj):
-        # Ideally, this would all be handled somehow in the emitter, but
-        # this would require all the magic surrounding l10n and addons in
-        # the recursive make backend to die, which is not going to happen
-        # any time soon enough.
-        # Notably missing:
-        # - DEFINES from config/config.mk
-        # - L10n support
-        # - The equivalent of -e when USE_EXTENSION_MANIFEST is set in
-        #   moz.build, but it doesn't matter in dist/bin.
-        pp = Preprocessor()
-        if obj.defines:
-            pp.context.update(obj.defines.defines)
-        pp.context.update(self.environment.defines)
-        pp.context.update(
-            AB_CD='en-US',
-            BUILD_FASTER=1,
-        )
-        pp.out = JarManifestParser()
-        pp.do_include(obj.path.full_path)
-        self.backend_input_files |= pp.includes
-
-        for jarinfo in pp.out:
-            jar_context = Context(
-                allowed_variables=VARIABLES, config=obj._context.config)
-            jar_context.push_source(obj._context.main_path)
-            jar_context.push_source(obj.path.full_path)
-
-            install_target = obj.install_target
-            if jarinfo.base:
-                install_target = mozpath.normpath(
-                    mozpath.join(install_target, jarinfo.base))
-            jar_context['FINAL_TARGET'] = install_target
-            if obj.defines:
-                jar_context['DEFINES'] = obj.defines.defines
-            files = jar_context['FINAL_TARGET_FILES']
-            files_pp = jar_context['FINAL_TARGET_PP_FILES']
-
-            for e in jarinfo.entries:
-                if e.is_locale:
-                    if jarinfo.relativesrcdir:
-                        src = '/%s' % jarinfo.relativesrcdir
-                    else:
-                        src = ''
-                    src = mozpath.join(src, 'en-US', e.source)
-                else:
-                    src = e.source
-
-                src = Path(jar_context, src)
-
-                if '*' not in e.source and not os.path.exists(src.full_path):
-                    if e.is_locale:
-                        raise Exception(
-                            '%s: Cannot find %s' % (obj.path, e.source))
-                    if e.source.startswith('/'):
-                        src = Path(jar_context, '!' + e.source)
-                    else:
-                        # This actually gets awkward if the jar.mn is not
-                        # in the same directory as the moz.build declaring
-                        # it, but it's how it works in the recursive make,
-                        # not that anything relies on that, but it's simpler.
-                        src = Path(obj._context, '!' + e.source)
-
-                output_basename = mozpath.basename(e.output)
-                if output_basename != src.target_basename:
-                    src = RenamedSourcePath(jar_context,
-                                            (src, output_basename))
-                path = mozpath.dirname(mozpath.join(jarinfo.name, e.output))
-
-                if e.preprocess:
-                    if '*' in e.source:
-                        raise Exception('%s: Wildcards are not supported with '
-                                        'preprocessing' % obj.path)
-                    files_pp[path] += [src]
-                else:
-                    files[path] += [src]
-
-            if files:
-                self.consume_object(FinalTargetFiles(jar_context, files))
-            if files_pp:
-                self.consume_object(
-                    FinalTargetPreprocessedFiles(jar_context, files_pp))
-
-            for m in jarinfo.chrome_manifests:
-                entry = parse_manifest_line(
-                    mozpath.dirname(jarinfo.name),
-                    m.replace('%', mozpath.basename(jarinfo.name) + '/'))
-                self.consume_object(ChromeManifestEntry(
-                    jar_context, '%s.manifest' % jarinfo.name, entry))
-
     def consume_finished(self):
         mk = Makefile()
         # Add the default rule at the very beginning.
         mk.create_rule(['default'])
         mk.add_statement('TOPSRCDIR = %s' % self.environment.topsrcdir)
         mk.add_statement('TOPOBJDIR = %s' % self.environment.topobjdir)
         mk.add_statement('BACKEND = %s' % self._backend_output_list_file)
         if not self._has_xpidl: