Bug 1045969 - Use paths relative to root topobjdir for backend files for similar reasons as in bug 1045329. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 01 Aug 2014 15:56:16 +0900
changeset 197219 0d3520e9f0fb005f7701a2b48171556e0dfe515f
parent 197218 8d9d227f75ee4d284ba2e2645886081006cac60c
child 197220 8c22972b05120af0c3929428989c968722171e03
push id47073
push usermh@glandium.org
push dateFri, 01 Aug 2014 06:56:31 +0000
treeherdermozilla-inbound@0d3520e9f0fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1045969, 1045329
milestone34.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 1045969 - Use paths relative to root topobjdir for backend files for similar reasons as in bug 1045329. r=mshal and paths relative to the "local" topobjdir for linkage.
python/mozbuild/mozbuild/backend/recursivemake.py
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -83,20 +83,20 @@ class BackendMakeFile(object):
     invalidate all make targets across the whole tree! This would effectively
     undermine incremental builds as any mozbuild change would cause the entire
     tree to rebuild!
 
     The solution is to not update the mtimes of backend.mk files unless they
     actually change. We use FileAvoidWrite to accomplish this.
     """
 
-    def __init__(self, srcdir, objdir, environment):
+    def __init__(self, srcdir, objdir, environment, topobjdir):
         self.srcdir = srcdir
         self.objdir = objdir
-        self.relobjdir = objdir[len(environment.topobjdir) + 1:]
+        self.relobjdir = mozpath.relpath(objdir, topobjdir)
         self.environment = environment
         self.name = mozpath.join(objdir, 'backend.mk')
 
         # XPIDLFiles attached to this file.
         self.idls = []
         self.xpt_name = None
 
         self.fh = FileAvoidWrite(self.name, capture_diff=True)
@@ -336,17 +336,18 @@ class RecursiveMakeBackend(CommonBackend
     def consume_object(self, obj):
         """Write out build files necessary to build with recursive make."""
 
         if not isinstance(obj, SandboxDerived):
             return
 
         if obj.objdir not in self._backend_files:
             self._backend_files[obj.objdir] = \
-                BackendMakeFile(obj.srcdir, obj.objdir, obj.config)
+                BackendMakeFile(obj.srcdir, obj.objdir, obj.config,
+                    self.environment.topobjdir)
         backend_file = self._backend_files[obj.objdir]
 
         CommonBackend.consume_object(self, obj)
 
         # CommonBackend handles XPIDLFile and TestManifest, but we want to do
         # some extra things for them.
         if isinstance(obj, XPIDLFile):
             backend_file.idls.append(obj)
@@ -381,17 +382,18 @@ class RecursiveMakeBackend(CommonBackend
                 'MOZ_DISABLE_UNIFIED_COMPILATION') and files_per_unification > 1
 
             # Sorted so output is consistent and we don't bump mtimes.
             for k, v in sorted(obj.variables.items()):
                 if k in unified_suffixes:
                     if do_unify:
                         # On Windows, path names have a maximum length of 255 characters,
                         # so avoid creating extremely long path names.
-                        unified_prefix = backend_file.relobjdir
+                        unified_prefix = mozpath.relpath(backend_file.objdir,
+                            backend_file.environment.topobjdir)
                         if len(unified_prefix) > 20:
                             unified_prefix = unified_prefix[-20:].split('/', 1)[-1]
                         unified_prefix = unified_prefix.replace('/', '_')
 
                         self._add_unified_build_rules(backend_file, v,
                             backend_file.objdir,
                             unified_prefix='Unified_%s_%s' % (
                                 unified_suffixes[k],
@@ -1198,22 +1200,17 @@ class RecursiveMakeBackend(CommonBackend
             for l in lib.linked_libraries:
                 if isinstance(l, StaticLibrary):
                     for q in recursive_get_shared_libs(l):
                         yield q
                 else:
                     yield l
 
         def pretty_relpath(lib):
-            # If this is an external objdir (i.e., comm-central), use the other
-            # directory instead of $(DEPTH).
-            if lib.objdir.startswith(topobjdir + '/'):
-                return '$(DEPTH)/%s' % lib.relobjdir
-            else:
-                return lib.relobjdir
+            return '$(DEPTH)/%s' % mozpath.relpath(lib.objdir, topobjdir)
 
         topobjdir = mozpath.normsep(obj.topobjdir)
         # This will create the node even if there aren't any linked libraries.
         build_target = self._build_target_for_obj(obj)
         self._compile_graph[build_target]
 
         # Until MOZ_GLUE_LDFLAGS/MOZ_GLUE_PROGRAM_LDFLAGS are properly
         # handled in moz.build world, assume any program or shared library