OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 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 optparse | 7 import optparse |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import tempfile | 10 import tempfile |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 number_of_file_instances += 1 | 108 number_of_file_instances += 1 |
109 dir_to_files_map[src_search_dir].append(src_file) | 109 dir_to_files_map[src_search_dir].append(src_file) |
110 if (number_of_file_instances > 1): | 110 if (number_of_file_instances > 1): |
111 raise Exception( | 111 raise Exception( |
112 'There is more than one instance of file %s in %s' | 112 'There is more than one instance of file %s in %s' |
113 % (src_file, src_search_dirs)) | 113 % (src_file, src_search_dirs)) |
114 if (number_of_file_instances < 1): | 114 if (number_of_file_instances < 1): |
115 raise Exception( | 115 raise Exception( |
116 'Unable to find file %s in %s' % (src_file, src_search_dirs)) | 116 'Unable to find file %s in %s' % (src_file, src_search_dirs)) |
117 | 117 |
| 118 # Delete the old output file if any. |
118 if os.path.isfile(options.jar_path): | 119 if os.path.isfile(options.jar_path): |
119 os.remove(options.jar_path) | 120 os.remove(options.jar_path) |
120 | 121 |
121 # Jar the sources from every source search directory. | 122 # Jar the sources from every source search directory. |
122 for src_search_dir in src_search_dirs: | 123 for src_search_dir in src_search_dirs: |
123 if len(dir_to_files_map[src_search_dir]) > 0: | 124 if len(dir_to_files_map[src_search_dir]) > 0: |
124 JarSources(src_search_dir, dir_to_files_map[src_search_dir], | 125 JarSources(src_search_dir, dir_to_files_map[src_search_dir], |
125 options.jar_path) | 126 options.jar_path) |
126 else: | 127 else: |
127 raise Exception( | 128 raise Exception( |
(...skipping 15 matching lines...) Expand all Loading... |
143 # Clean up temporary output directory. | 144 # Clean up temporary output directory. |
144 if unzipped_jar_path: | 145 if unzipped_jar_path: |
145 build_utils.DeleteDirectory(unzipped_jar_path) | 146 build_utils.DeleteDirectory(unzipped_jar_path) |
146 | 147 |
147 if options.stamp: | 148 if options.stamp: |
148 build_utils.Touch(options.stamp) | 149 build_utils.Touch(options.stamp) |
149 | 150 |
150 if __name__ == '__main__': | 151 if __name__ == '__main__': |
151 sys.exit(main()) | 152 sys.exit(main()) |
152 | 153 |
OLD | NEW |