| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Writes dependency ordered list of native libraries. | 7 """Writes dependency ordered list of native libraries. |
| 8 | 8 |
| 9 The list excludes any Android system libraries, as those are not bundled with | 9 The list excludes any Android system libraries, as those are not bundled with |
| 10 the APK. | 10 the APK. |
| 11 | 11 |
| 12 This list of libraries is used for several steps of building an APK. | 12 This list of libraries is used for several steps of building an APK. |
| 13 In the component build, the --input-libraries only needs to be the top-level | 13 In the component build, the --input-libraries only needs to be the top-level |
| 14 library (i.e. libcontent_shell_content_view). This will then use readelf to | 14 library (i.e. libcontent_shell_content_view). This will then use readelf to |
| 15 inspect the shared libraries and determine the full list of (non-system) | 15 inspect the shared libraries and determine the full list of (non-system) |
| 16 libraries that should be included in the APK. | 16 libraries that should be included in the APK. |
| 17 """ | 17 """ |
| 18 | 18 |
| 19 # TODO(cjhopman): See if we can expose the list of library dependencies from | 19 # TODO(cjhopman): See if we can expose the list of library dependencies from |
| 20 # gyp, rather than calculating it ourselves. | 20 # gyp, rather than calculating it ourselves. |
| 21 # http://crbug.com/225558 | 21 # http://crbug.com/225558 |
| 22 | 22 |
| 23 import json | |
| 24 import optparse | 23 import optparse |
| 25 import os | 24 import os |
| 26 import re | 25 import re |
| 27 import sys | 26 import sys |
| 28 | 27 |
| 29 from util import build_utils | 28 from util import build_utils # pylint: disable=F0401 |
| 30 | 29 |
| 31 _options = None | 30 _options = None |
| 32 _library_re = re.compile( | 31 _library_re = re.compile( |
| 33 '.*NEEDED.*Shared library: \[(?P<library_name>[\w/.]+)\]') | 32 '.*NEEDED.*Shared library: \[(?P<library_name>[\w/.]+)\]') |
| 34 | 33 |
| 35 | 34 |
| 36 def FullLibraryPath(library_name): | 35 def FullLibraryPath(library_name): |
| 37 return '%s/%s' % (_options.libraries_dir, library_name) | 36 return '%s/%s' % (_options.libraries_dir, library_name) |
| 38 | 37 |
| 39 | 38 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 84 |
| 86 return sorted_deps | 85 return sorted_deps |
| 87 | 86 |
| 88 def GetSortedTransitiveDependenciesForExecutable(executable): | 87 def GetSortedTransitiveDependenciesForExecutable(executable): |
| 89 """Returns all transitive library dependencies in dependency order.""" | 88 """Returns all transitive library dependencies in dependency order.""" |
| 90 all_deps = GetDependencies(executable) | 89 all_deps = GetDependencies(executable) |
| 91 libraries = [lib for lib in all_deps if not IsSystemLibrary(lib)] | 90 libraries = [lib for lib in all_deps if not IsSystemLibrary(lib)] |
| 92 return GetSortedTransitiveDependencies(libraries) | 91 return GetSortedTransitiveDependencies(libraries) |
| 93 | 92 |
| 94 | 93 |
| 95 def main(argv): | 94 def main(): |
| 96 parser = optparse.OptionParser() | 95 parser = optparse.OptionParser() |
| 97 | 96 |
| 98 parser.add_option('--input-libraries', | 97 parser.add_option('--input-libraries', |
| 99 help='A list of top-level input libraries.') | 98 help='A list of top-level input libraries.') |
| 100 parser.add_option('--libraries-dir', | 99 parser.add_option('--libraries-dir', |
| 101 help='The directory which contains shared libraries.') | 100 help='The directory which contains shared libraries.') |
| 102 parser.add_option('--readelf', help='Path to the readelf binary.') | 101 parser.add_option('--readelf', help='Path to the readelf binary.') |
| 103 parser.add_option('--output', help='Path to the generated .json file.') | 102 parser.add_option('--output', help='Path to the generated .json file.') |
| 104 parser.add_option('--stamp', help='Path to touch on success.') | 103 parser.add_option('--stamp', help='Path to touch on success.') |
| 105 | 104 |
| 106 global _options | 105 global _options |
| 107 _options, _ = parser.parse_args() | 106 _options, _ = parser.parse_args() |
| 108 | 107 |
| 109 libraries = build_utils.ParseGypList(_options.input_libraries) | 108 libraries = build_utils.ParseGypList(_options.input_libraries) |
| 110 if libraries[0].endswith('.so'): | 109 if libraries[0].endswith('.so'): |
| 111 libraries = [os.path.basename(lib) for lib in libraries] | 110 libraries = [os.path.basename(lib) for lib in libraries] |
| 112 libraries = GetSortedTransitiveDependencies(libraries) | 111 libraries = GetSortedTransitiveDependencies(libraries) |
| 113 else: | 112 else: |
| 114 libraries = GetSortedTransitiveDependenciesForExecutable(libraries[0]) | 113 libraries = GetSortedTransitiveDependenciesForExecutable(libraries[0]) |
| 115 | 114 |
| 116 build_utils.WriteJson(libraries, _options.output, only_if_changed=True) | 115 build_utils.WriteJson(libraries, _options.output, only_if_changed=True) |
| 117 | 116 |
| 118 if _options.stamp: | 117 if _options.stamp: |
| 119 build_utils.Touch(_options.stamp) | 118 build_utils.Touch(_options.stamp) |
| 120 | 119 |
| 121 | 120 |
| 122 if __name__ == '__main__': | 121 if __name__ == '__main__': |
| 123 sys.exit(main(sys.argv)) | 122 sys.exit(main()) |
| 124 | 123 |
| 125 | 124 |
| OLD | NEW |