Bug 1235021 - Use Path instances to handle paths in jar manifest in the FasterMake backend. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 24 Dec 2015 14:41:10 +0900
changeset 278024 73e69f3c9ea160d3a18594fd0833f3336e5dbfcf
parent 278023 666f5a3e18a410fe198c1a3977d248b064358572
child 278025 a9d167756f2fe583fd9dfaf7586095ebc256c4b9
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 - Use Path instances to handle paths in jar manifest in the FasterMake backend. r=gps This is a transitional step to make further changes smaller and easier to review.
python/mozbuild/mozbuild/backend/fastermake.py
--- a/python/mozbuild/mozbuild/backend/fastermake.py
+++ b/python/mozbuild/mozbuild/backend/fastermake.py
@@ -1,15 +1,19 @@
 # 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,
+    Path,
+)
 from mozbuild.frontend.data import (
     ChromeManifestEntry,
     ContextDerived,
     Defines,
     FinalTargetPreprocessedFiles,
     FinalTargetFiles,
     JARManifest,
     XPIDLFile,
@@ -131,80 +135,79 @@ class FasterMakeBackend(CommonBackend):
         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
 
+        jar_context = Context(config=obj._context.config)
+        jar_context.add_source(obj.path.full_path)
+
         for jarinfo in pp.out:
             install_target = obj.install_target
             if jarinfo.base:
                 install_target = mozpath.normpath(
                     mozpath.join(install_target, jarinfo.base))
             for e in jarinfo.entries:
                 if e.is_locale:
                     if jarinfo.relativesrcdir:
-                        path = mozpath.join(self.environment.topsrcdir,
-                                            jarinfo.relativesrcdir)
+                        src = '/%s' % jarinfo.relativesrcdir
                     else:
-                        path = mozpath.dirname(obj.path.full_path)
-                    src = mozpath.join( path, 'en-US', e.source)
-                elif e.source.startswith('/'):
-                    src = mozpath.join(self.environment.topsrcdir,
-                                       e.source[1:])
+                        src = ''
+                    src = mozpath.join(src, 'en-US', e.source)
                 else:
-                    src = mozpath.join(mozpath.dirname(obj.path.full_path), e.source)
+                    src = e.source
 
-                src = mozpath.normpath(src)
+                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 s.split('/'):
+                        for p in mozpath.split(s):
                             if '*' not in p:
                                 yield p + '/'
-                    prefix = ''.join(_prefix(src))
+                    prefix = ''.join(_prefix(src.full_path))
 
                     self._install_manifests[install_target] \
                         .add_pattern_symlink(
                         prefix,
-                        src[len(prefix):],
+                        src.full_path[len(prefix):],
                         mozpath.join(jarinfo.name, e.output))
                     continue
 
-                if not os.path.exists(src):
+                if 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 = mozpath.join(self.environment.topobjdir,
-                                           e.source[1:])
+                        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 = mozpath.join(obj.objdir, e.source)
+                        src = Path(obj._context, '!' + e.source)
                     self._dependencies['install-%s' % install_target] \
                         .append(mozpath.relpath(
-                        src, self.environment.topobjdir))
+                        src.full_path, self.environment.topobjdir))
 
                 if e.preprocess:
                     self._add_preprocess(
                         obj,
-                        src,
+                        src.full_path,
                         mozpath.join(jarinfo.name, mozpath.dirname(e.output)),
                         mozpath.basename(e.output),
                         defines=defines)
                 else:
                     self._install_manifests[install_target].add_symlink(
-                        src,
+                        src.full_path,
                         mozpath.join(jarinfo.name, e.output))
 
             manifest = mozpath.normpath(mozpath.join(install_target,
                                                      jarinfo.name))
             manifest += '.manifest'
             for m in jarinfo.chrome_manifests:
                 self._manifest_entries[manifest].add(
                     m.replace('%', mozpath.basename(jarinfo.name) + '/'))