Bug 1290502 - Avoid duplicate entries in dependentlibs.list; r=ted, a=ritu
authorMike Shal <mshal@mozilla.com>
Fri, 29 Jul 2016 14:36:40 -0400
changeset 349673 582822e22e479fc2c13b118d417979604985d3da
parent 349672 10d3f6d868e5451e0b030e7734c09d3de18bbfdf
child 349674 ef5c6ff8eceec52c664ac437f46527a7be25be9e
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted, ritu
bugs1290502
milestone50.0a2
Bug 1290502 - Avoid duplicate entries in dependentlibs.list; r=ted, a=ritu MozReview-Commit-ID: CFyf1W3oFju
toolkit/library/dependentlibs.py
--- a/toolkit/library/dependentlibs.py
+++ b/toolkit/library/dependentlibs.py
@@ -6,16 +6,17 @@
 upon that are in the same directory, followed by the library itself.
 '''
 
 import os
 import re
 import subprocess
 import sys
 import mozpack.path as mozpath
+from collections import OrderedDict
 from mozpack.executables import (
     get_type,
     ELF,
     MACHO,
 )
 from buildconfig import substs
 
 def dependentlibs_dumpbin(lib):
@@ -88,29 +89,29 @@ def dependentlibs_otool(lib):
     proc.wait()
     return deps
 
 def dependentlibs(lib, libpaths, func):
     '''For a given library, returns the list of recursive dependencies that can
     be found in the given list of paths, followed by the library itself.'''
     assert(libpaths)
     assert(isinstance(libpaths, list))
-    deps = []
+    deps = OrderedDict()
     for dep in func(lib):
         if dep in deps or os.path.isabs(dep):
             continue
         for dir in libpaths:
             deppath = os.path.join(dir, dep)
             if os.path.exists(deppath):
-                deps.extend([d for d in dependentlibs(deppath, libpaths, func) if not d in deps])
+                deps.update(dependentlibs(deppath, libpaths, func))
                 # Black list the ICU data DLL because preloading it at startup
                 # leads to startup performance problems because of its excessive
                 # size (around 10MB).
                 if not dep.startswith("icu"):
-                    deps.append(deppath)
+                    deps[dep] = deppath
                 break
 
     return deps
 
 def gen_list(output, lib):
     libpaths = [os.path.join(substs['DIST'], 'bin')]
     binary_type = get_type(lib)
     if binary_type == ELF:
@@ -118,18 +119,17 @@ def gen_list(output, lib):
     elif binary_type == MACHO:
         func = dependentlibs_otool
     else:
         ext = os.path.splitext(lib)[1]
         assert(ext == '.dll')
         func = dependentlibs_dumpbin
 
     deps = dependentlibs(lib, libpaths, func)
-    deps.append(mozpath.join(libpaths[0], lib))
-    dependentlibs_output = [mozpath.basename(f) for f in deps]
-    output.write('\n'.join(dependentlibs_output) + '\n')
-    return set(deps)
+    deps[lib] = mozpath.join(libpaths[0], lib)
+    output.write('\n'.join(deps.keys()) + '\n')
+    return set(deps.values())
 
 def main():
     gen_list(sys.stdout, sys.argv[1])
 
 if __name__ == '__main__':
     main()