Index: build/android/gyp/write_ordered_libraries.py |
diff --git a/build/android/gyp/write_ordered_libraries.py b/build/android/gyp/write_ordered_libraries.py |
index b1e3cec811b4403b2bf0454e7b898192f6dd5421..31aba74ccaf428e133c6167ab24aa2fcd5bafd59 100755 |
--- a/build/android/gyp/write_ordered_libraries.py |
+++ b/build/android/gyp/write_ordered_libraries.py |
@@ -65,33 +65,18 @@ def GetNonSystemDependencies(library_name): |
def GetSortedTransitiveDependencies(libraries): |
"""Returns all transitive library dependencies in dependency order.""" |
- def GraphNode(library): |
- return (library, GetNonSystemDependencies(library)) |
- |
- # First: find all library dependencies. |
- unchecked_deps = libraries |
- all_deps = set(libraries) |
- while unchecked_deps: |
- lib = unchecked_deps.pop() |
- new_deps = GetNonSystemDependencies(lib).difference(all_deps) |
- unchecked_deps.extend(new_deps) |
- all_deps = all_deps.union(new_deps) |
- |
- # Then: simple, slow topological sort. |
- sorted_deps = [] |
- unsorted_deps = dict(map(GraphNode, all_deps)) |
- while unsorted_deps: |
- for library, dependencies in unsorted_deps.items(): |
- if not dependencies.intersection(unsorted_deps.keys()): |
- sorted_deps.append(library) |
- del unsorted_deps[library] |
- |
- return sorted_deps |
- |
-def GetSortedTransitiveDependenciesForExecutable(executable): |
- """Returns all transitive library dependencies in dependency order.""" |
- all_deps = GetDependencies(executable) |
- libraries = [lib for lib in all_deps if not IsSystemLibrary(lib)] |
+ return build_utils.GetSortedTransitiveDependencies( |
+ libraries, GetNonSystemDependencies) |
+ |
+ |
+def GetSortedTransitiveDependenciesForBinaries(binaries): |
+ if binaries[0].endswith('.so'): |
+ libraries = [os.path.basename(lib) for lib in binaries] |
+ else: |
+ assert len(binaries) == 1 |
+ all_deps = GetDependencies(binaries[0]) |
+ libraries = [lib for lib in all_deps if not IsSystemLibrary(lib)] |
+ |
return GetSortedTransitiveDependencies(libraries) |
@@ -111,11 +96,7 @@ def main(): |
libraries = build_utils.ParseGypList(_options.input_libraries) |
if len(libraries): |
- if libraries[0].endswith('.so'): |
- libraries = [os.path.basename(lib) for lib in libraries] |
- libraries = GetSortedTransitiveDependencies(libraries) |
- else: |
- libraries = GetSortedTransitiveDependenciesForExecutable(libraries[0]) |
+ libraries = GetSortedTransitiveDependenciesForBinaries(libraries) |
build_utils.WriteJson(libraries, _options.output, only_if_changed=True) |