| 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 """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 | 
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 65   def JavapFilter(line): | 65   def JavapFilter(line): | 
| 66     return (re.match('|'.join(good_patterns), line) and | 66     return (re.match('|'.join(good_patterns), line) and | 
| 67         not re.match('|'.join(bad_patterns), line)) | 67         not re.match('|'.join(bad_patterns), line)) | 
| 68   toc = filter(JavapFilter, disassembled_classes.split('\n')) | 68   toc = filter(JavapFilter, disassembled_classes.split('\n')) | 
| 69 | 69 | 
| 70   return '\n'.join(toc) | 70   return '\n'.join(toc) | 
| 71 | 71 | 
| 72 | 72 | 
| 73 def UpdateToc(jar_path, toc_path): | 73 def UpdateToc(jar_path, toc_path): | 
| 74   classes = GetClassesInZipFile(zipfile.ZipFile(jar_path)) | 74   classes = GetClassesInZipFile(zipfile.ZipFile(jar_path)) | 
| 75   javap_output = CallJavap(classpath=jar_path, classes=classes) | 75   toc = '' | 
| 76   toc = ExtractToc(javap_output) | 76   if len(classes) != 0: | 
|  | 77     javap_output = CallJavap(classpath=jar_path, classes=classes) | 
|  | 78     toc = ExtractToc(javap_output) | 
| 77 | 79 | 
| 78   with open(toc_path, 'w') as tocfile: | 80   with open(toc_path, 'w') as tocfile: | 
| 79     tocfile.write(toc) | 81     tocfile.write(toc) | 
| 80 | 82 | 
| 81 | 83 | 
| 82 def DoJarToc(options): | 84 def DoJarToc(options): | 
| 83   jar_path = options.jar_path | 85   jar_path = options.jar_path | 
| 84   toc_path = options.toc_path | 86   toc_path = options.toc_path | 
| 85   record_path = '%s.md5.stamp' % toc_path | 87   record_path = '%s.md5.stamp' % toc_path | 
| 86   md5_check.CallAndRecordIfStale( | 88   md5_check.CallAndRecordIfStale( | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 113     build_utils.WriteDepfile( | 115     build_utils.WriteDepfile( | 
| 114         options.depfile, | 116         options.depfile, | 
| 115         build_utils.GetPythonDependencies()) | 117         build_utils.GetPythonDependencies()) | 
| 116 | 118 | 
| 117   if options.stamp: | 119   if options.stamp: | 
| 118     build_utils.Touch(options.stamp) | 120     build_utils.Touch(options.stamp) | 
| 119 | 121 | 
| 120 | 122 | 
| 121 if __name__ == '__main__': | 123 if __name__ == '__main__': | 
| 122   sys.exit(main()) | 124   sys.exit(main()) | 
| OLD | NEW | 
|---|