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. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 fromfile='old_landmines', tofile='new_landmines', | 76 fromfile='old_landmines', tofile='new_landmines', |
77 fromfiledate=old_date, tofiledate=time.ctime(), n=0) | 77 fromfiledate=old_date, tofiledate=time.ctime(), n=0) |
78 | 78 |
79 with open(triggered, 'w') as f: | 79 with open(triggered, 'w') as f: |
80 f.writelines(diff) | 80 f.writelines(diff) |
81 elif os.path.exists(triggered): | 81 elif os.path.exists(triggered): |
82 # Remove false triggered landmines. | 82 # Remove false triggered landmines. |
83 os.remove(triggered) | 83 os.remove(triggered) |
84 | 84 |
85 | 85 |
86 def main(): | 86 def process_options(): |
87 """Returns a list of landmine emitting scripts.""" | |
87 parser = optparse.OptionParser() | 88 parser = optparse.OptionParser() |
88 parser.add_option( | 89 parser.add_option( |
89 '-s', '--landmine-scripts', action='append', | 90 '-s', '--landmine-scripts', action='append', |
90 default=[os.path.join(SRC_DIR, 'build', 'get_landmines.py')], | 91 default=[os.path.join(SRC_DIR, 'build', 'get_landmines.py')], |
91 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 ' |
92 'is passed to this script via option -t.') | 93 'is passed to this script via option -t. Note that an extra ' |
94 'script can be specified via an env var EXTRA_LANDMINES_SCRIPT.') | |
93 parser.add_option('-v', '--verbose', action='store_true', | 95 parser.add_option('-v', '--verbose', action='store_true', |
94 default=('LANDMINES_VERBOSE' in os.environ), | 96 default=('LANDMINES_VERBOSE' in os.environ), |
95 help=('Emit some extra debugging information (default off). This option ' | 97 help=('Emit some extra debugging information (default off). This option ' |
96 'is also enabled by the presence of a LANDMINES_VERBOSE environment ' | 98 'is also enabled by the presence of a LANDMINES_VERBOSE environment ' |
97 'variable.')) | 99 'variable.')) |
98 | 100 |
99 options, args = parser.parse_args() | 101 options, args = parser.parse_args() |
100 | |
101 if args: | 102 if args: |
iannucci
2013/08/31 01:18:59
I'd keep this whitespace line
| |
102 parser.error('Unknown arguments %s' % args) | 103 parser.error('Unknown arguments %s' % args) |
103 | 104 |
104 logging.basicConfig( | 105 logging.basicConfig( |
105 level=logging.DEBUG if options.verbose else logging.ERROR) | 106 level=logging.DEBUG if options.verbose else logging.ERROR) |
106 | 107 |
108 extra_script = os.environ.get('EXTRA_LANDMINES_SCRIPT') | |
109 if extra_script: | |
110 return options.landmine_scripts + [extra_script] | |
111 else: | |
112 return options.landmine_scripts | |
113 | |
114 | |
115 def main(): | |
116 landmine_scripts = process_options() | |
107 gyp_helper.apply_chromium_gyp_env() | 117 gyp_helper.apply_chromium_gyp_env() |
108 | 118 |
109 for target in ('Debug', 'Release', 'Debug_x64', 'Release_x64'): | 119 for target in ('Debug', 'Release', 'Debug_x64', 'Release_x64'): |
110 landmines = [] | 120 landmines = [] |
111 for s in options.landmine_scripts: | 121 for s in landmine_scripts: |
112 proc = subprocess.Popen([sys.executable, s, '-t', target], | 122 proc = subprocess.Popen([sys.executable, s, '-t', target], |
113 stdout=subprocess.PIPE) | 123 stdout=subprocess.PIPE) |
114 output, _ = proc.communicate() | 124 output, _ = proc.communicate() |
115 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) | 125 landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()]) |
126 | |
iannucci
2013/08/31 01:18:59
and remove this one
| |
116 set_up_landmines(target, landmines) | 127 set_up_landmines(target, landmines) |
117 | 128 |
118 return 0 | 129 return 0 |
119 | 130 |
120 | 131 |
121 if __name__ == '__main__': | 132 if __name__ == '__main__': |
122 sys.exit(main()) | 133 sys.exit(main()) |
OLD | NEW |