| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ | 6 """ |
| 7 This script runs every build as the first hook (See DEPS). If it detects that | 7 This script runs every build as the first hook (See DEPS). If it detects that |
| 8 the build should be clobbered, it will delete the contents of the build | 8 the build should be clobbered, it will delete the contents of the build |
| 9 directory. | 9 directory. |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 if os.path.exists(landmines_path): | 66 if os.path.exists(landmines_path): |
| 67 with open(landmines_path, 'r') as f: | 67 with open(landmines_path, 'r') as f: |
| 68 old_landmines = f.readlines() | 68 old_landmines = f.readlines() |
| 69 if old_landmines != new_landmines: | 69 if old_landmines != new_landmines: |
| 70 old_date = time.ctime(os.stat(landmines_path).st_ctime) | 70 old_date = time.ctime(os.stat(landmines_path).st_ctime) |
| 71 diff = difflib.unified_diff(old_landmines, new_landmines, | 71 diff = difflib.unified_diff(old_landmines, new_landmines, |
| 72 fromfile='old_landmines', tofile='new_landmines', | 72 fromfile='old_landmines', tofile='new_landmines', |
| 73 fromfiledate=old_date, tofiledate=time.ctime(), n=0) | 73 fromfiledate=old_date, tofiledate=time.ctime(), n=0) |
| 74 sys.stdout.write('Clobbering due to:\n') | 74 sys.stdout.write('Clobbering due to:\n') |
| 75 sys.stdout.writelines(diff) | 75 sys.stdout.writelines(diff) |
| 76 sys.stdout.flush() |
| 76 | 77 |
| 77 clobber.clobber(out_dir) | 78 clobber.clobber(out_dir) |
| 78 | 79 |
| 79 # Save current set of landmines for next time. | 80 # Save current set of landmines for next time. |
| 80 with open(landmines_path, 'w') as f: | 81 with open(landmines_path, 'w') as f: |
| 81 f.writelines(new_landmines) | 82 f.writelines(new_landmines) |
| 82 | 83 |
| 83 | 84 |
| 84 def process_options(): | 85 def process_options(): |
| 85 """Returns an options object containing the configuration for this script.""" | 86 """Returns an options object containing the configuration for this script.""" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE) | 139 proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE) |
| 139 output, _ = proc.communicate() | 140 output, _ = proc.communicate() |
| 140 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) | 141 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) |
| 141 clobber_if_necessary(landmines, options.src_dir) | 142 clobber_if_necessary(landmines, options.src_dir) |
| 142 | 143 |
| 143 return 0 | 144 return 0 |
| 144 | 145 |
| 145 | 146 |
| 146 if __name__ == '__main__': | 147 if __name__ == '__main__': |
| 147 sys.exit(main()) | 148 sys.exit(main()) |
| OLD | NEW |