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

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

Issue 197693002: [Android] Lint build/android/gyp/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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
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 """Creates a TOC file from a Java jar. 7 """Creates a TOC file from a Java jar.
8 8
9 The TOC file contains the non-package API of the jar. This includes all 9 The TOC file contains the non-package API of the jar. This includes all
10 public/protected/package classes/functions/members and the values of static 10 public/protected/package classes/functions/members and the values of static
11 final variables (members with package access are kept because in some cases we 11 final variables (members with package access are kept because in some cases we
12 have multiple libraries with the same package, particularly test+non-test). Some 12 have multiple libraries with the same package, particularly test+non-test). Some
13 other information (major/minor javac version) is also included. 13 other information (major/minor javac version) is also included.
14 14
15 This TOC file then can be used to determine if a dependent library should be 15 This TOC file then can be used to determine if a dependent library should be
16 rebuilt when this jar changes. I.e. any change to the jar that would require a 16 rebuilt when this jar changes. I.e. any change to the jar that would require a
17 rebuild, will have a corresponding change in the TOC file. 17 rebuild, will have a corresponding change in the TOC file.
18 """ 18 """
19 19
20 import optparse 20 import optparse
21 import os
22 import re 21 import re
23 import sys 22 import sys
24 import zipfile 23 import zipfile
25 24
25 # pylint: disable=F0401
26 from util import build_utils 26 from util import build_utils
27 from util import md5_check 27 from util import md5_check
28 # pylint: enable=F0401
28 29
29 30
30 def GetClassesInZipFile(zip_file): 31 def GetClassesInZipFile(zip_file):
31 classes = [] 32 classes = []
32 files = zip_file.namelist() 33 files = zip_file.namelist()
33 for f in files: 34 for f in files:
34 if f.endswith('.class'): 35 if f.endswith('.class'):
35 # f is of the form org/chromium/base/Class$Inner.class 36 # f is of the form org/chromium/base/Class$Inner.class
36 classes.append(f.replace('/', '.')[:-6]) 37 classes.append(f.replace('/', '.')[:-6])
37 return classes 38 return classes
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 toc_path = options.toc_path 85 toc_path = options.toc_path
85 record_path = '%s.md5.stamp' % toc_path 86 record_path = '%s.md5.stamp' % toc_path
86 md5_check.CallAndRecordIfStale( 87 md5_check.CallAndRecordIfStale(
87 lambda: UpdateToc(jar_path, toc_path), 88 lambda: UpdateToc(jar_path, toc_path),
88 record_path=record_path, 89 record_path=record_path,
89 input_paths=[jar_path], 90 input_paths=[jar_path],
90 ) 91 )
91 build_utils.Touch(toc_path) 92 build_utils.Touch(toc_path)
92 93
93 94
94 def main(argv): 95 def main():
95 parser = optparse.OptionParser() 96 parser = optparse.OptionParser()
96 parser.add_option('--jar-path', help='Input .jar path.') 97 parser.add_option('--jar-path', help='Input .jar path.')
97 parser.add_option('--toc-path', help='Output .jar.TOC path.') 98 parser.add_option('--toc-path', help='Output .jar.TOC path.')
98 parser.add_option('--stamp', help='Path to touch on success.') 99 parser.add_option('--stamp', help='Path to touch on success.')
99 100
100 options, _ = parser.parse_args() 101 options, _ = parser.parse_args()
101 102
102 DoJarToc(options) 103 DoJarToc(options)
103 104
104 if options.stamp: 105 if options.stamp:
105 build_utils.Touch(options.stamp) 106 build_utils.Touch(options.stamp)
106 107
107 108
108 if __name__ == '__main__': 109 if __name__ == '__main__':
109 sys.exit(main(sys.argv)) 110 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698