Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: build/android/gyp/write_ordered_libraries.py

Issue 13473017: CheckCallDie: add option to suppress successful output (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: :/ Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/gyp/util/build_utils.py ('k') | build/android/java_cpp_template.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 import json
24 import optparse 24 import optparse
25 import os 25 import os
26 import re 26 import re
27 import sys 27 import sys
28 28
29 BUILD_ANDROID_DIR = os.path.join(os.path.dirname(__file__), '..') 29 from util import build_utils
30 sys.path.append(BUILD_ANDROID_DIR)
31
32 from pylib import build_utils
33 30
34 31
35 _options = None 32 _options = None
36 _libraries_dir = None 33 _libraries_dir = None
37 _library_re = re.compile( 34 _library_re = re.compile(
38 '.*NEEDED.*Shared library: \[(?P<library_name>[\w/.]+)\]') 35 '.*NEEDED.*Shared library: \[(?P<library_name>[\w/.]+)\]')
39 36
40 37
41 def FullLibraryPath(library_name): 38 def FullLibraryPath(library_name):
42 return '%s/%s' % (_libraries_dir, library_name) 39 return '%s/%s' % (_libraries_dir, library_name)
43 40
44 41
45 def IsSystemLibrary(library_name): 42 def IsSystemLibrary(library_name):
46 # If the library doesn't exist in the libraries directory, assume that it is 43 # If the library doesn't exist in the libraries directory, assume that it is
47 # an Android system library. 44 # an Android system library.
48 return not os.path.exists(FullLibraryPath(library_name)) 45 return not os.path.exists(FullLibraryPath(library_name))
49 46
50 47
51 def CallReadElf(library_name): 48 def CallReadElf(library_name):
52 readelf_cmd = [_options.readelf, 49 readelf_cmd = [_options.readelf,
53 '-d', 50 '-d',
54 FullLibraryPath(library_name)] 51 FullLibraryPath(library_name)]
55 return build_utils.CheckCallDie(readelf_cmd) 52 return build_utils.CheckCallDie(readelf_cmd, suppress_output=True)
56 53
57 54
58 def GetDependencies(library_name): 55 def GetDependencies(library_name):
59 elf = CallReadElf(library_name) 56 elf = CallReadElf(library_name)
60 return set(_library_re.findall(elf)) 57 return set(_library_re.findall(elf))
61 58
62 59
63 def GetNonSystemDependencies(library_name): 60 def GetNonSystemDependencies(library_name):
64 all_deps = GetDependencies(library_name) 61 all_deps = GetDependencies(library_name)
65 return set((lib for lib in all_deps if not IsSystemLibrary(lib))) 62 return set((lib for lib in all_deps if not IsSystemLibrary(lib)))
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 json.dump(libraries, outfile) 111 json.dump(libraries, outfile)
115 112
116 if _options.stamp: 113 if _options.stamp:
117 build_utils.Touch(_options.stamp) 114 build_utils.Touch(_options.stamp)
118 115
119 116
120 if __name__ == '__main__': 117 if __name__ == '__main__':
121 sys.exit(main(sys.argv)) 118 sys.exit(main(sys.argv))
122 119
123 120
OLDNEW
« no previous file with comments | « build/android/gyp/util/build_utils.py ('k') | build/android/java_cpp_template.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698