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

Side by Side Diff: cheddar_monkey.py

Issue 1505823003: Add script to mass add a new #include. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some fixes Created 4 years, 8 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
« no previous file with comments | « no previous file | tools/clang/pass_to_move/add_header.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import argparse
7 import os
8 import re
9 import subprocess
10 import sys
11
12 # Clang errors look like this:
13 # ../../base/test/test_discardable_memory_allocator.cc:22:5: error: use of undec lared identifier 'DCHECK'
14 _CLANG_ERROR_RE = re.compile('(?P<path>[^:]+):\d+:\d+: error: .+')
15
16
17 def FindFirstFileWithError(output):
18 for line in output.splitlines():
19 match = _CLANG_ERROR_RE.match(line)
20 if match:
21 return match.group('path')
22
23
24 def main():
25 parser = argparse.ArgumentParser()
26 parser.add_argument('--header', required=True)
27 parser.add_argument('--build-dir', default='.')
28 parser.add_argument('additional_build_args', nargs='*')
29 args = parser.parse_args()
30
31 while True:
32 try:
33 ninja_args = ['ninja']
34 ninja_args.extend(['-C', args.build_dir])
35 ninja_args.extend(args.additional_build_args)
36 print 'Running %s' % ninja_args
37 subprocess.check_output(ninja_args)
38 except subprocess.CalledProcessError as e:
39 print 'Got a compile error!'
40 bad_file = FindFirstFileWithError(e.output)
41 if not bad_file:
42 print 'Something bad happened!'
43 print e.output
44 return 2
45 bad_file_path = os.path.join(args.build_dir, bad_file)
46 add_header_args = ['python', 'tools/clang/pass_to_move/add_header.py',
47 '--header', args.header, bad_file_path]
48 print 'Inserting header with command %s' % add_header_args
49 subprocess.check_call(add_header_args)
50 continue
51 except Exception as e:
52 print 'Something weird happened: %s' % e
53 return 1
54 print 'Probably done! \(^.^)/'
55 break
56
57
58 if __name__ == '__main__':
59 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | tools/clang/pass_to_move/add_header.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698