Bug 1235021 - Re-emit FinalTarget{,Preprocessed}Files from the jar manifest handler code in the FasterMake backend. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 24 Dec 2015 17:23:09 +0900
changeset 278029 dc3037f69b58e579a69d1c83925fb2205fb962a8
parent 278028 a99b3de8d858141e9846e78d5ea7314732d1f114
child 278030 3d25c8199fec736ccbdb13f15865ecad2232bd6f
push id29841
push userryanvm@gmail.com
push dateSat, 02 Jan 2016 00:29:52 +0000
treeherdermozilla-central@f7fbc524f9f3 [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 - Re-emit FinalTarget{,Preprocessed}Files from the jar manifest handler code in the FasterMake backend. r=gps Like with ChromeManifestEntries, reloop in consume_object, with the double goal of allowing to reuse the jar manifest handler code in other backends and avoid code duplication in the FasterMake backend itself when support for e.g. GeneratedFiles is added.
python/mozbuild/mozbuild/backend/fastermake.py
--- a/python/mozbuild/mozbuild/backend/fastermake.py
+++ b/python/mozbuild/mozbuild/backend/fastermake.py
@@ -2,17 +2,19 @@
 # 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,
@@ -75,21 +77,38 @@ class FasterMakeBackend(CommonBackend):
                               FinalTargetPreprocessedFiles)) and \
                 obj.install_target.startswith('dist/bin'):
             for path, files in obj.files.walk():
                 for f in files:
                     if isinstance(obj, FinalTargetPreprocessedFiles):
                         self._add_preprocess(obj, f.full_path, path,
                                              target=f.target_basename,
                                              defines=defines)
+                    elif '*' in f:
+                        def _prefix(s):
+                            for p in mozpath.split(s):
+                                if '*' not in p:
+                                    yield p + '/'
+                        prefix = ''.join(_prefix(f.full_path))
+
+                        self._install_manifests[obj.install_target] \
+                            .add_pattern_symlink(
+                                prefix,
+                                f.full_path[len(prefix):],
+                                mozpath.join(path, f.target_basename))
                     else:
                         self._install_manifests[obj.install_target].add_symlink(
                             f.full_path,
                             mozpath.join(path, f.target_basename)
                         )
+                    if isinstance(f, ObjDirPath):
+                        dep_target = 'install-%s' % obj.install_target
+                        self._dependencies[dep_target].append(
+                            mozpath.relpath(f.full_path,
+                                            self.environment.topobjdir))
 
         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)
@@ -121,79 +140,72 @@ class FasterMakeBackend(CommonBackend):
         )
         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.add_source(obj.path.full_path)
+            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
+            jar_context['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 '*' in e.source:
-                    if e.preprocess:
-                        raise Exception('%s: Wildcards are not supported with '
-                                        'preprocessing' % obj.path)
-                    def _prefix(s):
-                        for p in mozpath.split(s):
-                            if '*' not in p:
-                                yield p + '/'
-                    prefix = ''.join(_prefix(src.full_path))
-
-                    self._install_manifests[install_target] \
-                        .add_pattern_symlink(
-                        prefix,
-                        src.full_path[len(prefix):],
-                        mozpath.join(jarinfo.name, e.output))
-                    continue
-
-                if not os.path.exists(src.full_path):
+                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)
-                    self._dependencies['install-%s' % install_target] \
-                        .append(mozpath.relpath(
-                        src.full_path, self.environment.topobjdir))
+
+                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:
-                    self._add_preprocess(
-                        obj,
-                        src.full_path,
-                        mozpath.join(jarinfo.name, mozpath.dirname(e.output)),
-                        mozpath.basename(e.output),
-                        defines=defines)
+                    if '*' in e.source:
+                        raise Exception('%s: Wildcards are not supported with '
+                                        'preprocessing' % obj.path)
+                    files_pp[path] += [src]
                 else:
-                    self._install_manifests[install_target].add_symlink(
-                        src.full_path,
-                        mozpath.join(jarinfo.name, e.output))
+                    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))