OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 the V8 project 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. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 | 51 |
52 | 52 |
53 def set_up_landmines(target, new_landmines): | 53 def set_up_landmines(target, new_landmines): |
54 """Does the work of setting, planting, and triggering landmines.""" | 54 """Does the work of setting, planting, and triggering landmines.""" |
55 out_dir = get_target_build_dir(landmine_utils.builder(), target) | 55 out_dir = get_target_build_dir(landmine_utils.builder(), target) |
56 | 56 |
57 landmines_path = os.path.join(out_dir, '.landmines') | 57 landmines_path = os.path.join(out_dir, '.landmines') |
58 if not os.path.exists(out_dir): | 58 if not os.path.exists(out_dir): |
59 return | 59 return |
60 | 60 |
61 if os.path.exists(landmines_path): | 61 # Make sure the landmines tracker exists. |
62 triggered = os.path.join(out_dir, '.landmines_triggered') | 62 open(landmines_path, 'a').close() |
63 with open(landmines_path, 'r') as f: | |
64 old_landmines = f.readlines() | |
65 if old_landmines != new_landmines: | |
66 old_date = time.ctime(os.stat(landmines_path).st_ctime) | |
67 diff = difflib.unified_diff(old_landmines, new_landmines, | |
68 fromfile='old_landmines', tofile='new_landmines', | |
69 fromfiledate=old_date, tofiledate=time.ctime(), n=0) | |
70 | 63 |
71 with open(triggered, 'w') as f: | 64 triggered = os.path.join(out_dir, '.landmines_triggered') |
72 f.writelines(diff) | 65 with open(landmines_path, 'r') as f: |
73 elif os.path.exists(triggered): | 66 old_landmines = f.readlines() |
74 # Remove false triggered landmines. | 67 if old_landmines != new_landmines: |
75 os.remove(triggered) | 68 old_date = time.ctime(os.stat(landmines_path).st_ctime) |
69 diff = difflib.unified_diff(old_landmines, new_landmines, | |
70 fromfile='old_landmines', tofile='new_landmines', | |
71 fromfiledate=old_date, tofiledate=time.ctime(), n=0) | |
72 | |
73 with open(triggered, 'w') as f: | |
74 f.writelines(diff) | |
75 print "Setting landmine: %s" % triggered | |
Jakob Kummerow
2014/07/23 11:05:48
are you keeping these print statements intentional
| |
76 print "Reason:\n%s" % diff | |
77 elif os.path.exists(triggered): | |
78 # Remove false triggered landmines. | |
79 os.remove(triggered) | |
80 print "Removing landmine: %s" % triggered | |
76 with open(landmines_path, 'w') as f: | 81 with open(landmines_path, 'w') as f: |
77 f.writelines(new_landmines) | 82 f.writelines(new_landmines) |
78 | 83 |
79 | 84 |
80 def process_options(): | 85 def process_options(): |
81 """Returns a list of landmine emitting scripts.""" | 86 """Returns a list of landmine emitting scripts.""" |
82 parser = optparse.OptionParser() | 87 parser = optparse.OptionParser() |
83 parser.add_option( | 88 parser.add_option( |
84 '-s', '--landmine-scripts', action='append', | 89 '-s', '--landmine-scripts', action='append', |
85 default=[os.path.join(SRC_DIR, 'build', 'get_landmines.py')], | 90 default=[os.path.join(SRC_DIR, 'build', 'get_landmines.py')], |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) | 125 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) |
121 | 126 |
122 for target in ('Debug', 'Release'): | 127 for target in ('Debug', 'Release'): |
123 set_up_landmines(target, landmines) | 128 set_up_landmines(target, landmines) |
124 | 129 |
125 return 0 | 130 return 0 |
126 | 131 |
127 | 132 |
128 if __name__ == '__main__': | 133 if __name__ == '__main__': |
129 sys.exit(main()) | 134 sys.exit(main()) |
OLD | NEW |