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 a hook. If it detects that the build should | 7 This script runs every build as a hook. If it detects that the build should |
8 be clobbered, it will touch the file <build_dir>/.landmine_triggered. The | 8 be clobbered, it will touch the file <build_dir>/.landmine_triggered. The |
9 various build scripts will then check for the presence of this file and clobber | 9 various build scripts will then check for the presence of this file and clobber |
10 accordingly. The script will also emit the reasons for the clobber to stdout. | 10 accordingly. The script will also emit the reasons for the clobber to stdout. |
11 | 11 |
12 A landmine is tripped when a builder checks out a different revision, and the | 12 A landmine is tripped when a builder checks out a different revision, and the |
13 diff between the new landmines and the old ones is non-null. At this point, the | 13 diff between the new landmines and the old ones is non-null. At this point, the |
14 build is clobbered. | 14 build is clobbered. |
15 """ | 15 """ |
16 | 16 |
17 import difflib | 17 import difflib |
| 18 import errno |
18 import logging | 19 import logging |
19 import optparse | 20 import optparse |
20 import os | 21 import os |
21 import sys | 22 import sys |
22 import subprocess | 23 import subprocess |
23 import time | 24 import time |
24 | 25 |
25 import landmine_utils | 26 import landmine_utils |
26 | 27 |
27 | 28 |
(...skipping 22 matching lines...) Expand all Loading... |
50 raise NotImplementedError('Unexpected GYP_GENERATORS (%s)' % build_tool) | 51 raise NotImplementedError('Unexpected GYP_GENERATORS (%s)' % build_tool) |
51 return os.path.abspath(ret) | 52 return os.path.abspath(ret) |
52 | 53 |
53 | 54 |
54 def set_up_landmines(target, new_landmines): | 55 def set_up_landmines(target, new_landmines): |
55 """Does the work of setting, planting, and triggering landmines.""" | 56 """Does the work of setting, planting, and triggering landmines.""" |
56 out_dir = get_target_build_dir(landmine_utils.builder(), target, | 57 out_dir = get_target_build_dir(landmine_utils.builder(), target, |
57 landmine_utils.platform() == 'ios') | 58 landmine_utils.platform() == 'ios') |
58 | 59 |
59 landmines_path = os.path.join(out_dir, '.landmines') | 60 landmines_path = os.path.join(out_dir, '.landmines') |
60 if not os.path.exists(out_dir): | 61 try: |
61 os.makedirs(out_dir) | 62 os.makedirs(out_dir) |
| 63 except OSError as e: |
| 64 if e.errno == errno.EEXIST: |
| 65 pass |
62 | 66 |
63 if not os.path.exists(landmines_path): | 67 if not os.path.exists(landmines_path): |
64 with open(landmines_path, 'w') as f: | 68 with open(landmines_path, 'w') as f: |
65 f.writelines(new_landmines) | 69 f.writelines(new_landmines) |
66 else: | 70 else: |
67 triggered = os.path.join(out_dir, '.landmines_triggered') | 71 triggered = os.path.join(out_dir, '.landmines_triggered') |
68 with open(landmines_path, 'r') as f: | 72 with open(landmines_path, 'r') as f: |
69 old_landmines = f.readlines() | 73 old_landmines = f.readlines() |
70 if old_landmines != new_landmines: | 74 if old_landmines != new_landmines: |
71 old_date = time.ctime(os.stat(landmines_path).st_ctime) | 75 old_date = time.ctime(os.stat(landmines_path).st_ctime) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 stdout=subprocess.PIPE) | 127 stdout=subprocess.PIPE) |
124 output, _ = proc.communicate() | 128 output, _ = proc.communicate() |
125 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) | 129 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) |
126 set_up_landmines(target, landmines) | 130 set_up_landmines(target, landmines) |
127 | 131 |
128 return 0 | 132 return 0 |
129 | 133 |
130 | 134 |
131 if __name__ == '__main__': | 135 if __name__ == '__main__': |
132 sys.exit(main()) | 136 sys.exit(main()) |
OLD | NEW |