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

Side by Side Diff: tools/clang/scripts/generate_win_compdb.py

Issue 2673683006: Stop special handling of backslashes in compilation command lines. (Closed)
Patch Set: Rebasing... Created 3 years, 10 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 | 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 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 Clang tools on Windows are still a bit busted. The tooling can't handle 7 Clang tools on Windows are still a bit busted. The tooling can't handle
8 backslashes in paths, doesn't understand how to read .rsp files, etc. In 8 backslashes in paths, doesn't understand how to read .rsp files, etc. In
9 addition, ninja generates compile commands prefixed with the ninja msvc helper, 9 addition, ninja generates compile commands prefixed with the ninja msvc helper,
10 which also confuses clang. This script generates a compile DB that should mostly 10 which also confuses clang. This script generates a compile DB that should mostly
(...skipping 30 matching lines...) Expand all
41 match = _RSP_RE.search(e['command']) 41 match = _RSP_RE.search(e['command'])
42 rsp_path = os.path.join(e['directory'], match.group(2)) 42 rsp_path = os.path.join(e['directory'], match.group(2))
43 rsp_contents = file(rsp_path).read() 43 rsp_contents = file(rsp_path).read()
44 e['command'] = ''.join([ 44 e['command'] = ''.join([
45 e['command'][:match.start(1)], 45 e['command'][:match.start(1)],
46 rsp_contents, 46 rsp_contents,
47 e['command'][match.end(1):]]) 47 e['command'][match.end(1):]])
48 except IOError: 48 except IOError:
49 pass 49 pass
50 50
51 # TODO(dcheng): This should be implemented in Clang tooling.
52 # http://llvm.org/bugs/show_bug.cgi?id=19687
53 # Finally, use slashes instead of backslashes to avoid bad escaping by the
54 # tooling. This should really only matter for command, but we do it for all
55 # keys for consistency.
56 e['directory'] = e['directory'].replace('\\', '/')
57 e['command'] = e['command'].replace('\\', '/')
58 e['file'] = e['file'].replace('\\', '/')
59
60 return e 51 return e
61 52
62 53
63 def main(argv): 54 def main(argv):
64 # Parse argument 55 # Parse argument
65 parser = argparse.ArgumentParser() 56 parser = argparse.ArgumentParser()
66 parser.add_argument( 57 parser.add_argument(
67 'build_path', 58 'build_path',
68 nargs='?', 59 nargs='?',
69 help='Path to build directory', 60 help='Path to build directory',
(...skipping 13 matching lines...) Expand all
83 compile_db = [e for e in compile_db if '_nacl.cc.pdb' not in e['command'] 74 compile_db = [e for e in compile_db if '_nacl.cc.pdb' not in e['command']
84 and '_nacl_win64.cc.pdb' not in e['command']] 75 and '_nacl_win64.cc.pdb' not in e['command']]
85 print 'Filtered out %d entries...' % (original_length - len(compile_db)) 76 print 'Filtered out %d entries...' % (original_length - len(compile_db))
86 f = file('%s/compile_commands.json' % args.build_path, 'w') 77 f = file('%s/compile_commands.json' % args.build_path, 'w')
87 f.write(json.dumps(compile_db, indent=2)) 78 f.write(json.dumps(compile_db, indent=2))
88 print 'Done!' 79 print 'Done!'
89 80
90 81
91 if __name__ == '__main__': 82 if __name__ == '__main__':
92 sys.exit(main(sys.argv[1:])) 83 sys.exit(main(sys.argv[1:]))
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