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

Side by Side Diff: include_rsp.py

Issue 718873004: Various hacks for running a clang tool on Windows. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
(Empty)
1 import os
2 import re
3 import json
4 import sys
5
6
7 _NINJA_MSVC_WRAPPER = re.compile('ninja -t msvc -e .+? -- ')
8 _RSP_RE = re.compile(r' (@(.+?\.rsp)) ')
9
10
11 def process_arg(arg):
12 if not arg.startswith('/'):
13 return arg
14 if arg == '/c':
15 return '-c'
16 if arg.startswith('/Fo'):
17 return arg.replace('/Fo', '-o ', 1)
18 return ''
19
20
21 def process_entry(e):
22 # Strip off the ninja -t msvc wrapper.
23 e['command'] = _NINJA_MSVC_WRAPPER.sub('', e['command'])
24
25 # Expand the contents of the response file, if any.
26 try:
27 match = _RSP_RE.search(e['command'])
28 rsp_path = os.path.join(e['directory'], match.group(2))
29 rsp_contents = file(rsp_path).read()
30 e['command'] = e['command'][:match.start(1)] + rsp_contents + e['command'][m atch.end(1):]
31 except IOError:
32 pass
33
34 # TODO(dcheng): This should be implemented as an argument adjuster.
35 # Convert a limited subset of MSVC arguments to clang-style arguments and
36 # remove the rest.
37 e['command'] = ' '.join([process_arg(arg) for arg in e['command'].split(' ')])
38 e['command'] += ' -fms-compatibility -fms-extensions'
39 e['command'] += ' -target i686-pc-windows-msvc'
40 # e['command'] += ' --driver-mode=cl'
dcheng 2014/11/11 23:36:07 Lines 38-40 were various attempts to get clang-cl
hans 2014/11/11 23:42:44 Is it invoked as clang-cl but not getting into cl
41
42 # TODO(dcheng): This should be implemented in Clang tooling.
43 # Finally, use slashes instead of backslashes to avoid bad escaping by the
44 # tooling. This should really only matter for command, but we do it for all ke ys
45 # for consistency.
46 e['directory'] = e['directory'].replace('\\', '/')
47 e['command'] = e['command'].replace('\\', '/')
48 e['file'] = e['file'].replace('\\', '/')
49
50 return e
51
52
53 def main(argv):
54 compile_db = json.loads(file('out/Debug/compile_commands.json').read())
55 print 'Read in %d entries from the compile db' % len(compile_db)
56 compile_db = [process_entry(e) for e in compile_db]
57 prefilter_len = len(compile_db)
58 # Filter out entries that still have RSP in them.
59 compile_db = [e for e in compile_db if e['command'].find('.obj.rsp') == -1]
dcheng 2014/11/11 23:36:07 For some reason, the compile DB had two entries fo
60 print 'Filtered out %d entries' % (prefilter_len - len(compile_db))
61 compile_db_with_rsp = json.dumps(compile_db, indent=2)
62 f = file('out/Debug/compile_commands_with_rsp.json', 'w')
63 f.write(compile_db_with_rsp)
64 print 'Wrote out new compile db with rsp inline'
65
66
67 if __name__ == '__main__':
68 sys.exit(main(sys.argv[1:]))
69
OLDNEW
« no previous file with comments | « no previous file | tools/clang/rewrite_scoped_refptr/CMakeLists.txt » ('j') | tools/clang/rewrite_scoped_refptr/CMakeLists.txt » ('J')

Powered by Google App Engine
This is Rietveld 408576698