Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: build/landmines.py

Issue 293983017: Always write .landmines (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 out_dir = get_target_build_dir(landmine_utils.builder(), target, 57 out_dir = get_target_build_dir(landmine_utils.builder(), target,
58 landmine_utils.platform() == 'ios') 58 landmine_utils.platform() == 'ios')
59 59
60 landmines_path = os.path.join(out_dir, '.landmines') 60 landmines_path = os.path.join(out_dir, '.landmines')
61 try: 61 try:
62 os.makedirs(out_dir) 62 os.makedirs(out_dir)
63 except OSError as e: 63 except OSError as e:
64 if e.errno == errno.EEXIST: 64 if e.errno == errno.EEXIST:
65 pass 65 pass
66 66
67 if not os.path.exists(landmines_path): 67 if os.path.exists(landmines_path):
68 with open(landmines_path, 'w') as f:
69 f.writelines(new_landmines)
70 else:
71 triggered = os.path.join(out_dir, '.landmines_triggered') 68 triggered = os.path.join(out_dir, '.landmines_triggered')
72 with open(landmines_path, 'r') as f: 69 with open(landmines_path, 'r') as f:
73 old_landmines = f.readlines() 70 old_landmines = f.readlines()
74 if old_landmines != new_landmines: 71 if old_landmines != new_landmines:
75 old_date = time.ctime(os.stat(landmines_path).st_ctime) 72 old_date = time.ctime(os.stat(landmines_path).st_ctime)
76 diff = difflib.unified_diff(old_landmines, new_landmines, 73 diff = difflib.unified_diff(old_landmines, new_landmines,
77 fromfile='old_landmines', tofile='new_landmines', 74 fromfile='old_landmines', tofile='new_landmines',
78 fromfiledate=old_date, tofiledate=time.ctime(), n=0) 75 fromfiledate=old_date, tofiledate=time.ctime(), n=0)
79 76
80 with open(triggered, 'w') as f: 77 with open(triggered, 'w') as f:
81 f.writelines(diff) 78 f.writelines(diff)
82 elif os.path.exists(triggered): 79 elif os.path.exists(triggered):
83 # Remove false triggered landmines. 80 # Remove false triggered landmines.
84 os.remove(triggered) 81 os.remove(triggered)
82 with open(landmines_path, 'w') as f:
83 f.writelines(new_landmines)
85 84
86 85
87 def process_options(): 86 def process_options():
88 """Returns a list of landmine emitting scripts.""" 87 """Returns a list of landmine emitting scripts."""
89 parser = optparse.OptionParser() 88 parser = optparse.OptionParser()
90 parser.add_option( 89 parser.add_option(
91 '-s', '--landmine-scripts', action='append', 90 '-s', '--landmine-scripts', action='append',
92 default=[os.path.join(SRC_DIR, 'build', 'get_landmines.py')], 91 default=[os.path.join(SRC_DIR, 'build', 'get_landmines.py')],
93 help='Path to the script which emits landmines to stdout. The target ' 92 help='Path to the script which emits landmines to stdout. The target '
94 'is passed to this script via option -t. Note that an extra ' 93 'is passed to this script via option -t. Note that an extra '
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 stdout=subprocess.PIPE) 126 stdout=subprocess.PIPE)
128 output, _ = proc.communicate() 127 output, _ = proc.communicate()
129 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) 128 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()])
130 set_up_landmines(target, landmines) 129 set_up_landmines(target, landmines)
131 130
132 return 0 131 return 0
133 132
134 133
135 if __name__ == '__main__': 134 if __name__ == '__main__':
136 sys.exit(main()) 135 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698