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 """Instruments classes and jar files. | 7 """Instruments classes and jar files. |
8 | 8 |
9 This script corresponds to the 'emma_instr' action in the java build process. | 9 This script corresponds to the 'emma_instr' action in the java build process. |
10 Depending on whether emma_instrument is set, the 'emma_instr' action will either | 10 Depending on whether emma_instrument is set, the 'emma_instr' action will either |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 '-out', options.coverage_file, | 174 '-out', options.coverage_file, |
175 '-m', 'fullcopy'] | 175 '-m', 'fullcopy'] |
176 build_utils.CheckOutput(cmd) | 176 build_utils.CheckOutput(cmd) |
177 | 177 |
178 temp_jar_dir = os.path.join(temp_dir, 'lib') | 178 temp_jar_dir = os.path.join(temp_dir, 'lib') |
179 jars = os.listdir(temp_jar_dir) | 179 jars = os.listdir(temp_jar_dir) |
180 if len(jars) != 1: | 180 if len(jars) != 1: |
181 print('Error: multiple output files in: %s' % (temp_jar_dir)) | 181 print('Error: multiple output files in: %s' % (temp_jar_dir)) |
182 return 1 | 182 return 1 |
183 | 183 |
184 shutil.copy(os.path.join(temp_jar_dir, jars[0]), options.output_path) | 184 # Delete output_path first to avoid modifying input_path in the case where |
185 # input_path is a hardlink to output_path. http://crbug.com/571642 | |
jbudorick
2015/12/22 19:34:44
I'm confused about how this fixes 571642. That fai
agrieve
2015/12/22 20:10:00
1. Build once without coverage enabled, and there'
jbudorick
2015/12/22 20:42:35
ah, ok. lgtm
| |
186 if os.path.exists(options.output_path): | |
187 os.unlink(options.output_path) | |
188 shutil.move(os.path.join(temp_jar_dir, jars[0]), options.output_path) | |
185 finally: | 189 finally: |
186 shutil.rmtree(temp_dir) | 190 shutil.rmtree(temp_dir) |
187 | 191 |
188 if options.source_dirs: | 192 if options.source_dirs: |
189 source_dirs = build_utils.ParseGypList(options.source_dirs) | 193 source_dirs = build_utils.ParseGypList(options.source_dirs) |
190 else: | 194 else: |
191 source_dirs = _GetSourceDirsFromSourceFiles(options.source_files) | 195 source_dirs = _GetSourceDirsFromSourceFiles(options.source_files) |
192 _CreateSourcesListFile(source_dirs, options.sources_list_file, | 196 _CreateSourcesListFile(source_dirs, options.sources_list_file, |
193 options.src_root) | 197 options.src_root) |
194 | 198 |
(...skipping 18 matching lines...) Expand all Loading... | |
213 | 217 |
214 | 218 |
215 def main(): | 219 def main(): |
216 option_parser = command_option_parser.CommandOptionParser( | 220 option_parser = command_option_parser.CommandOptionParser( |
217 commands_dict=VALID_COMMANDS) | 221 commands_dict=VALID_COMMANDS) |
218 command_option_parser.ParseAndExecute(option_parser) | 222 command_option_parser.ParseAndExecute(option_parser) |
219 | 223 |
220 | 224 |
221 if __name__ == '__main__': | 225 if __name__ == '__main__': |
222 sys.exit(main()) | 226 sys.exit(main()) |
OLD | NEW |