| 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 import fnmatch | 7 import fnmatch |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 jar_path = os.path.abspath(options.jar_path) | 22 jar_path = os.path.abspath(options.jar_path) |
| 23 | 23 |
| 24 # The paths of the files in the jar will be the same as they are passed in to | 24 # The paths of the files in the jar will be the same as they are passed in to |
| 25 # the command. Because of this, the command should be run in | 25 # the command. Because of this, the command should be run in |
| 26 # options.classes_dir so the .class file paths in the jar are correct. | 26 # options.classes_dir so the .class file paths in the jar are correct. |
| 27 jar_cwd = options.classes_dir | 27 jar_cwd = options.classes_dir |
| 28 class_files_rel = [os.path.relpath(f, jar_cwd) for f in class_files] | 28 class_files_rel = [os.path.relpath(f, jar_cwd) for f in class_files] |
| 29 jar_cmd = ['jar', 'cf0', jar_path] + class_files_rel | 29 jar_cmd = ['jar', 'cf0', jar_path] + class_files_rel |
| 30 | 30 |
| 31 record_path = '%s.md5.stamp' % options.jar_path |
| 32 md5_check.CallAndRecordIfStale( |
| 33 lambda: build_utils.CheckCallDie(jar_cmd, cwd=jar_cwd), |
| 34 record_path=record_path, |
| 35 input_paths=class_files, |
| 36 input_strings=jar_cmd) |
| 31 | 37 |
| 32 md5_stamp = '%s.md5' % options.jar_path | 38 build_utils.Touch(options.jar_path) |
| 33 md5_checker = md5_check.Md5Checker( | |
| 34 stamp=md5_stamp, inputs=class_files, command=jar_cmd) | |
| 35 if md5_checker.IsStale(): | |
| 36 build_utils.CheckCallDie(jar_cmd, cwd=jar_cwd) | |
| 37 else: | |
| 38 build_utils.Touch(options.jar_path) | |
| 39 md5_checker.Write() | |
| 40 | 39 |
| 41 | 40 |
| 42 def main(argv): | 41 def main(argv): |
| 43 parser = optparse.OptionParser() | 42 parser = optparse.OptionParser() |
| 44 parser.add_option('--classes-dir', help='Directory containing .class files.') | 43 parser.add_option('--classes-dir', help='Directory containing .class files.') |
| 45 parser.add_option('--jar-path', help='Jar output path.') | 44 parser.add_option('--jar-path', help='Jar output path.') |
| 46 parser.add_option('--excluded-classes', | 45 parser.add_option('--excluded-classes', |
| 47 help='List of .class file patterns to exclude from the jar.') | 46 help='List of .class file patterns to exclude from the jar.') |
| 48 parser.add_option('--stamp', help='Path to touch on success.') | 47 parser.add_option('--stamp', help='Path to touch on success.') |
| 49 | 48 |
| 50 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. | 49 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. |
| 51 parser.add_option('--ignore', help='Ignored.') | 50 parser.add_option('--ignore', help='Ignored.') |
| 52 | 51 |
| 53 options, _ = parser.parse_args() | 52 options, _ = parser.parse_args() |
| 54 | 53 |
| 55 DoJar(options) | 54 DoJar(options) |
| 56 | 55 |
| 57 if options.stamp: | 56 if options.stamp: |
| 58 build_utils.Touch(options.stamp) | 57 build_utils.Touch(options.stamp) |
| 59 | 58 |
| 60 | 59 |
| 61 if __name__ == '__main__': | 60 if __name__ == '__main__': |
| 62 sys.exit(main(sys.argv)) | 61 sys.exit(main(sys.argv)) |
| 63 | 62 |
| OLD | NEW |