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

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

Issue 14263006: [Android] Refactor md5_check + add tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@java_toc
Patch Set: Rebase 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
« no previous file with comments | « build/android/gyp/jar.py ('k') | build/android/gyp/javac.py » ('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 """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 classes/functions/members and the values of static final 10 public/protected classes/functions/members and the values of static final
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 javap_output = CallJavap(classpath=jar_path, classes=classes) 74 javap_output = CallJavap(classpath=jar_path, classes=classes)
75 toc = ExtractToc(javap_output) 75 toc = ExtractToc(javap_output)
76 76
77 with open(toc_path, 'w') as tocfile: 77 with open(toc_path, 'w') as tocfile:
78 tocfile.write(toc) 78 tocfile.write(toc)
79 79
80 80
81 def DoJarToc(options): 81 def DoJarToc(options):
82 jar_path = options.jar_path 82 jar_path = options.jar_path
83 toc_path = options.toc_path 83 toc_path = options.toc_path
84 md5_stamp_path = '%s.md5' % toc_path 84 record_path = '%s.md5.stamp' % toc_path
85 md5_checker = md5_check.Md5Checker(stamp=md5_stamp_path, inputs=[jar_path]) 85 md5_check.CallAndRecordIfStale(
86 if md5_checker.IsStale(): 86 lambda: UpdateToc(jar_path, toc_path),
87 UpdateToc(jar_path, toc_path) 87 record_path=record_path,
88 md5_checker.Write() 88 input_paths=[jar_path],
89 else: 89 )
90 build_utils.Touch(toc_path) 90 build_utils.Touch(toc_path)
91 91
92 92
93 def main(argv): 93 def main(argv):
94 parser = optparse.OptionParser() 94 parser = optparse.OptionParser()
95 parser.add_option('--jar-path', help='Input .jar path.') 95 parser.add_option('--jar-path', help='Input .jar path.')
96 parser.add_option('--toc-path', help='Output .jar.TOC path.') 96 parser.add_option('--toc-path', help='Output .jar.TOC path.')
97 parser.add_option('--stamp', help='Path to touch on success.') 97 parser.add_option('--stamp', help='Path to touch on success.')
98 98
99 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. 99 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja.
100 parser.add_option('--ignore', help='Ignored.') 100 parser.add_option('--ignore', help='Ignored.')
101 101
102 options, _ = parser.parse_args() 102 options, _ = parser.parse_args()
103 103
104 DoJarToc(options) 104 DoJarToc(options)
105 105
106 if options.stamp: 106 if options.stamp:
107 build_utils.Touch(options.stamp) 107 build_utils.Touch(options.stamp)
108 108
109 109
110 if __name__ == '__main__': 110 if __name__ == '__main__':
111 sys.exit(main(sys.argv)) 111 sys.exit(main(sys.argv))
112 112
OLDNEW
« no previous file with comments | « build/android/gyp/jar.py ('k') | build/android/gyp/javac.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698